• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

getResets tfs 1.2

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi folks!

I'm trying create a reset system for TFS 1.2 and I'm getting a problem with the function getResets check it below and also the error.

Code:
function getResets(cid)
   local player = Player(cid)
   resets = player:getStorageValue(378378)
   
   if resets < 0 then
     resets = 0
   end
   
   return resets
end

To check how many resets the player has I'm currently using this getResets(cid) and to add a reset getResets(cid) + 1

EkaVSu.png


Thanks.
 
Player is nil.
You should check for nil.

Like this?

Code:
function getResets(cid)
    local player = Player(cid)
   
    if player == nil then
        return true
    end
   
    resets = player:getStorageValue(378378)   
    if resets < 0 then
        resets = 0
    end
   
    return resets
end
 
Like this?

Code:
function getResets(cid)
    local player = Player(cid)
  
    if player == nil then
        return true
    end
  
    resets = player:getStorageValue(378378)  
    if resets < 0 then
        resets = 0
    end
  
    return resets
end
Code:
function getResets(cid)
    local player = Player(cid)
  
    if player == nil then
        return 0
    end
  
    resets = player:getStorageValue(378378)   
    if resets < 0 then
        resets = 0
    end
  
    return resets
end
 
Back
Top