#1

PHP код:
forward OnPlayerTakeDamage(playeridissueridFloatamountweaponid);
public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    new 
s[20];
    
format(s20"-Damage %.0f"amount);
    
TextDrawSetString(TakeDamage[playerid], s);
    
TextDrawShowForPlayer(playeridTakeDamage[playerid]);
    
SetTimerEx("DestruirTextoDraw"1000false"i"playerid);
        if(
pClass[issuerid][Harshal] == 1)
        {
                  if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 75);
                }
        }
    return 
1;

Server logs:

Код:
[20:59:07] [debug] Run time error 4: "Array index out of bounds"
[20:59:07] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[20:59:07] [debug] AMX backtrace:
[20:59:07] [debug] #0 001456cc in public OnPlayerTakeDamage (playerid=0, issuerid=65535, Float:amount=3.30000, weaponid=54, ... <1 argument>) at D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn:8954
[20:59:09] [debug] Run time error 4: "Array index out of bounds"
[20:59:09] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[20:59:09] [debug] AMX backtrace:
[20:59:09] [debug] #0 001456cc in public OnPlayerTakeDamage (playerid=0, issuerid=65535, Float:amount=3.30000, weaponid=54, ... <1 argument>) at D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn:8954
Reply
#2

PHP код:
if(pClass[issuerid][Harshal] == 1
Always check if issuerid is not INVALID_PLAYER_ID before using its value. Same goes for killerid under OnPlayerDeath
Reply
#3

PHP код:
    if(issuerid == INVALID_PLAYER_ID)
    {
        if(
pClass[issuerid][Harshal] == 1)
        {
                  if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 75);
                }
        }
    } 
Right?
Reply
#4

Wrong.

Quote:

check if issuerid is not INVALID_PLAYER_ID

Reply
#5

Quote:
Originally Posted by Loinal
Посмотреть сообщение
PHP код:
    if(issuerid == INVALID_PLAYER_ID)
    {
        if(
pClass[issuerid][Harshal] == 1)
        {
                  if(
weaponid == 25)
                {
                new 
Float:hp;
                
GetPlayerHealth(playerid,hp);
                
SetPlayerHealth(playeridhp 75);
                }
        }
    } 
Right?
Quote:

if(issuerid == INVALID_PLAYER_ID)

It should be issuerid != INVALID_PLAYER_ID
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)