Jump to content

[HELP] jailtime


opnaiC

Recommended Posts

Posted
function SetJailTime() 
    for theKey,thePlayer in ipairs(getElementsByType ( "player" )) do 
        if ( getAccountData(getPlayerAccount(thePlayer), "Jailtime") ) then 
            local jailtime = getAccountData(getPlayerAccount(thePlayer), "Jailtime" ) 
            if tonumber(jailtime)) > 0 then 
                setAccountData ( getPlayerAccount(thePlayer), "Jailtime", jailtime - 1 ) 
                elseif tonumber(jailtime) == 0 then 
                    portoutjail(thePlayer) 
                    setAccountData(getPlayerAccount(targetplayer), "Jailtime", nil) 
            end 
        end 
    end 
end 
setTimer ( SetJailTime, 60000, 0 ) 

Its saying attempted to compare number with nil

I made a jail system and I can jail the player if he has a wanted level. But now I want to every 60 sec to take -1 from the accountdata and if its allready 0 then teleport the player out of the jail.

Posted
Replace this
if tonumber(jailtime)) > 0 then 

with this

if tonumber(jailtime) >= 1 then 

Still saying trying to compare number with nil

Posted
Then the player's account does not have "Jailtime" data set on.

Are you alive in this world? Do you even know how to script? :lol::lol:

Don't you see his (if) statement, line 3? If it is set to something, it will go on. Just that you can't notice, don't help pls.

Posted
Then the player's account does not have "Jailtime" data set on.

Are you alive in this world? Do you even know how to script? :lol::lol:

Don't you see his (if) statement, line 3? If it is set to something, it will go on. Just that you can't notice, don't help pls.

omg .... Its not the hole script only a part of it... look at the rest and you will undestand it

Posted
Oh thanks for telling me dude. May I know what "attempted to compare number with nil" means?

please look at the hole script, I know what it mean but Idk why it isnt working

Posted
  
function SetJailTime() 
    for theKey,thePlayer in ipairs(getElementsByType ( "player" )) do 
        local acc = getPlayerAccount( thePlayer ) 
  
        if not isGuestAccount( acc ) and tonumber( getAccountData(getPlayerAccount(thePlayer), "Jailtime") ) then 
            local jailtime = getAccountData(getPlayerAccount(thePlayer), "Jailtime" ) 
            if tonumber(jailtime) > 0 then 
                setAccountData ( getPlayerAccount(thePlayer), "Jailtime", jailtime - 1 ) 
            elseif tonumber(jailtime) == 0 then 
                portoutjail(thePlayer) 
                setAccountData(getPlayerAccount(targetplayer), "Jailtime", nil) 
            end 
        end 
    end 
end 
setTimer ( SetJailTime, 60000, 0 ) 
  

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