Xwad Posted April 10, 2015 Posted April 10, 2015 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.
WhoAmI Posted April 10, 2015 Posted April 10, 2015 Create collshape, attach it to this vehicle. When pressing 'r' check if player is in colshape and then give him ammo.
#RooTs Posted April 10, 2015 Posted April 10, 2015 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
WhoAmI Posted April 10, 2015 Posted April 10, 2015 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
RenanPG Posted April 11, 2015 Posted April 11, 2015 https://wiki.multitheftauto.com/wiki/GivePedWeapon "This function gives the specified weapon to the specified ped. This function can't be used on players, use giveWeapon for that."
Xwad Posted April 13, 2015 Author Posted April 13, 2015 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 )
Xwad Posted April 13, 2015 Author Posted April 13, 2015 Maybe need I use onVehicleEnter event? Or need I make a trigger server event?
Ryancit2 Posted April 13, 2015 Posted April 13, 2015 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)
.:DoA:.Backflip Posted April 13, 2015 Posted April 13, 2015 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...
ALw7sH Posted April 13, 2015 Posted April 13, 2015 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
Xwad Posted April 13, 2015 Author Posted April 13, 2015 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.
Walid Posted April 13, 2015 Posted April 13, 2015 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
Xwad Posted April 13, 2015 Author Posted April 13, 2015 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 )
Ryancit2 Posted April 13, 2015 Posted April 13, 2015 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?
Ryancit2 Posted April 14, 2015 Posted April 14, 2015 Means something wrong with that check, just try without vehicle checks and see if it still doesn't gives weapon.
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