Jump to content

Variable for all


DjMixCuma

Recommended Posts

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

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...