ViRuZGamiing Posted December 21, 2014 Share Posted December 21, 2014 Hi guys, I need some help the point is, when I shot and I hit it's 1 hit dead, if dead then give the bullet back. Example: 1 bullet, gets the kill, still 1 bullet 2nd Example: 1 bullet, miss the kill, 0 bullets 3th Example: 0 Bullets, knifes, 1 bullet Code: function spawnHandler () takeAllWeapons (source) giveWeapon(source, 22, 1, true) giveWeapon(source, 4, 1) end addEventHandler("onPlayerSpawn", getRootElement(), spawnHandler) function deadHandler (ammo, attacker, weapon, bodypart) if (attacker == false) then outputChatBox(tostring(getPlayerName(source)).." commited suicide!") elseif (attacker == true) then outputChatBox(tostring(getPlayerName(attacker)).." killed "..tostring(getPlayerName(source)).."!") giveWeapon(attacker, 22, 1, true) wSlot = getSlotFromWeapon (weapon) tAmmo = getPedTotalAmmo (attacker, wSlot) tAmmo = tAmmo + 1 takeWeapon(attacker, 22) giveWeapon(attacker, 22, tAmmo, true) if ( bodypart == 9 ) then if ( weapon == 22 ) then outputChatBox("HEADSHOT!") elseif (weapon == 4) then outputChatBox("KNIFE KILL!") end end end end addEventHandler ("onPlayerWasted", getRootElement(), deadHandler ) function oneHit ( attacker, weapon ) if ( weapon == 22 or 4) then if (getElementType(attacker) == "player") then killPed (source) end end end addEventHandler ( "onPlayerDamage", getRootElement (), oneHit ) Link to comment
Jaydan Posted December 21, 2014 Share Posted December 21, 2014 I think I get what you're saying You would need to use https://wiki.multitheftauto.com/wiki/OnClientWeaponFire to find the element which was hit, if it was hit then use setWeaponAmmo To give them the bullet back. Link to comment
ViRuZGamiing Posted December 21, 2014 Author Share Posted December 21, 2014 Look at the code, I have it all, the problem is it's not giving the correct amount of ammo Link to comment
pa3ck Posted December 21, 2014 Share Posted December 21, 2014 giveWeapon(attacker, 22, 1, true) -- here wSlot = getSlotFromWeapon (weapon) tAmmo = getPedTotalAmmo (attacker, wSlot) tAmmo = tAmmo + 1 takeWeapon(attacker, 22) giveWeapon(attacker, 22, tAmmo, true) Why do you give the player a weapon with 1 bullet? Link to comment
ViRuZGamiing Posted December 21, 2014 Author Share Posted December 21, 2014 Because of the ammo is 1 and you shoot, you lose your gun. Now it gives you a gun. Link to comment
ViRuZGamiing Posted December 22, 2014 Author Share Posted December 22, 2014 ammo represents the victims ammo, didn't read that. thought killer ammo. Probably fixed. Link to comment
.:HyPeX:. Posted December 22, 2014 Share Posted December 22, 2014 By the way, its one in the chamber. Chamber == bullter mag. Link to comment
ViRuZGamiing Posted December 22, 2014 Author Share Posted December 22, 2014 Oh, lol.. thanks 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