OnPlayerTakeDamage Help
#1

I have tried and tried to figure this out on my own, and it just seems impossible to, but so simple at the same time. I'm having trouble adding OnPlayerTakeDamage into my Gamemode..Here is What I get after Compile...

(2601) : warning 235: public function lacks forward declaration (symbol "OnPlayerTakeDamage")
(5505) : warning 213: tag mismatch
(5507) : warning 213: tag mismatch
(26636) : warning 213: tag mismatch
(42333) : warning 213: tag mismatch
(48964) : warning 213: tag mismatch
(48977) : warning 213: tag mismatch

Here is the code OnPlayerTakeDamage..Lines 2601-2624

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
    new Float:Health,Float:Armour;
    GetPlayerHealth(playerid,Health);
    GetPlayerArmour(playerid,Armour);
        if(Health == 0)
        {
        //SendDeathMessage(issuerid,playerid,weaponid);
        }
        else if(Armour > 0)
        {
        SetPlayerArmourEx(playerid,Armour+amount);
        GetPlayerArmour(playerid,Armour);
        SetPlayerArmourEx(playerid,Armour-Weapons[weaponid][ArmourDamage]);
        } else {
        SetPlayerHealthEx(playerid,Health+amount);
        GetPlayerHealth(playerid,Health);
        SetPlayerHealthEx(playerid,Health-Weapons[weaponid][Damage]);
        }
    }
    return 1;
}
pawn Код:
Line 5505   if(Weapons[i][GetPlayerWeapon(i)] == 0)
Line 5507   Weapons[i][GetPlayerWeapon(i)]=1;
Line 26636 if(Weapons[playerid][GetPlayerWeapon(playerid)] == 0)
Line 42333 if(Weapons[playerid][weaponid] == 0)
Line 48964 Weapons[playerid][weaponid] = 1;
Line 48977 Weapons[playerid][i] = 0;
Would be much appreciated with helpful feedback..

Thanks.
Reply
#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
#3

I am not quite sure..it seems it would be simple, but honestly I don't know..
Reply
#4

Make sure you have the 0.3d includes. If you say you've already got them, you probably have multiple versions of pawno.
Reply
#5

are you sure u got the 0.3d includes?
Reply
#6

I redownloaded the includes again..That Fixed the Declaration error on OnPlayerTakeDamage, But didn't solve Tag Mismatch..How can I fix that?
Reply
#7

Show the declaration for the array (the 'new').
Reply
#8

pawn Код:
enum WeapInfo
{
WeaponID,
Damage,
WeaponName[55],
ArmourDamage
}
//new Weapons[MAX_PLAYERS][50];
new Weapons[55][WeapInfo] = {
{0,10,"Unarmed",10},
{1,20,"Brass Knuckles",15},
{2,35,"Golf Club",30},
{3,35,"Nite Stick",35},
{4,50,"Knife",45},
{5,40,"Baseball Bat",35},
{6,30,"Shovel",30},
{7,30,"Pool Cue",30},
{8,100,"Katana",90},
{9,50,"Chainsaw",44},
{10,5,"Purple Dildo",3},
{11,5,"Small White Vibrator",3},
{12,10,"Large White Vibrator",5},
{13,5,"Silver Vibrator",3},
{14,5,"Flowers",3},
{15,25,"Cane",20},
{16,100,"Grenade",90},
{17,50,"Tear Gas",20},
{18,50,"Molotov Coctail",20},
{19,0,"Invalid Weapon",0},
{20,0,"Invalid Weapon",0},
{11,0,"Invalid Weapon",0},
{22,40,"Colt 9mm",40},
{23,40,"Silenced Colt 9mm",40},
{24,25,"Desert Eagle",25},
{25,50,"Shotgun",45},
{26,50,"Sawn-off Shotgun",45},
{27,60,"Combat Shotgun",50},
{28,35,"Micro SMG",30},
{29,35,"MP5K",35},
{30,40,"AK-47",40},
{31,40,"M4",40},
{32,30,"Tec9",25},
{33,100,"Country Rifle",90},
{34,100,"Sniper Rifle",90},
{35,100,"Rocket Launcher",90},
{36,100,"HS Rocket Launcher",90},
{37,30,"Flamethrower",20},
{38,50,"Minigun",50},
{39,100,"Satchel Charge",100}, //might not be synced
{40,10,"Satchel Detonator",10}, //might not be synced
{41,10,"Spraycan",10},
{42,15,"Fire Extinguisher",15},
{43,0,"Camera",0},
{44,0,"Nightvision Goggles",0},
{45,0,"Thermal Goggles",0},
{46,100,"Thermal Goggles",100},
{47,100,"Fake Pistol",100},
{48,0,"Invalid Weapon",0},
{49,50,"Vehicle",60},
{50,200,"Heli-Blades",200},
{51,100,"Explosion",100},
{52,0,"Invalid Weapon",0},
{53,20,"Drowned",25},
{54,0,"Splat",0} // default damage on splat
};
Reply
#9

Bump..
Reply
#10

Damage and ArmourDamage in the enum should be floats

Edit: Instead of Weapons[i][GetPlayerWeapon(i)] it should be Weapons[i][one of the enums above, like WeaponID]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)