Jump to content

ammo


Xwad

Recommended Posts

I made it but it does not work:/

  
function giveAmmo ( thePlayer, theVehicle, theTeam )if (getElementModel(source) == 433) then  giveWeapon ( source, 31, 200 ) 
endaddEventHandler ( "onPlayerVehiclenter", getRootElement(), giveAmmo )  
  

Link to comment
Make sure that player have the skin ID#433, or try this for test:
  
function giveAmmo(thePlayer, theVehicle, theTeam) 
   giveWeapon(source, 31, 200) 
end 
addEventHandler("onPlayerVehiclenter", getRootElement(), giveAmmo) 
  

Do you even know what you're going to do? Your code will give a weapon to a vehicle which makes no sense...

Link to comment

the event is "onPlayerVehicleEnter" not "onPlayerVehiclenter"

and source of this event is the player

function giveAmmo ( theVehicle, seat ) 
    if (getElementModel(theVehicle) == 433) then   
    giveWeapon ( source, 31, 200 ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), giveAmmo )  

---

Make sure that player have the skin ID#433, or try this for test:
  
function giveAmmo(thePlayer, theVehicle, theTeam) 
   giveWeapon(source, 31, 200) 
end 
addEventHandler("onPlayerVehiclenter", getRootElement(), giveAmmo) 
  

Do you even know what you're going to do? Your code will give a weapon to a vehicle which makes no sense...

you are worng because the source of this event is the player not the vehicle

the just one thing was worng the name of the event

Link to comment

ALw7sH it's working thanks:D But i want to make that it will only give the guns if i already have them. I mean if i have ak47 then i will get only ak47 but if i have only grenade then i will only get grenade. Is is possible to make that? or is it very difficult? thanks.

Link to comment

try to use getPedWeapons()

function getPedWeapons(ped) 
    local playerWeapons = {} 
    if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then 
        for i=2,9 do 
            local wep = getPedWeapon(ped,i) 
            if wep and wep ~= 0 then 
                table.insert(playerWeapons,wep) 
            end 
        end 
    else 
        return false 
    end 
    return playerWeapons 
end 

Link to comment

this but its noot good i tryed to make it but i can't this is too high level for me..:(

  
function giveAmmo ( theVehicle, seat ) 
    if (getElementModel(theVehicle) == 433) then   
    giveWeapon ( source, localWeapon, 200 ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), giveAmmo ) 
  

Link to comment
Make sure that player have the skin ID#433, or try this for test:
  
function giveAmmo(thePlayer, theVehicle, theTeam) 
   giveWeapon(source, 31, 200) 
end 
addEventHandler("onPlayerVehiclenter", getRootElement(), giveAmmo) 
  

Do you even know what you're going to do? Your code will give a weapon to a vehicle which makes no sense...

Sorry i guess Wiki is wrong that it says source of this event is the player entering vehicle.

this but its noot good i tryed to make it but i can't this is too high level for me..:(
  
function giveAmmo ( theVehicle, seat ) 
    if (getElementModel(theVehicle) == 433) then   
    giveWeapon ( source, localWeapon, 200 ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), giveAmmo ) 
  

Have you tried it without vehicle check? maybe that check is returning false?
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...