Xwad Posted April 14, 2015 Author Share Posted April 14, 2015 But it's working. the local weapon is not working. I mean that it will give only the weapon I already have. Link to comment
ALw7sH Posted April 14, 2015 Share Posted April 14, 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. Idont know if this is exactly what you want function giveAmmo ( theVehicle, seat ) if (getElementModel(theVehicle) == 433) then local weapon = getPedWeapon (source) if weapon then giveWeapon ( source, weapon, 200 ) end end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), giveAmmo ) Link to comment
Xwad Posted April 14, 2015 Author Share Posted April 14, 2015 yeah its working thanks:D Link to comment
Maurize Posted April 16, 2015 Share Posted April 16, 2015 addEventHandler( "onPlayerVehiclenter", getRootElement(), function( vehicle, seat, jacked ) if ( ( getElementModel( vehicle ) == 433 ) and ( getPedWeapon( source, 5 ) == 31 ) ) then outputChatBox( "Yeah, Ammo", source, 255, 255, 0 ); giveWeapon( source, 31, 200 ); end end ) Link to comment
Xwad Posted April 16, 2015 Author Share Posted April 16, 2015 how can i set for each weapon the ammo when i get in the vehicle? becaouse i want to make that if i have ak47 and rpg and enter the vehicle then i will get 200 ammo for ak47 but for rpg only 2. how can i make that? thanks. Link to comment
Maurize Posted April 16, 2015 Share Posted April 16, 2015 addEventHandler( "onPlayerVehicleEnter", getRootElement(), function( vehicle, seat, jacked ) if ( getElementModel( vehicle ) == 433 ) then if ( getPedWeapon( source ) == 31 ) then --if m4 giveWeapon( source, 31, 200 ); -- give m4 and 200 ammo elseif ( getPedWeapon( source ) == 30 ) then --if ak47 giveWeapon( source, 30, 300 ); -- then give weapon ak47 and 300 ammo elseif ( getPedWeapon( source ) == 35 ) then -- if rpg giveWeapon( source, 35, 2 ); -- then give weapon 35 and 2 ammo -- and so on how you like it. end outputChatBox( "Yeah, Ammo", source, 255, 255, 0 ); end end ) this script is for easy understand ... you can find all weapon ids here -> https://wiki.multitheftauto.com/wiki/Weapons Link to comment
Xwad Posted April 17, 2015 Author Share Posted April 17, 2015 i only get ammo for the m4:( Link to comment
Ryancit2 Posted April 17, 2015 Share Posted April 17, 2015 Try this: addEventHandler("onPlayerVehicleEnter", getRootElement(), function(vehicle, seat, jacked) if (getElementModel(vehicle) == 433) then local wep = getPedWeapon(source) or 0 if (wep == 0 or wep == 1 or wep == 10 or wep == 11 or wep == 12) then -- If its a melee. outputChatBox("You can not have weapon ammo for "..getWeaponNameFromID(wep), source, 200, 0, 0) return end if tonumber(wep) then giveWeapon(source, wep, 200) end outputChatBox("You have been given 200 ammo for "..getWeaponNameFromID(wep), source, 255, 255, 0) end end) Link to comment
Xwad Posted April 18, 2015 Author Share Posted April 18, 2015 its working but the problem is that i get 200 ammo for coket laucher becaous eits local weapon and i will get for all weapon 200 ammo if i enter How can i fix that? Link to comment
Xwad Posted April 18, 2015 Author Share Posted April 18, 2015 or wait!! What functions need i use to make a script that makes possible to set the max ammo that a player can carry for the weapons?? Link to comment
Ryancit2 Posted April 18, 2015 Share Posted April 18, 2015 Make use of tables like this: maxAmmo = { ["m4"] = 5000, ["mp5"] = 9000 } -- And use like this: if ammo >= maxAmmo[wep] then setWeaponAmmo(player, wep, maxAmmo[wep]) end -- server sided. Link to comment
Xwad Posted April 18, 2015 Author Share Posted April 18, 2015 is it server sided ?becaouse its not working i got 200 ammo:/ But it dosent metter im not patient anymore.. thanks for helping:) maxAmmo = { ["m4"] = 200, ["mp5"] = 128, ["grenade"] = 5, ["colt45"] = 30, ["silenced"] = 24, ["deagle"] = 24, ["shotgun"] = 30, ["uzi"] = 120, ["ak47"] = 200, ["rifle"] = 30, ["sniper"] = 30, ["rocketlaucher"] = 4, ["heatseeker"] = 4, ["moltov"] = 5 } -- And use like this: if ammo >= maxAmmo[wep] then setWeaponAmmo(player, wep, maxAmmo[wep]) end -- server sided. Link to comment
Ryancit2 Posted April 19, 2015 Share Posted April 19, 2015 Make table like that and add checks when giving ammo like this: maxAmmo = { ["m4"] = 200, ["mp5"] = 128, ["grenade"] = 5, ["colt45"] = 30, ["silenced"] = 24, ["deagle"] = 24, ["shotgun"] = 30, ["uzi"] = 120, ["ak47"] = 200, ["rifle"] = 30, ["sniper"] = 30, ["rocketlaucher"] = 4, ["heatseeker"] = 4, ["moltov"] = 5 } function giveAmmo(player, wep, ammo) if (not tonumber(ammo)) or (not tonumber(wep)) or (not player) then return end local current = getPedTotalAmmo(player, wep) if current >= (maxAmmo[wep] or 4) then setWeaponAmmo(player, wep, maxAmmo[wep]) return end -- If player have more than max ammo then it will set ammo to max. local new = setWeaponAmmo(player, wep, (maxAmmo[wep] or 4)) end -- And then call this function in other events by giveAmmo(playerToGive, wep, ammo) and it will give maxx ammo to player. 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