OnPlayerTakeDamage [+REP]
#1

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    
PlayerShotPlayer[issuerid][playerid] = 1;
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == || pInfo[issuerid][pKickBackCoin])
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31 || weaponid == 29)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.1,Float:y+0.1,Float:z+0.2);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == || pInfo[issuerid][pKickBackCoin])
        {
            if(
pInfo[issuerid][pZombieClass] == KZOM)
            {
                if(
weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31 || weaponid == 29 || weaponid == 27)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.0,Float:y+0.0,Float:z+0.0);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE)
    {
        if(
pInfo[issuerid][pZombieClass] == DSNIPE)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                if(
weaponid == 34)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 10);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == AKICK)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 27)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.3,Float:y+0.3,Float:z+0.4);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == VIPSCOUT || pInfo[issuerid][pHumanClass] == MASTER || pInfo[issuerid][pHumanClass] == BUDDY || pInfo[issuerid][pHumanClass] == HITMAN)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 34 || weaponid == 29 || weaponid == 14 || weaponid == 33 || weaponid == 30)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE)
    {
        if(
pInfo[issuerid][pZombieClass] == GZOM)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                if(
weaponid == 9)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE || TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHour] <= 2)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                
pInfo[issuerid][pXP] += 10;
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == COWBOY)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 22)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 20);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == ASSASSIN)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 8)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 100);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == PIMP)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 10)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 15);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == EXPERIENCEDSCOUT)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 34 || weaponid == 23 )
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 80);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == SCOUT || pInfo[issuerid][pHumanClass] == HEAVYSHOTGUN || pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pDamageShotgunCoin] == || pInfo[issuerid][pHumanClass] == BOXER)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
                if(
weaponid == 0)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 100);
                }
                if(
weaponid == 34)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == TECG)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 32)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == BULL)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 26)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == ELITE)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 26)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 20);
                }
                if(
weaponid == 24)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 70);
                }
                if(
weaponid == 32)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 5);
                }
                if(
weaponid == 31)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 15);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == HERSHEL)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 30);
                }
            }
        }
    }
/*    if(issuerid != INVALID_PLAYER_ID) // Spawn KIll
    {
        if(team[issuerid] == TEAM_HUMAN && team[playerid] == TEAM_ZOMBIE)
        {
            if(IsPlayerInRangeOfPoint(playerid,5,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
            {
                SetPlayerHealth(issuerid, 0);
                new Float:hp;
                new string[256];
                GetPlayerHealth(playerid, hp);
                SetPlayerHealth(playerid, hp+amount);
                GameTextForPlayer(issuerid, "~w~You are zombie because you were~n~spawn killing", 5000,3);
                format(string,sizeof(string), "%s has been set to zombie because he/she was spawn killing!",PlayerName(issuerid));
                SendClientMessageToAll(0x800000C8,string);
            }
        }
    }*/
    
return 1;

OnPlayerTakeDamageFunction


I get this in server log

PHP код:
[14:42:34] [debugRun time error 4"Array index out of bounds"
[14:42:34] [debug]  Accessing element at index 65535 past array upper bound 999
[14:42:34] [debugAMX backtrace:
[
14:42:34] [debug#0 00038794 in public OnPlayerTakeDamage (0, 65535, 1079194420, 54, 3) from zma4.amx 
Reply
#2

Check if issuerid is not INVALID_PLAYER_ID before using it in arrays.
Reply
#3

It's because you don't check if issuerid is a valid ID, therefore when you damage yourself by falling for example the issuerid is going to be 65535 instead of an id that's inside the array bounds (specified in this case MAX_PLAYERS aka 1000).
Reply
#4

But i have removed it to /* */
Reply
#5

The issuerid validation check must be on top of the callback.
Reply
#6

How to check the issuerid ?
Reply
#7

It's exactly the same as the commented part.
PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid

    if (
issuerid != INVALID_PLAYER_ID)
    {
        
// code where "issuerid" is used in arrays..
    
}
    return 
1;

Reply
#8

Wrap all your code in this check:

Код:
if(issuerid != INVALID_PLAYER_ID)
{    
      your callback code here..
}
Reply
#9

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    
PlayerShotPlayer[issuerid][playerid] = 1;
  if(
issuerid != INVALID_PLAYER_ID// Spawn KIll
  
{
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == || pInfo[issuerid][pKickBackCoin])
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31 || weaponid == 29)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.1,Float:y+0.1,Float:z+0.2);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == || pInfo[issuerid][pKickBackCoin])
        {
            if(
pInfo[issuerid][pZombieClass] == KZOM)
            {
                if(
weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31 || weaponid == 29 || weaponid == 27)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.0,Float:y+0.0,Float:z+0.0);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE)
    {
        if(
pInfo[issuerid][pZombieClass] == DSNIPE)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                if(
weaponid == 34)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 10);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == AKICK)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 27)
                {
                    new 
Float:x,Float:y,Float:z,Float:angle;
                    
GetPlayerFacingAngle(playerid,Float:angle);
                    
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
                    
SetPlayerVelocity(playerid,Float:x+0.3,Float:y+0.3,Float:z+0.4);
                    
SetPlayerFacingAngle(playerid,Float:angle);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == VIPSCOUT || pInfo[issuerid][pHumanClass] == MASTER || pInfo[issuerid][pHumanClass] == BUDDY || pInfo[issuerid][pHumanClass] == HITMAN)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 34 || weaponid == 29 || weaponid == 14 || weaponid == 33 || weaponid == 30)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE)
    {
        if(
pInfo[issuerid][pZombieClass] == GZOM)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                if(
weaponid == 9)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_ZOMBIE || TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHour] <= 2)
        {
            if(
team[playerid] == TEAM_HUMAN)
            {
                
pInfo[issuerid][pXP] += 10;
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == COWBOY)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 22)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 20);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == ASSASSIN)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 8)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 100);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == PIMP)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 10)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 15);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == EXPERIENCEDSCOUT)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 34 || weaponid == 23 )
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 80);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == SCOUT || pInfo[issuerid][pHumanClass] == HEAVYSHOTGUN || pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pDamageShotgunCoin] == || pInfo[issuerid][pHumanClass] == BOXER)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
                if(
weaponid == 0)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 100);
                }
                if(
weaponid == 34)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == TECG)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 32)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 35);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == BULL)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 26)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 40);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == ELITE)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 26)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 20);
                }
                if(
weaponid == 24)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 70);
                }
                if(
weaponid == 32)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 5);
                }
                if(
weaponid == 31)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 15);
                }
            }
        }
    }
    if(
team[issuerid] == TEAM_HUMAN)
    {
        if(
pInfo[issuerid][pHumanClass] == HERSHEL)
        {
            if(
team[playerid] == TEAM_ZOMBIE)
            {
                if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 30);
                }
            }
        }
    }
/*
        if(team[issuerid] == TEAM_HUMAN && team[playerid] == TEAM_ZOMBIE)
        {
            if(IsPlayerInRangeOfPoint(playerid,5,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
            {
                SetPlayerHealth(issuerid, 0);
                new Float:hp;
                new string[256];
                GetPlayerHealth(playerid, hp);
                SetPlayerHealth(playerid, hp+amount);
                GameTextForPlayer(issuerid, "~w~You are zombie because you were~n~spawn killing", 5000,3);
                format(string,sizeof(string), "%s has been set to zombie because he/she was spawn killing!",PlayerName(issuerid));
                SendClientMessageToAll(0x800000C8,string);
            }
        }
    }*/
    
}
    return 
1;

Like this ?
Reply
#10

Yes, thats what they meant. Give it a try.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)