Desaster Posted December 16, 2013 Share Posted December 16, 2013 hi I saved the wepon id's and weapon ammo's in a SQL table but the problem each reconnect the player get + 50% of the weapons he had any idea why ? ps: I used this func on login giveWeapon Link to comment
PaiN^ Posted December 16, 2013 Share Posted December 16, 2013 Where's the code ? We can't figure out what's wrong without it. Link to comment
Desaster Posted December 17, 2013 Author Share Posted December 17, 2013 well I located the error in the ammunation shop and idk why everytime the player login he get double ammo well here is my function server: addEvent ("wepShop", true) addEventHandler ("wepShop", getRootElement(), function(name, id, ammo, cost) if not id then return end if (getPlayerMoney (source) >= tonumber(cost)) then exports["TopBarChat"]:sendClientMessage ( "You bought a " .. name.." for $"..cost,source,0,255,0,TopBar, 5 ) takePlayerMoney (source, tonumber(cost)) local account = getPlayerAccount ( source ) setAccountData( account,"GunsMoney",tonumber( getAccountData( account,"GunsMoney" ) or 0 ) + tonumber(cost) ) giveWeapon ( source, id, ammo ) else exports["TopBarChat"]:sendClientMessage ( "You can't afford to buy this!",source,255,0,0,TopBar, 5 ) end end) hmm the client side isn't needed but it has a function with onClientGUIClick that triggers this event triggerServerEvent ("wepShop2", getLocalPlayer(), wepName2, wepID2, wepCost2) ps: id / name / cost are defined thnx Link to comment
xXMADEXx Posted December 17, 2013 Share Posted December 17, 2013 so can't you just use "*2" in the giveWeapon function like this: local ammo = tonumber ( getAccountData ( getPlayerAccount ( player ), "weaponAmmo" ) ) if ( ammo ) then giveWeapon ( player, 5, ammo*2 ) end Link to comment
Desaster Posted December 17, 2013 Author Share Posted December 17, 2013 that's not what I mean . I mean when any player login the ammunation resource give him *2 ammo as he had before idk why it's a bug Link to comment
PaiN^ Posted December 17, 2013 Share Posted December 17, 2013 Try this : addEvent( "wepShop", true ) addEventHandler( "wepShop", root, function( name, id, ammo, cost ) if not id then return end if getPlayerMoney( source ) >= tonumber( cost ) then exports["TopBarChat"]:sendClientMessage( "You bought a " .. name .. " for $" .. cost, source, 0, 255, 0, TopBar, 5 ) takePlayerMoney( source, tonumber( cost ) ) local account = getPlayerAccount( source ) if not isGuesAccount( account ) then setAccountData( account, "GunsMoney", tonumber( getAccountData( account,"GunsMoney" ) ) or 0 + tonumber( cost ) ) end giveWeapon( source, id, ammo ) else exports["TopBarChat"]:sendClientMessage( "You can't afford to buy this!", source, 255, 0, 0, TopBar, 5 ) end end ) 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