hi facepunch i have made a button that when is clicked you can change text that is on the screen... however the problem im having is when a new player joins the game it says nil and when you change the text it only changes for you and it doesnt change it for everybody else.
[IMG]http://oi62.tinypic.com/jq3xi9.jpg[/IMG]
[editline]25th August 2014[/editline]
oh yes and the code:
[QUOTE]laws = "Default Laws"
local HUD = {}
HUD.RED = Color(255, 0, 0, 255)
hook.Add("HUDPaint", "afsfasfasff131313", function()
draw.SimpleText(laws, default, 222, 222, HUD.RED, TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT )
end )
DButton4 = vgui.Create( "DButton" );
DButton4:SetPos( 194, 32 )
DButton4:SetText( "Laws" )
DButton4:SetSize( 32, 20 )
DButton4.DoClick = function()
Derma_StringRequest(
"Laws",
"Modify the laws at the top of the screen.",
"",
function( text ) laws = text end
)
end[/QUOTE]
You need to upload the text to the server and share with all clients.
and don't make a table to hold one value
to prevent it from erroring, adding a check to the beginning of the file should work, if that's all your file does:
[lua]
if not LocalPlayer() then return end
[/lua]
[QUOTE=HumbleTH;45793999]You need to upload the text to the server and share with all clients.
and don't make a table to hold one value
to prevent it from erroring, adding a check to the beginning of the file should work, if that's all your file does:
[lua]
if not LocalPlayer() then return end
[/lua][/QUOTE]
okay so i wasnt able to get it to stop saying nil when i connect.
the file is clientside if that helps.
[editline]25th August 2014[/editline]
[QUOTE=Krown420;45794127]okay so i wasnt able to get it to stop saying nil when i connect.
the file is clientside if that helps.[/QUOTE]
okay nvm i got it to stop saying nil but when i change the text its still only for me
[editline]25th August 2014[/editline]
can anybody tell me how to make sure the string gets sent over the server or whatever like the dude above mentioned?? :quagmire:
Yeah, use the net library, and send a message from the client to the server ( the law which you've entered ), then send it from the server to all the clients.
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=The Beta;45794719]Yeah, use the net library, and send a message from the client to the server ( the law which you've entered ), then send it from the server to all the clients.
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
thank you.. ive took a look at this... and i understand what i need to do... but i cant seem to do it :/
i dont think ima be able to add this
[editline]25th August 2014[/editline]
if somebody could help with this i will be very thankful :zoid:
[editline]25th August 2014[/editline]
i tried doing it by putting this in server file
[QUOTE]
util.AddNetworkString( "Example3" ) // even though the server isn't sending this message, it must be
// networked before the client can send it!
net.Receive( "Example3", function( text, laws )
laws = text
end )[/QUOTE]
and this in client file
[QUOTE]DButton4 = vgui.Create( "DButton" );
DButton4:SetPos( 194, 32 )
DButton4:SetText( "Laws" )
DButton4:SetSize( 32, 20 )
DButton4.DoClick = function()
Derma_StringRequest(
"Laws",
"Modify the laws at the top of the screen.",
"",
function( text ) NetExample3() end
)
end[/QUOTE]
please tell me what i am doing wrong
Add me on steam and I'll guide you through the usage of net-messages.
[QUOTE=The Beta;45795442]Add me on steam and I'll guide you through the usage of net-messages.[/QUOTE]
ty very much bro... is your steam name The Beta?
also the link under your name did not work
[QUOTE=Krown420;45795899]
also the link under your name did not work[/QUOTE]
[url]http://steamcommunity.com/profiles/76561198086752052[/url]
[QUOTE=ms333;45796010][url]http://steamcommunity.com/profiles/76561198086752052[/url][/QUOTE]
thank you good sir
i still need help if anybody can help me solve this :words:
Sorry, you need to Log In to post a reply to this thread.