DjMixCuma Posted December 8, 2012 Share Posted December 8, 2012 Hello! how to create Variable for all players? please any example, thanks ) i want create this if variable == 1 then --they can't else --they can end Link to comment
Castillo Posted December 8, 2012 Share Posted December 8, 2012 local welcomeText = "Hello World!" addEventHandler ( "onPlayerJoin", root, function ( ) outputChatBox ( welcomeText, source ) end ) That'll output the 'welcomeText' content to all players who join the server. Link to comment
DjMixCuma Posted December 8, 2012 Author Share Posted December 8, 2012 solidsnake i want set this for example: local can = {} if can[source].command == true then -- all players can use this command else -- no all players can use this command so how to set can[source].command (for example) for all players?? Link to comment
Castillo Posted December 8, 2012 Share Posted December 8, 2012 That's a table, not a variable. And you can remove all that [ source ] and leave it like this: local can = { } if can.command == true then -- all players can use this command else -- no all players can use this command end Link to comment
DjMixCuma Posted December 8, 2012 Author Share Posted December 8, 2012 sorry my bad i'm noob in lua. thanks for help i will write later, if it working. Link to comment
DjMixCuma Posted December 8, 2012 Author Share Posted December 8, 2012 okey working but how to on start resource give permission to start command? my code: local can = {} addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() can.Command = true end function start() if can.Command == true then setTimer(stop, 5000, 1) can.Command = false outputChatBox("Can!", 255, 255, 255, true) else outputChatBox("Can't!", 255, 255, 255, true) end end function stop() can.Command = true outputChatBox("Now Can Again!", 255, 255, 255, true) end addCommandHandler("test", start) Link to comment
DjMixCuma Posted December 8, 2012 Author Share Posted December 8, 2012 When i spawn i want to use /test, but i cant because table is false default in this construction of code: local can = {} function start() if can.Command == true then setTimer(stop, 5000, 1) can.Command = false outputChatBox("Can!", 255, 255, 255, true) else outputChatBox("Can't!", 255, 255, 255, true) end end function stop() can.Command = true outputChatBox("Now Can Again!", 255, 255, 255, true) end addCommandHandler("test", start) but when i using this: local can = {} addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() can.Command = true end function start() if can.Command == true then setTimer(stop, 5000, 1) can.Command = false outputChatBox("Can!", 255, 255, 255, true) else outputChatBox("Can't!", 255, 255, 255, true) end end function stop() can.Command = true outputChatBox("Now Can Again!", 255, 255, 255, true) end addCommandHandler("test", start) command not working, but when i use this: local can = {} function start() can.Command = true if can.Command == true then setTimer(stop, 5000, 1) can.Command = false outputChatBox("Can!", 255, 255, 255, true) else outputChatBox("Can't!", 255, 255, 255, true) end end function stop() can.Command = true outputChatBox("Now Can Again!", 255, 255, 255, true) end addCommandHandler("test", start) i can use command infinitely Link to comment
Castillo Posted December 8, 2012 Share Posted December 8, 2012 Wiki quote: Note: You cannot use "list" or "test" as command name. local can = { } function start ( player ) if ( can.Command == true ) then setTimer ( stop, 5000, 1 ) can.Command = false outputChatBox ( "Can!", player, 255, 255, 255, true ) else outputChatBox ( "Can't!", player, 255, 255, 255, true ) end end addCommandHandler ( "test2", start ) function stop ( ) can.Command = true outputChatBox ( "Now Can Again!", root, 255, 255, 255, true ) end Link to comment
DjMixCuma Posted December 8, 2012 Author Share Posted December 8, 2012 okey, but i must set can.Command == true for all, when resource starting, because i can't use this command, because can.Command is set to false. Link to comment
Castillo Posted December 8, 2012 Share Posted December 8, 2012 local can = { command = true } function start ( player ) if ( can.Command == true ) then setTimer ( stop, 5000, 1 ) can.Command = false outputChatBox ( "Can!", player, 255, 255, 255, true ) else outputChatBox ( "Can't!", player, 255, 255, 255, true ) end end addCommandHandler ( "test2", start ) function stop ( ) can.Command = true outputChatBox ( "Now Can Again!", root, 255, 255, 255, true ) end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now