Jump to content

weapon Bug


Desaster

Recommended Posts

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 :P thnx

Link to comment

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

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...