Jump to content

help its possible


Recommended Posts

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 post
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) 

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 post
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) 

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 post

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 post

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 post

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