Jump to content

ammo


Xwad

Recommended Posts

Posted

Hi is it possilbe to make a script that makes possible when a player is front of a barrak vehicle and press for example r then he will get ammo for his weapon? thanks.

Posted
Create collshape, attach it to this vehicle. When pressing 'r' check if player is in colshape and then give him ammo.

you can also use function

givePedWeapon 

together with collshape

Posted
Create collshape, attach it to this vehicle. When pressing 'r' check if player is in colshape and then give him ammo.

you can also use function

givePedWeapon 

together with collshape

You mean

giveWeapon 

Posted

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 )  
  

Posted

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) 
  

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

Posted

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

Posted

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.

Posted

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 

Posted

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 ) 
  

Posted
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?

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