OnPlayerGive/TakeDamage causes crashes on the server
#1

So I have this two callbacks OnPlayerGive/TakeDamage which causes the server to crash on linux (but not on Windows, tested it with NPC)

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {
        
ShotPlayer[issuerid][playerid] = gettime();
        
LastShot[playerid] = gettime();
    }
    if(
PlayerInfo[playerid][pJustLogged] == 0)
    {
        new 
Float:HP;
        new 
Float:Armor;
        
GetPlayerHealth(playeridHP);
        
GetPlayerArmour(playeridArmor);
        if(
Armor 1)
        {
            if(
weaponid == 31 || weaponid == 30)
            {
                
SetPlayerHealth(playeridHP-(amount*3));
            }
            else if(
weaponid == 22)
            {
                
SetPlayerHealth(playeridHP-20);
            }
            else if(
weaponid == 34)
            {
                
SetPlayerHealth(playeridHP-50);
            }
            else if(
weaponid == 8)
            {
                
SetPlayerHealth(playeridHP-30);
            }
            else if(
weaponid == 5)
            {
                
SetPlayerHealth(playeridHP-20);
                new 
hitrand random(10);
                if(
hitrand <= 5)
                {
                    
SendClientMessageEx(playeridCOLOR_GRAD2"  You have been knocked to the floor by a baseball bat.");
                    
ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,0,0,0,0);
                }
            }
            else if(
weaponid == 3)
            {
                
SetPlayerHealth(playeridHP-20);
                new 
hitrand random(10);
                if(
hitrand <= 5)
                {
                    
SendClientMessageEx(playeridCOLOR_GRAD2"  You have been knocked to the floor by an ASP Baton.");
                    
ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,0,0,0,0);
                }
            }
            else if(
weaponid == 15 || weaponid == || weaponid == || weaponid == || weaponid == 7)
            {
                
SetPlayerHealth(playeridHP-20);
            }
            else
            {
                if(
weaponid != 26)
                {
                    
SetPlayerHealth(playeridHP-(amount*1.5));
                }
            }
        }
        if(
Armor >= 1)
        {
            if(
weaponid == 34)
            {
                
SetPlayerArmour(playeridArmor-50);
            }
            if(
Armor >= 30)
            {
                if(
weaponid == 8)
                {
                    
SetPlayerArmour(playeridArmor-30);
                }
            }
            if(
Armor >= 20)
            {
                if(
weaponid == || weaponid == 15 || weaponid == || weaponid == || weaponid == || weaponid == || weaponid == 7)
                {
                    
SetPlayerArmour(playeridArmor-20);
                }
            }
        }
    }
    return 
