Jump to content

Math help


ViRuZGamiing

Recommended Posts

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

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