Xwad Posted April 10, 2015 Share 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. Link to comment
WhoAmI Posted April 10, 2015 Share 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. Link to comment
#RooTs Posted April 10, 2015 Share 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 Link to comment
WhoAmI Posted April 10, 2015 Share 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 Link to comment
#RooTs Posted April 10, 2015 Share Posted April 10, 2015 @WhoAmI, is not the same thing? Link to comment
RenanPG Posted April 11, 2015 Share 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." Link to comment
Xwad Posted April 13, 2015 Author Share 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 ) Link to comment
Xwad Posted April 13, 2015 Author Share Posted April 13, 2015 Maybe need I use onVehicleEnter event? Or need I make a trigger server event? Link to comment
Ryancit2 Posted April 13, 2015 Share 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) Link to comment
Xwad Posted April 13, 2015 Author Share Posted April 13, 2015 No the 433 is for vehicle model Link to comment
.:DoA:.Backflip Posted April 13, 2015 Share 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... Link to comment
ALw7sH Posted April 13, 2015 Share 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 Link to comment
Xwad Posted April 13, 2015 Author Share 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. Link to comment
Walid Posted April 13, 2015 Share 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 Link to comment
Walid Posted April 13, 2015 Share Posted April 13, 2015 is this server side? Shared function Link to comment
Xwad Posted April 13, 2015 Author Share Posted April 13, 2015 I think its not working:/ Link to comment
Xwad Posted April 13, 2015 Author Share Posted April 13, 2015 i tryed to make it but its not working Link to comment
Xwad Posted April 13, 2015 Author Share 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 ) Link to comment
Ryancit2 Posted April 13, 2015 Share 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? Link to comment
Xwad Posted April 14, 2015 Author Share Posted April 14, 2015 What do you mean with returning false? Link to comment
Ryancit2 Posted April 14, 2015 Share Posted April 14, 2015 Means something wrong with that check, just try without vehicle checks and see if it still doesn't gives weapon. 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