1;
}
public 
OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart)
{
    new
        
string[128]
    ;
    
//print("Callback OPGD is called.");
    
if(pTazer[playerid] == 1)
    {
         if(
TazerTimeout[playerid] > 0)
          {
            return 
1;
        }
        new 
Float:XFloat:YFloat:Z;
        
GetPlayerPos(damagedidXYZ);
        if(
PlayerCuffed[damagedid] == && GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT)
        {
            
format(stringsizeof(string), "* %s gets hit by %s's tazer shot, stunning them."GetPlayerNameEx(damagedid), GetPlayerNameEx(playerid));
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
GameTextForPlayer(damagedid"~r~Tazed"35003);
            
TogglePlayerControllable(damagedid0);
            
ApplyAnimation(damagedid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
            
PlayerPlaySound(damagedid1085XYZ);
            
PlayerPlaySound(playerid1085XYZ);
            
PlayerCuffed[damagedid] = 1;
            
SetPVarInt(damagedid"PlayerCuffed"1);
            
PlayerCuffedTime[damagedid] = 16;
            
SetPVarInt(damagedid"IsFrozen"1);
            
//Frozen[i] = 1;
            
TazerTimeout[playerid] = 4;
            
SetTimerEx("TazerTimer",1000,false,"d",playerid);
            
GameTextForPlayer(playerid"~n~~n~~n~~n~~n~~n~~n~~n~~r~Tazer reloading... ~w~5"1500,3);
        }
    }
    return 
1;

CrashDetector Logs;

Код:
OnPlayerGiveDamage

[08:37:27] [debug] Server crashed while executing rgrp.amx
[08:37:27] [debug] AMX backtrace:
[08:37:27] [debug] #0 00000014 in public OnPlayerGiveDamage (1, 0, 1111018701, 24, 3) from rgrp.amx

OnPlayerTakeDamage

[09:19:41] [debug] Server crashed while executing rgrp.amx
[09:19:41] [debug] AMX backtrace:
[09:19:41] [debug] #0 00000014 in public OnPlayerTakeDamage (1, 65535, 1084122727, 54, 3) from rgrp.amx
Strangely I have attempted to check the crash by myself by calling the OnPlayerTakeDamage but it doesn't crashes at all until it was done by other players (I don't think ID: 0 crashes the server with these callback but I will do some plenty of checking)
Reply
#2

PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart

    new 
        
string[128
    ; 
    
//print("Callback OPGD is called."); 
    
if(pTazer[playerid] == 1
    { 
        if(
TazerTimeout[playerid] > 0)  return 1
        new 
Float:XFloat:YFloat:Z
        
GetPlayerPos(damagedidXYZ); 
        if(
PlayerCuffed[damagedid] == && GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT
        { 
            
format(stringsizeof(string), "* %s gets hit by %s's tazer shot, stunning them."GetPlayerNameEx(damagedid), GetPlayerNameEx(playerid)); 
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
            
GameTextForPlayer(damagedid"~r~Tazed"35003); 
            
TogglePlayerControllable(damagedid0); 
            
ApplyAnimation(damagedid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1); 
            
PlayerPlaySound(damagedid1085XYZ); 
            
PlayerPlaySound(playerid1085XYZ); 
            
PlayerCuffed[damagedid] = 1
            
SetPVarInt(damagedid"PlayerCuffed"1); 
            
PlayerCuffedTime[damagedid] = 16
            
SetPVarInt(damagedid"IsFrozen"1); 
            
//Frozen[i] = 1; 
            
TazerTimeout[playerid] = 4
            
SetTimerEx("TazerTimer",1000,false,"d",playerid); 
            
GameTextForPlayer(playerid"~n~~n~~n~~n~~n~~n~~n~~n~~r~Tazer reloading... ~w~5"1500,3); 
        } 
    } 
Reply
#3

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart

    if(
issuerid != INVALID_PLAYER_ID
    { 
        
ShotPlayer[issuerid][playerid] = gettime(); 
        
LastShot[playerid] = gettime(); 
    } 
    if(
PlayerInfo[playerid][pJustLogged] == 0
    { 
        new 
Float:HP
        new 
Float:Armor
        
GetPlayerHealth(playeridHP); 
        
GetPlayerArmour(playeridArmor); 
        if(
Armor 1
        { 
            if(
weaponid == 31 || weaponid == 30
            { 
                
SetPlayerHealth(playeridHP-(amount*3)); 
            } 
            else if(
weaponid == 22
            { 
                
SetPlayerHealth(playeridHP-20); 
            } 
            else if(
weaponid == 34
            { 
                
SetPlayerHealth(playeridHP-50); 
            } 
            else if(
weaponid == 8
            { 
                
SetPlayerHealth(playeridHP-30); 
            } 
            else if(
weaponid == 5
            { 
                
SetPlayerHealth(playeridHP-20); 
                new 
hitrand random(10); 
                if(
hitrand <= 5
                { 
                    
SendClientMessageEx(playeridCOLOR_GRAD2"  You have been knocked to the floor by a baseball bat."); 
                    
ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,0,0,0,0); 
                } 
            } 
            else if(
weaponid == 3
            { 
                
SetPlayerHealth(playeridHP-20); 
                new 
hitrand random(10); 
                if(
hitrand <= 5
                { 
                    
SendClientMessageEx(playeridCOLOR_GRAD2"  You have been knocked to the floor by an ASP Baton."); 
                    
ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,0,0,0,0); 
                } 
            } 
            else if(
weaponid == 15 || weaponid == || weaponid == || weaponid == || weaponid == 7
            { 
                
SetPlayerHealth(playeridHP-20); 
            } 
            else 
            { 
                if(
weaponid != 26
                { 
                    
SetPlayerHealth(playeridHP-(amount*1.5)); 
                } 
            } 
        } 
        if(
Armor >= 1
        { 
            if(
weaponid == 34
            { 
                
SetPlayerArmour(playeridArmor-50); 
            } 
        }
        if(
Armor >= 30
        { 
                if(
weaponid == 8
                { 
                    
SetPlayerArmour(playeridArmor-30); 
                } 
        } 
        if(
Armor >= 20
        { 
                if(
weaponid == || weaponid == 15 || weaponid == || weaponid == || weaponid == || weaponid == || weaponid == 7
                { 
                    
SetPlayerArmour(playeridArmor-20); 
                } 
          } 
       } 
    } 
    return 
1

Reply
#4

is that the full crash log? if not mind posting the full one here?
also try re compling script with debug 3 so it will list the line it crashed on it in the log so you could fix it easily.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)