SkatCh Posted September 11, 2014 Posted September 11, 2014 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 .
Anubhav Posted September 11, 2014 Posted September 11, 2014 Are you sure you have set the account data?
SkatCh Posted September 11, 2014 Author Posted September 11, 2014 ofc i add it all weapons working fine but simple Note ; just new members when they join i got this error .
Anubhav Posted September 11, 2014 Posted September 11, 2014 So check if the value exist by a if statment.
Anubhav Posted September 11, 2014 Posted September 11, 2014 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 );
darhal Posted September 12, 2014 Posted September 12, 2014 Fist id is 0 so u will edit this if weapom0 >= 0 then -- code end also u should set the account data of fist id 0
darhal Posted September 12, 2014 Posted September 12, 2014 Edit !!!!!!!! [LUA] if weapon0 >= 0 then -- some code [\LUA]
Saml1er Posted September 12, 2014 Posted September 12, 2014 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 );
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