Jump to content

create variable for a player


Recommended Posts

Can you help me with this?

I did, but neither remembered that this does not work if another player were to use the command ...

  
function givekit2( player ) 
    local accName = getAccountName ( getPlayerAccount ( player ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Vip" ) ) then 
        if not tempokit2 then 
            giveWeapon ( player, 31, 300 ) --Give M4 
            giveWeapon ( player, 34, 80 ) -- Give Sniper Rifle 
            tempokit2 = true 
            setTimer(set1hora,3600000,1,player) 
        else 
            outputChatBox ( "#ff0000Voce tem que esperar 1 hora para poder pegar o kit novamente.", player, 255,0,0) 
        end 
        else 
        outputChatBox ( "#ff0000Voce nao e um VIP!", player, 255,0,0) 
    end 
end 
addCommandHandler("kitpremiun",givekit2) 
  
function set1hora() 
    tempokit2 = false 
end 
  

Link to comment
Can you help me with this?

I did, but neither remembered that this does not work if another player were to use the command ...

  
function givekit2( player ) 
    local accName = getAccountName ( getPlayerAccount ( player ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Vip" ) ) then 
        if not tempokit2 then 
            giveWeapon ( player, 31, 300 ) --Give M4 
            giveWeapon ( player, 34, 80 ) -- Give Sniper Rifle 
            tempokit2 = true 
            setTimer(set1hora,3600000,1,player) 
        else 
            outputChatBox ( "#ff0000Voce tem que esperar 1 hora para poder pegar o kit novamente.", player, 255,0,0) 
        end 
        else 
        outputChatBox ( "#ff0000Voce nao e um VIP!", player, 255,0,0) 
    end 
end 
addCommandHandler("kitpremiun",givekit2) 
  
function set1hora() 
    tempokit2 = false 
end 
  

Don't use normal variables for player variables, use element data with the example I showed you.

Another example:

  
setElementData(player, "tempokit2", true)  
local istrue = getElementData(player, "tempokit2") 
  

Link to comment

so?

  
function givekit2( player ) 
    local accName = getAccountName ( getPlayerAccount ( player ) ) 
    local istrue = getElementData(player, "tempokit2") 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Vip" ) ) then 
        if not istrue then 
            giveWeapon ( player, 31, 300 ) --Give M4 
            giveWeapon ( player, 34, 80 ) -- Give Sniper Rifle 
            setElementData(player, "tempokit2", true) 
            setTimer ( function() 
                setElementData(player, "tempokit2", false) 
                end, 3600000, 1 ) 
        else 
            outputChatBox ( "#ff0000Voce tem que esperar 1 hora para poder pegar o kit novamente.", player, 255,0,0) 
        end 
        else 
        outputChatBox ( "#ff0000Voce nao e um VIP!", player, 255,0,0) 
    end 
end 
addCommandHandler("kitpremiun",givekit2) 
  

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