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 . Failure is simply an opportunity to begin again more intelligently - Henry Ford
Anubhav Posted September 11, 2014 Posted September 11, 2014 Are you sure you have set the account data? See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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 . Failure is simply an opportunity to begin again more intelligently - Henry Ford
Anubhav Posted September 11, 2014 Posted September 11, 2014 So check if the value exist by a if statment. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
SkatCh Posted September 11, 2014 Author Posted September 11, 2014 ?? i don't undrestand. Failure is simply an opportunity to begin again more intelligently - Henry Ford
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 ); See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
darhal Posted September 12, 2014 Posted September 12, 2014 Edit !!!!!!!! [LUA] if weapon0 >= 0 then -- some code [\LUA] #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
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