OnPlayerDeath gets stuck. -
ikbenremco - 26.06.2014
Hi, I've encountered a strange problem with my OnPlayerDeath, if there is player who died by a INVALID_PLAYER_ID for example if an admin does /sethp 0 0, he will spawn at 0,0,0 and be in the CJ skin..
It stopped when I removed this code under, it looks like it's crashing it somehow, if a player gets killed by a normal player with or without hit, it works fine, but if a player gets killed by a INVALID_PLAYER_ID, it bugs.
Код:
if (AcceptedHit[playerid] == killerid && CharacterData[playerid][pBounty])
{
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
new string[128];
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string),"Hitman %s has failed the contract on %s and lost $%d.", PlayerRPName(playerid), PlayerRPName(killerid), CharacterData[killerid][pBounty]/2);
SendFactionMessage(i, YELLOW, string);
}
}
format(string, sizeof(string),"You have killed a hitman and gained $%d, the contract on your head has been removed.", CharacterData[killerid][pBounty]/2);
SendClientMessage(killerid, YELLOW, string);
CharacterData[playerid][pFailedHits] ++;
//PlayerJustDied[playerid] = 1;
GiveMoney(playerid, -CharacterData[killerid][pBounty]/2);
GiveMoney(killerid, CharacterData[killerid][pBounty]/2);
AcceptedHit[playerid] = 999;
CharacterData[killerid][pBounty] = 0;
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
}
Re: OnPlayerDeath gets stuck. -
RedFusion - 26.06.2014
Try this and see what happens:
pawn Код:
if (killerid != INVALID_PLAYER_ID && AcceptedHit[playerid] == killerid && CharacterData[playerid][pBounty])
Re: OnPlayerDeath gets stuck. -
ikbenremco - 26.06.2014
The same! Tried this before!
Re: OnPlayerDeath gets stuck. -
RedFusion - 26.06.2014
Put a print after each line of code and see where it stops printing
Re: OnPlayerDeath gets stuck. -
ikbenremco - 26.06.2014
Код:
printf("OnPlayerDeath debug 1: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
if (killerid != INVALID_PLAYER_ID && AcceptedHit[playerid] == killerid && CharacterData[playerid][pBounty])
{
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
new string[128];
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string),"Hitman %s has failed the contract on %s and lost $%d.", PlayerRPName(playerid), PlayerRPName(killerid), CharacterData[killerid][pBounty]/2);
SendFactionMessage(i, YELLOW, string);
}
}
format(string, sizeof(string),"You have killed a hitman and gained $%d, the contract on your head has been removed.", CharacterData[killerid][pBounty]/2);
SendClientMessage(killerid, YELLOW, string);
CharacterData[playerid][pFailedHits] ++;
//PlayerJustDied[playerid] = 1;
GiveMoney(playerid, -CharacterData[killerid][pBounty]/2);
GiveMoney(killerid, CharacterData[killerid][pBounty]/2);
AcceptedHit[playerid] = 999;
CharacterData[killerid][pBounty] = 0;
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
}
printf("OnPlayerDeath debug 2: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
if (AcceptedHit[killerid] == playerid && killerid != INVALID_PLAYER_ID)
{
printf("OnPlayerDeath debug 3: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
new witness, Float:KilledPos[3], string[128], bounty = CharacterData[playerid][pBounty]/2;
GetPlayerPos(playerid, KilledPos[0], KilledPos[1], KilledPos[2]);
foreach (Player, i)
{
if(IsPlayerInRangeOfPoint(i, 10.0, KilledPos[0], KilledPos[1], KilledPos[2]))
{
if(i != playerid && i != killerid)
{
witness ++;
}
}
}
PlayerJustDied[playerid] = 1;
format(string, sizeof(string),"You have been critically injured by a hitman and lost $%d.", CharacterData[playerid][pBounty]/2);
SendClientMessage(playerid, YELLOW, string);
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string), "Hitman %s has successfully assassinated %s with a %s and collected $%d, %d witnesses.",PlayerRPName(killerid), PlayerRPName(playerid), WeaponName(GetPlayerWeapon(killerid)), CharacterData[playerid][pBounty]/2,witness);
SendFactionMessage(i, YELLOW, string);
}
}
GiveMoney(playerid, -bounty);
GiveMoney(killerid, bounty);
AcceptedHit[killerid] = 999;
CharacterData[playerid][pBounty] = 0;
CharacterData[killerid][pCompletedHits] ++;
}
printf("OnPlayerDeath debug 3: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
Debug;
[19:44:59] OnPlayerDeath debug 1: 0 | 65535 | 255 | 999
[19:44:59] OnPlayerDeath debug 2: 0 | 65535 | 255 | 999
[19:44:59] [death] Jihad_Warrior died 255
Re: OnPlayerDeath gets stuck. -
RedFusion - 26.06.2014
pawn Код:
if (AcceptedHit[killerid] == playerid && killerid != INVALID_PLAYER_ID)
{
new witness, Float:KilledPos[3], string[128], bounty = CharacterData[playerid][pBounty]/2;
GetPlayerPos(playerid, KilledPos[0], KilledPos[1], KilledPos[2]);
print("1");
foreach (Player, i)
{
if(IsPlayerInRangeOfPoint(i, 10.0, KilledPos[0], KilledPos[1], KilledPos[2]))
{
if(i != playerid && i != killerid)
{
witness ++;
}
}
}
print("2");
PlayerJustDied[playerid] = 1;
print("3");
format(string, sizeof(string),"You have been critically injured by a hitman and lost $%d.", CharacterData[playerid][pBounty]/2);
print("4");
SendClientMessage(playerid, YELLOW, string);
print("5");
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string), "Hitman %s has successfully assassinated %s with a %s and collected $%d, %d witnesses.",PlayerRPName(killerid), PlayerRPName(playerid), WeaponName(GetPlayerWeapon(killerid)), CharacterData[playerid][pBounty]/2,witness);
SendFactionMessage(i, YELLOW, string);
}
}
print("6");
GiveMoney(playerid, -bounty);
print("7");
GiveMoney(killerid, bounty);
print("8");
AcceptedHit[killerid] = 999;
print("9");
CharacterData[playerid][pBounty] = 0;
print("10");
CharacterData[killerid][pCompletedHits] ++;
print("11");
}
You need to go deeper, we've already come to the conclusion that this part of the code doesn't execute
Re: OnPlayerDeath gets stuck. -
ikbenremco - 26.06.2014
Code:
Код:
printf("OnPlayerDeath debug 1: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
printf("OnPlayerDeath: Debug 1");
if (killerid != INVALID_PLAYER_ID && AcceptedHit[playerid] == killerid && CharacterData[playerid][pBounty])
{
printf("OnPlayerDeath: Debug 2");
new string[128];
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string),"Hitman %s has failed the contract on %s and lost $%d.", PlayerRPName(playerid), PlayerRPName(killerid), CharacterData[killerid][pBounty]/2);
SendFactionMessage(i, YELLOW, string);
}
}
printf("OnPlayerDeath: Debug 3");
format(string, sizeof(string),"You have killed a hitman and gained $%d, the contract on your head has been removed.", CharacterData[killerid][pBounty]/2);
SendClientMessage(killerid, YELLOW, string);
CharacterData[playerid][pFailedHits] ++;
//PlayerJustDied[playerid] = 1;
printf("OnPlayerDeath: Debug 4");
GiveMoney(playerid, -CharacterData[killerid][pBounty]/2);
GiveMoney(killerid, CharacterData[killerid][pBounty]/2);
AcceptedHit[playerid] = 999;
printf("OnPlayerDeath: Debug 5");
CharacterData[killerid][pBounty] = 0;
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
printf("OnPlayerDeath: Debug 6");
}
printf("OnPlayerDeath: Debug 7");
if (AcceptedHit[killerid] == playerid && killerid != INVALID_PLAYER_ID)
{
printf("OnPlayerDeath: Debug 8");
printf("OnPlayerDeath debug 3: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
new witness, Float:KilledPos[3], string[128], bounty = CharacterData[playerid][pBounty]/2;
GetPlayerPos(playerid, KilledPos[0], KilledPos[1], KilledPos[2]);
foreach (Player, i)
{
if(IsPlayerInRangeOfPoint(i, 10.0, KilledPos[0], KilledPos[1], KilledPos[2]))
{
if(i != playerid && i != killerid)
{
witness ++;
}
}
}
printf("OnPlayerDeath: Debug 9");
PlayerJustDied[playerid] = 1;
format(string, sizeof(string),"You have been critically injured by a hitman and lost $%d.", CharacterData[playerid][pBounty]/2);
SendClientMessage(playerid, YELLOW, string);
for(new i = 1; i < MAX_FACTIONS; i++)
{
if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
{
format(string, sizeof(string), "Hitman %s has successfully assassinated %s with a %s and collected $%d, %d witnesses.",PlayerRPName(killerid), PlayerRPName(playerid), WeaponName(GetPlayerWeapon(killerid)), CharacterData[playerid][pBounty]/2,witness);
SendFactionMessage(i, YELLOW, string);
}
}
GiveMoney(playerid, -bounty);
GiveMoney(killerid, bounty);
AcceptedHit[killerid] = 999;
CharacterData[playerid][pBounty] = 0;
CharacterData[killerid][pCompletedHits] ++;
printf("OnPlayerDeath: Debug 10");
}
printf("OnPlayerDeath: Debug 11");
printf("OnPlayerDeath debug 3: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
The strangest thing is this occures when I /sethp 0 0 myself, this shouldn't be even called cuz there was no hitman involved.
Re: OnPlayerDeath gets stuck. -
RedFusion - 26.06.2014
Show me the part of your serverlog where a player dies. That's the reason i added the prints, to see the last print to know where it stops
Re: OnPlayerDeath gets stuck. -
ikbenremco - 26.06.2014
[19:56:16] OnPlayerDeath debug 1: 0 | 65535 | 255 | 999
[19:56:16] OnPlayerDeath: Debug 1
[19:56:16] OnPlayerDeath: Debug 7
[19:56:16] [death] Jihad_Warrior died 255
It crashes after the 7
Re: OnPlayerDeath gets stuck. -
RedFusion - 26.06.2014
Put in more prints after 7 to know more precisely where your code stops