11.05.2018, 22:40
Hey, So I have this weird bug where if someone kills id 0 it won't show it in the deathlog and the kills and deaths won't increase but when the player relogs with the same id it gets fixed somehow. The server doesn't detect if id 0 has been killed it shows as if he suicided but when he relogs it gets fixed.
OnPlayerDeath
Also I guess this is caused by the skinhit system.
Also I know I made this topic before but this isn't the same topic I fixed most of the stuff myself from the old topic but I can't fix this. This just seems weird.
OnPlayerDeath
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
new string[128], killername[MAX_PLAYER_NAME];
GetPlayerName(lasthit[playerid], killername, MAX_PLAYER_NAME);
if(killstreak[playerid] >= 3)
{
format(string,sizeof(string), "~ %s has ended %s's killstreak", killername, GetName(playerid));
SendClientMessageToAll(COLOR_ORANGE, string);
SetPlayerColor(playerid, COLOR_WHITE);
}
killstreak[playerid] = 0;
HandleKS(killerid);
ResetPlayerWeapons(playerid);
GameTextForPlayer(playerid,"~r~~h~WASTED",8000,1);
if(PlayerInfo[killerid][pDonator] == 1)
{
GivePlayerCash(killerid, 200);
}
else {
GivePlayerCash(killerid, 100);
}
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
GivePlayerCash(killerid, 100);
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
SaveAccountStats(playerid);
if(lasthit[playerid] == INVALID_PLAYER_ID)
{
SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
return 1;
}
if(lasthit[playerid] != INVALID_PLAYER_ID)
{
format(string, sizeof(string), "* %s[%d] has been killed by %s.", GetName(playerid),playerid, killername);
SendDeathMessage(lasthit[playerid],playerid,GetPlayerWeapon(lasthit[playerid]));
SendClientMessageToAll(COLOR_WHITE, string);
return 1;
}
lasthit[playerid] = INVALID_PLAYER_ID;
return 1;
}
PHP код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if(damagedid != INVALID_PLAYER_ID)
{
new Float:armour; GetPlayerArmour(damagedid,armour);
if(armour < 1)
{
new Float:health; GetPlayerHealth(damagedid, health);
SetPlayerHealth(damagedid,health-amount);
lasthit[damagedid] = playerid;
return 1;
}
if(armour > 0)
{
if(armour < amount)
{
new Float:health; GetPlayerHealth(damagedid, health);
new Float:value = amount-armour;
SetPlayerArmour(damagedid,0);
SetPlayerHealth(damagedid,health-value);
lasthit[damagedid] = playerid;
return 1;
}
if(armour > amount)
{
SetPlayerArmour(damagedid,armour-amount);
lasthit[damagedid] = playerid;
return 1;
}
return 1;
}
return 1;
}
return 1;
}