Jacobob14 Posted June 3, 2014 Posted June 3, 2014 Hello I have a gun shop and I wonder if it is possible that when the player dies do not miss the weapon buy until you run out of ammunition function Pistol() if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney(source,500) giveWeapon(source,22, 100,true) outputChatBox ( "Gracias por tu compra : Pistol ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Pistol", true) addEventHandler("Pistol", root, Pistol) function Deagle() if ( getPlayerMoney(source) >= 800 ) then takePlayerMoney(source,800) giveWeapon(source,24, 50,true) outputChatBox ( "Gracias por tu compra : Deagle ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Deagle", true) addEventHandler("Deagle", root, Deagle)
Castillo Posted June 3, 2014 Posted June 3, 2014 @Jacobob: You want the player to keep the weapons he/she has after he/she dies?
Booo Posted June 3, 2014 Posted June 3, 2014 Hello I have a gun shopand I wonder if it is possible that when the player dies do not miss the weapon buy until you run out of ammunition function Pistol() if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney(source,500) giveWeapon(source,22, 100,true) outputChatBox ( "Gracias por tu compra : Pistol ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Pistol", true) addEventHandler("Pistol", root, Pistol) function Deagle() if ( getPlayerMoney(source) >= 800 ) then takePlayerMoney(source,800) giveWeapon(source,24, 50,true) outputChatBox ( "Gracias por tu compra : Deagle ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Deagle", true) addEventHandler("Deagle", root, Deagle) try this bro if work tell me ! function Pistol() if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney(source,500) giveWeapon(source,22, 100,true) outputChatBox ( "Gracias por tu compra : Pistol ", source, 255, 255, 255, true) if getElementData(source,"BooWeap") then table.insert(getElementData(source,"BooWeap"),22,100) else setElementData(source,"BoooWeap",{["22"]=100}) end else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Pistol", true) addEventHandler("Pistol", root, Pistol) function Deagle() if ( getPlayerMoney(source) >= 800 ) then takePlayerMoney(source,800) giveWeapon(source,24, 50,true) outputChatBox ( "Gracias por tu compra : Deagle ", source, 255, 255, 255, true) if getElementData(source,"BooWeap") then table.insert(getElementData(source,"BooWeap"),24,50) else setElementData(source,"BoooWeap",{["24"]=50}) end else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Deagle", true) addEventHandler("Deagle", root, Deagle) addEventHandler( "onPlayerWasted", getRootElement( ), function() setElementData(source,"BooWeap",{}) for i=1,12,1 do if getPedWeapon (source,i) then table.insert(getElementData(source,"BooWeap"),getPedWeapon (source,i),getPedTotalAmmo (source,i)) end end end ) addEventHandler( "onPlayerSpawn", getRootElement( ), function() if getElementData(source,"BooWeap") then for k,v in pairs(getElementData(source,"BooWeap")) do giveWeapon(source, tonumber(k), tonumber(v), true) end end end )
Max+ Posted June 3, 2014 Posted June 3, 2014 Hello I have a gun shopand I wonder if it is possible that when the player dies do not miss the weapon buy until you run out of ammunition function Pistol() if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney(source,500) giveWeapon(source,22, 100,true) outputChatBox ( "Gracias por tu compra : Pistol ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Pistol", true) addEventHandler("Pistol", root, Pistol) function Deagle() if ( getPlayerMoney(source) >= 800 ) then takePlayerMoney(source,800) giveWeapon(source,24, 50,true) outputChatBox ( "Gracias por tu compra : Deagle ", source, 255, 255, 255, true) else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Deagle", true) addEventHandler("Deagle", root, Deagle) try this bro if work tell me ! function Pistol() if ( getPlayerMoney(source) >= 500 ) then takePlayerMoney(source,500) giveWeapon(source,22, 100,true) outputChatBox ( "Gracias por tu compra : Pistol ", source, 255, 255, 255, true) if getElementData(source,"BooWeap") then table.insert(getElementData(source,"BooWeap"),22,100) else setElementData(source,"BoooWeap",{["22"]=100}) end else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Pistol", true) addEventHandler("Pistol", root, Pistol) function Deagle() if ( getPlayerMoney(source) >= 800 ) then takePlayerMoney(source,800) giveWeapon(source,24, 50,true) outputChatBox ( "Gracias por tu compra : Deagle ", source, 255, 255, 255, true) if getElementData(source,"BooWeap") then table.insert(getElementData(source,"BooWeap"),24,50) else setElementData(source,"BoooWeap",{["24"]=50}) end else outputChatBox("Error 5674: Dinero Insuficiente", source, 250,230,0) end end addEvent("Deagle", true) addEventHandler("Deagle", root, Deagle) addEventHandler( "onPlayerWasted", getRootElement( ), function() setElementData(source,"BooWeap",{}) for i=1,12,1 do if getPedWeapon (source,i) then table.insert(getElementData(source,"BooWeap"),getPedWeapon (source,i),getPedTotalAmmo (source,i)) end end end ) addEventHandler( "onPlayerSpawn", getRootElement( ), function() if getElementData(source,"BooWeap") then for k,v in pairs(getElementData(source,"BooWeap")) do giveWeapon(source, tonumber(k), tonumber(v), true) end end end ) He want the player who buy weapons save his weapons , if there is ammo left in them if not , he lose his weapons , Your Code, give him the same weapons with Extra Ammo , ?
Jacobob14 Posted June 3, 2014 Author Posted June 3, 2014 as I can make it just the ammunition he had left ;( ?
Max+ Posted June 3, 2014 Posted June 3, 2014 You Can Use This , --By Solidsnake14 local playerWeapons = { } addEventHandler ( "onPlayerWasted", root, function ( ) if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( playerWeapons [ source ] ) then for weapon, ammo in pairs ( playerWeapons [ source ] ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end playerWeapons [ source ] = nil end )
Max+ Posted June 3, 2014 Posted June 3, 2014 Make lua file name it server.lua and then put the codes into the file , and meta , and give your self a weapon then kill your self and you will get the same weapon with the same ammo on the next spawn .
Jacobob14 Posted June 3, 2014 Author Posted June 3, 2014 but I just want you to buy weapons in the shop
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