Jump to content

save problem


SkatCh

Recommended Posts

guys please i need some help here i create save system for guns but i have small problem here ,

addEventHandler ( "onPlayerSpawn", root, 
    function () 
        local theAccount = getPlayerAccount ( source ); 
  -- weapons 
        local weapon0 = getAccountData ( theAccount, "weapons.weapon0" ); 
 -- ammo 
        local ammo0 = getAccountData ( theAccount, "weapons.ammo0" );  
 -- give the weapons 
        if ( weapon0 > 0 ) then giveWeapon ( source, weapon0, ammo0 ); end ----- this line  
  
); 

the script is working fine but this weapon Fist 0 , when a new player join the server i got this error ;

attempt to compare number with boolean .

Link to comment
  
addEventHandler ( "onPlayerSpawn", root, 
    function () 
        local theAccount = getPlayerAccount ( source ); 
  -- weapons 
        local weapon0 = getAccountData ( theAccount, "weapons.weapon0" ); 
 -- ammo 
        local ammo0 = getAccountData ( theAccount, "weapons.ammo0" ); 
        if weapon0 == false or ammo0  == false then return end 
 -- give the weapons 
        if ( weapon0 > 0 ) then giveWeapon ( source, weapon0, ammo0 ); end ----- this line 
  
); 
  

Link to comment
  
addEventHandler ( "onPlayerSpawn", root, 
  
    function () 
  
        local theAccount = getPlayerAccount ( source ); 
  
  -- weapon 
if not theAccount then return end 
  
        local weapon0 = tonumber (getAccountData ( theAccount, "weapons.weapon0" ) ) or 0 
  
 -- ammo 
  
        local ammo0 = tonumber (getAccountData ( theAccount, "weapons.ammo0" ) ) or 0 
        if  not weapon0 or not ammo0  then return end[code][/code] 
  
 -- give the weapons 
  
        if ( weapon0 > 0 ) then giveWeapon ( source, weapon0, ammo0 );  
      end 
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...