• Script help (NWBool)
    8 replies, posted
I try to write a simple script, but it wont work.. it's also causing other scripts to stop working. Its just a simple command. [CODE]hook.Add("PlayerSay","RulesCommand",function(ply,text) if(string.sub(string.lower(text),1,6) == "!acceptrules") then if(ply:GetNWBool("rulesaccepted",false)==false) then ply:SetNWBool("rulesaccepted",true) print( ply:Nick() .. " accepted the rules." ) return "" else end end end)[/CODE]
You say it's not working... Does it ever print the message in console? Are there any errors from this addon? BTW, to print to the player use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ChatPrint]Player:ChatPrint[/url]
[QUOTE=MexicanR;50350768]You say it's not working... Does it ever print the message in console? Are there any errors from this addon? BTW, to print to the player use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ChatPrint]Player:ChatPrint[/url][/QUOTE] there are no errors, its also not printing the message.. well... thats wierd.. just the html scripts are not working with this script.. wtf..
Do you set the bool anywhere before you try to get it? If not you could do something like this: [code] hook.Add( "PlayerAuthed", "SetRules", function(ply) if ply:GetNWBool( "rulesaccepted", false) == false then ply:SetNWBool( "rulesaccepted", true) else ply:SetNWBool( "rulesaccepted", false) end end) [/code]
[QUOTE=MexicanR;50350808]Do you set the bool anywhere before you try to get it?[/QUOTE] the command it for setting the bool, if its not set its returning false but i found out that only the html requests and the script itself are not working.. because its not printing the message
[CODE] function lololo( ply, text ) if text == "!acceptrules" and not ply:GetNWBool("rulesaccepted") then ply:SetNWBool("rulesaccepted",true) print( ply:Nick() .. " accepted the rules." ) end end hook.Add( "PlayerSay", "lololo", lololo) [/CODE] Try it
[QUOTE=NikkuMiru;50350816]the command it for setting the bool, if its not set its returning false but i found out that only the html requests and the script itself are not working.. because its not printing the message[/QUOTE] Ok, but you still have to set it beforehand and make sure it actually exists.
[quote]if(string.sub(string.lower(text),1,6) == "!acceptrules") then[/quote] I'm not 100% sure on this, but you're using 6 as the third string sub argument and yet your text is bigger in character length so that might be stopping the contents from being executed Here's the wiki example: [img]http://i.imgur.com/dYA1Egf.png[/img] You can just do 'if text == "whatever'
[QUOTE=godred2;50350830][CODE] function lololo( ply, text ) if text == "!acceptrules" and not ply:GetNWBool("rulesaccepted") then ply:SetNWBool("rulesaccepted",true) print( ply:Nick() .. " accepted the rules." ) end end hook.Add( "PlayerSay", "lololo", lololo) [/CODE] Try it[/QUOTE] well its printing into the console but the html scripts are still not working... they'r also not printing errors... just working when the script is gone.. the script itself is working now, thanks.
Sorry, you need to Log In to post a reply to this thread.