Jacobob14 Posted June 3, 2014 Share 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) Link to comment
Controlled Posted June 3, 2014 Share Posted June 3, 2014 I can't understand what your asking. Link to comment
Castillo Posted June 3, 2014 Share Posted June 3, 2014 @Jacobob: You want the player to keep the weapons he/she has after he/she dies? Link to comment
Jacobob14 Posted June 3, 2014 Author Share Posted June 3, 2014 but only if buy at the store Link to comment
Booo Posted June 3, 2014 Share 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 ) Link to comment
Max+ Posted June 3, 2014 Share 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 , ? Link to comment
Jacobob14 Posted June 3, 2014 Author Share Posted June 3, 2014 as I can make it just the ammunition he had left ;( ? Link to comment
Max+ Posted June 3, 2014 Share 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 ) Link to comment
Jacobob14 Posted June 3, 2014 Author Share Posted June 3, 2014 ould you explain me how to use it please Link to comment
Max+ Posted June 3, 2014 Share 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 . Link to comment
Jacobob14 Posted June 3, 2014 Author Share Posted June 3, 2014 but I just want you to buy weapons in the shop 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