OnPlayerTakeDamage Help
#2

Take a look at my OnPlayerTakeDamage, and see if you can salvage any information out of it.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new
            Float:armour,
            Float:health,
            Float:P[3]
        ;
           
        GetPlayerArmour(playerid, armour);
        GetPlayerHealth(playerid, health);
           
        if(armour != 0) //Armor?
        {  
            switch(weaponid)
            {
                case 0: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-3); } //Fists
                case 1: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Brass Knuckles
                case 2: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-7); } //Golf Club
                case 3: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Nite Stick
                case 4: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-10); } //Knife
                case 5: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-9); } //Baseball Bat
                case 6: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-9); } //Shovel
                case 7: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-6); } //Pool Cue
                case 8: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-12); } //Katana
                case 9: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-25); } //Chainsaw (When the hell is this going to be used?)
               
                                                        /* Dildos & Flowers, Don't need to edit these... */
                //case 10..14: {    SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-6); }
                                                                        /* Continue.. */
                                                                       
                case 15: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Cane
                case 16: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-75); } //Grenade
                //case 17: {        SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-15); } //Tear gas (How the hell do you get hurt by one of these?)
                case 18: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-45); } //Molotov Cocktail
                case 22: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-13); } //Colt 45 (9mm)
                case 23:
                {
                    if(UsingTazer[issuerid] == 1) //They were being tazed!
                    {
                        UsingTazer[issuerid] = -1;
                        expAmmo[issuerid] = -1;
                        BeingTazed[playerid] = 1;
                        FreezePlayer(playerid, 1);

                        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); //Apply it twice so it works
                        SetTimerEx("Unfreeze", 5000, false, "i", playerid); //5 second taze
                       
                        SetPlayerHealth(playerid, health-1.0);
                       
                        UserInfo[issuerid][TazerDarts]--;

                        SendClientMessage(playerid, COLOR_SUCCESSFUL, "* You have been shot with a Tazer!");
                        SendClientMessage(issuerid, COLOR_SUCCESSFUL, "* You have hit them with a tazer. You have switched back to standard rounds!");
                    }
                    else { SetPlayerHealth(playerid, health+amount);        SetPlayerHealth(playerid, health-12); } //Silenced Pistol
                }
                case 24:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-45);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 1500, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-35);  } //Not using Explosive Ammo!
                }
                case 25:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-65);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-25);  } //Not using Explosive Ammo!
                }
                case 26: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-23); } //Sawn-off Shotgun
                case 27: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-20); } //SPAS 12 (Auto shotgun does LESS damage!)
                case 28: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-7); } //Uzi
                case 29: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-12); } //MP5
                case 30: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-15); } //AK47
                case 31: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-14); } //M4A1
                case 32: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-8); } //Tec9
                case 33:
                {              
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-45);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-25);  } //Not using Explosive Ammo!
                }
                case 34:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-75);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-50);  } //Not using Explosive Ammo!
                }
                case 35:
                {
                    if(random(300) == 35) //Random chance to survive it because they have armor..
                    {      
                        SetPlayerHealth(playerid, 5);      
                        SendClientMessage(playerid, COLOR_SUCCESSFUL, "* Somehow you survive!");
                        return 1;
                    }
                    else {
                        return      SetPlayerHealth(playerid, 0);
                    }
                }
               
            }
        }
        else //no armor
        {
            switch(weaponid)
            {
                case 0: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-3); } //Fists
                case 1: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Brass Knuckles
                case 2: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-7); } //Golf Club
                case 3: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Nite Stick
                case 4: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-10); } //Knife
                case 5: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-9); } //Baseball Bat
                case 6: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-9); } //Shovel
                case 7: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-6); } //Pool Cue
                case 8: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-12); } //Katana
                case 9: {           SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-25); } //Chainsaw (When the hell is this going to be used?)
               
                                                        /* Dildos & Flowers, Don't need to edit these... */
                //case 10..14: {    SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-6); }
                                                                        /* Continue.. */
                                                                       
                case 15: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-5); } //Cane
                case 16: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-75); } //Grenade
                //case 17: {        SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-15); } //Tear gas (How the hell do you get hurt by one of these?)
                case 18: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-45); } //Molotov Cocktail
                case 22: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-13); } //Colt 45 (9mm)
                case 23:
                {
                    if(UsingTazer[issuerid] == 1) //They were being tazed!
                    {
                        UsingTazer[issuerid] = -1;
                        expAmmo[issuerid] = -1;
                        BeingTazed[playerid] = 1;
                        FreezePlayer(playerid, 1);

                        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                        ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); //Apply it twice so it works!
                        SetTimerEx("Unfreeze", 5000, false, "i", playerid); //5 second taze
                       
                        SetPlayerHealth(playerid, health-1.0);
                       
                        UserInfo[issuerid][TazerDarts]--;

                        SendClientMessage(playerid, COLOR_SUCCESSFUL, "* You have been shot with a Tazer!");
                        SendClientMessage(issuerid, COLOR_SUCCESSFUL, "* You have hit them with a tazer. You have switched back to standard rounds!");
                    }
                    else { SetPlayerHealth(playerid, health+amount);        SetPlayerHealth(playerid, health-12); } //Silenced Pistol
                }
                case 24:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-60);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 1500, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-35);  } //Not using Explosive Ammo!
                }
                case 25:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-49);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-45);  } //Not using Explosive Ammo!
                }
                case 26: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-40); } //Sawn-off Shotgun
                case 27: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-37); } //SPAS 12 (Auto shotgun does LESS damage!)
                case 28: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-13); } //Uzi
                case 29: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-16); } //MP5
                case 30: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-20); } //AK47
                case 31: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-17); } //M4A1
                case 32: {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-14); } //Tec9
                case 33:
                {              
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-67);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-55);  } //Not using Explosive Ammo!
                }
                case 34:
                {
                    if(expAmmo[issuerid] == 1) { //Are they using Explosive Ammunition?
                               
                        GetPlayerPos(playerid, P[0], P[1], P[2]);
                       
                        SetPlayerHealth(playerid, health+amount);
                        SetPlayerHealth(playerid, health-92);

                        expParticle[playerid] = CreateObject(18686, P[0], P[1], P[2], 0, 0, 0, 30); //Explosion particle!
                        SetTimerEx("DestroyObjectP", 350, 0, "i", playerid);
                       
                        //UserInfo[issuerid][ExplosiveAmmo]--;
                        if(UserInfo[issuerid][ExplosiveAmmo] <= 0) { expAmmo[issuerid] = -1;    SendClientMessage(issuerid, COLOR_ERROR, "* You have ran out of Incendiary rounds, and have been switched back to Standard rounds!"); }
                    }
                    else {          SetPlayerHealth(playerid, health+amount);       SetPlayerHealth(playerid, health-75);  } //Not using Explosive Ammo!
                }
                case 35:
                {
                    return      SetPlayerHealth(playerid, 0);
                }
               
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
OnPlayerTakeDamage Help - by Mac-10 - 27.01.2012, 03:42
Re: OnPlayerTakeDamage Help - by 2KY - 27.01.2012, 04:09
Re: OnPlayerTakeDamage Help - by Mac-10 - 28.01.2012, 01:29
Re: OnPlayerTakeDamage Help - by MP2 - 28.01.2012, 01:54
Re: OnPlayerTakeDamage Help - by jamesbond007 - 28.01.2012, 01:54
Re: OnPlayerTakeDamage Help - by Mac-10 - 28.01.2012, 02:10
Re: OnPlayerTakeDamage Help - by MP2 - 28.01.2012, 02:16
Re: OnPlayerTakeDamage Help - by Mac-10 - 29.01.2012, 06:42
Re: OnPlayerTakeDamage Help - by Mac-10 - 12.02.2012, 07:00
Re: OnPlayerTakeDamage Help - by KingHual - 12.02.2012, 08:39

Forum Jump:


Users browsing this thread: 1 Guest(s)