10.05.2018, 18:15
Hello, I'm facing some problems with the Deathmessages. When every a player kills someone it sends the message that the player has suicided while a player has killed him ( This happens 75% of the times ). It seems like it doesn't detect the killer.
SendDeathMessageEx
Also, I have some hits that my skinhit system would be causing this so here take a look the skinhit system.
Thanks to anyone who helps!
SendDeathMessageEx
PHP код:
SendDeathMessageEx(playerid, killerid, reason)
{
new string[128], killername[MAX_PLAYER_NAME], deathreason[24], modelid;
if (reason != INVALID_REASON && !IsPlayerNPC(killerid))
{
modelid = killerid != INVALID_PLAYER_ID ? GetPlayerState(killerid) == PLAYER_STATE_DRIVER ? GetVehicleModel(GetPlayerVehicleID(killerid)) : 0 : 0;
if (reason == 31)
{
switch (modelid)
{
case 447: deathreason = "Sparrow Machine Gun";
case 464: deathreason = "RC Baron Machine Gun";
case 476: deathreason = "Rustler Machine Gun";
default: deathreason = "M4";
}
}
else if (reason == 37)
{
deathreason = "Fire";
}
else if (reason == 38)
{
switch (modelid)
{
case 425: deathreason = "Hunter Machine Gun";
default: deathreason = "Minigun";
}
}
else if (reason == 50)
{
switch (modelid)
{
case 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563: deathreason = "Helicopter";
default:
{
deathreason = "Collision";
reason = 49;
}
}
}
else if (reason == 51)
{
switch (modelid)
{
case 425: deathreason = "Hunter Missile";
case 432: deathreason = "Rhino Turret";
case 520: deathreason = "Hydra Missile";
default: deathreason = "Explosion";
}
}
else
{
format(deathreason, 24, "%s", WeaponName[reason]);
}
if (killerid != INVALID_PLAYER_ID)
{
GetPlayerName(killerid, killername, MAX_PLAYER_NAME);
format(string, 128, "* %s has been killed by %s (%s).", GetName(playerid), killername, deathreason);
}
else format(string, 128, "* %s has died (%s).", GetName(playerid), deathreason);
}
else
{
format(string, 128, "* %s has died (%s).", GetName(playerid), WeaponName[sizeof(WeaponName)-1]);
}
SendClientMessageToAll(COLOR_WHITE, string);
SendDeathMessage(killerid, playerid, reason);
}
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;
}