opnaiC Posted August 15, 2016 Share Posted August 15, 2016 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. Link to comment
Gravestone Posted August 15, 2016 Share Posted August 15, 2016 Replace this if tonumber(jailtime)) > 0 then with this if tonumber(jailtime) >= 1 then Link to comment
opnaiC Posted August 15, 2016 Author Share Posted August 15, 2016 Replace this if tonumber(jailtime)) > 0 then with this if tonumber(jailtime) >= 1 then Still saying trying to compare number with nil Link to comment
Gravestone Posted August 15, 2016 Share Posted August 15, 2016 Then the player's account does not have "Jailtime" data set on. Link to comment
Anubhav Posted August 15, 2016 Share Posted August 15, 2016 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? 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. Link to comment
opnaiC Posted August 15, 2016 Author Share Posted August 15, 2016 (edited) с Edited August 15, 2016 by Guest Link to comment
Gravestone Posted August 15, 2016 Share Posted August 15, 2016 (edited) May I know what "attempted to compare number with nil" means? Edited August 15, 2016 by Guest Link to comment
opnaiC Posted August 15, 2016 Author Share Posted August 15, 2016 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? 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 Link to comment
opnaiC Posted August 15, 2016 Author Share Posted August 15, 2016 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 Link to comment
Anubhav Posted August 15, 2016 Share Posted August 15, 2016 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 ) 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