12.11.2016, 13:26
So I have this two callbacks OnPlayerGive/TakeDamage which causes the server to crash on linux (but not on Windows, tested it with NPC)
CrashDetector Logs;
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)
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
ShotPlayer[issuerid][playerid] = gettime();
LastShot[playerid] = gettime();
}
if(PlayerInfo[playerid][pJustLogged] == 0)
{
new Float:HP;
new Float:Armor;
GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, Armor);
if(Armor < 1)
{
if(weaponid == 31 || weaponid == 30)
{
SetPlayerHealth(playerid, HP-(amount*3));
}
else if(weaponid == 22)
{
SetPlayerHealth(playerid, HP-20);
}
else if(weaponid == 34)
{
SetPlayerHealth(playerid, HP-50);
}
else if(weaponid == 8)
{
SetPlayerHealth(playerid, HP-30);
}
else if(weaponid == 5)
{
SetPlayerHealth(playerid, HP-20);
new hitrand = random(10);
if(hitrand <= 5)
{
SendClientMessageEx(playerid, COLOR_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(playerid, HP-20);
new hitrand = random(10);
if(hitrand <= 5)
{
SendClientMessageEx(playerid, COLOR_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 == 4 || weaponid == 2 || weaponid == 6 || weaponid == 7)
{
SetPlayerHealth(playerid, HP-20);
}
else
{
if(weaponid != 26)
{
SetPlayerHealth(playerid, HP-(amount*1.5));
}
}
}
if(Armor >= 1)
{
if(weaponid == 34)
{
SetPlayerArmour(playerid, Armor-50);
}
if(Armor >= 30)
{
if(weaponid == 8)
{
SetPlayerArmour(playerid, Armor-30);
}
}
if(Armor >= 20)
{
if(weaponid == 5 || weaponid == 15 || weaponid == 3 || weaponid == 4 || weaponid == 2 || weaponid == 6 || weaponid == 7)
{
SetPlayerArmour(playerid, Armor-20);
}
}
}
}
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
new
string[128]
;
//print("Callback OPGD is called.");
if(pTazer[playerid] == 1)
{
if(TazerTimeout[playerid] > 0)
{
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(damagedid, X, Y, Z);
if(PlayerCuffed[damagedid] == 0 && GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT)
{
format(string, sizeof(string), "* %s gets hit by %s's tazer shot, stunning them.", GetPlayerNameEx(damagedid), GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(damagedid, "~r~Tazed", 3500, 3);
TogglePlayerControllable(damagedid, 0);
ApplyAnimation(damagedid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
PlayerPlaySound(damagedid, 1085, X, Y, Z);
PlayerPlaySound(playerid, 1085, X, Y, Z);
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;
}
Код:
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