SendDeathMessageEx -
Exhibit - 10.05.2018
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
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);
}
Also, I have some hits that my skinhit system would be causing this so here take a look the skinhit system.
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;
}
Thanks to anyone who helps!
Re: SendDeathMessageEx -
CrystalGamer - 10.05.2018
PHP код:
SendDeathMessageEx(playerid, killerid, reason)
{
new string[128], playername[MAX_PLAYER_NAME], killername[MAX_PLAYER_NAME], weaponn[24], modelid;
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
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: weaponn = "Sparrow Machine Gun";
case 464: weaponn = "RC Baron Machine Gun";
case 476: weaponn = "Rustler Machine Gun";
default: weaponn = "M4";
}
}
else if (reason == 37) {
weaponn = "Fire";
}
else if (reason == 38) {
switch (modelid) {
case 425: weaponn = "Hunter Machine Gun";
default: weaponn = "Minigun";
}
}
else if (reason == 50) {
switch (modelid) {
case 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563: weaponn = "Helicopter";
default: {
weaponn = "Collision";
reason = 49;
}
}
}
else if (reason == 51) {
switch (modelid) {
case 425: weaponn = "Hunter Missile";
case 432: weaponn = "Rhino Turret";
case 520: weaponn = "Hydra Missile";
default: weaponn = "Explosion";
}
}
else {
format(weaponn, 24, "%s", WeaponName[reason]);
}
if (killerid != INVALID_PLAYER_ID) {
GetPlayerName(killerid, killername, MAX_PLAYER_NAME);
format(string, 128, "* %s[%d] has been killed by %s[%d] (%s).", playername,playerid, killername,killerid, weaponn);
}
else format(string, 128, "* %s[%d] has died (%s).", playername,playerid, weaponn);
}
else {
format(string, 128, "* %s[%d] has died (%s).", playername,playerid, WeaponName[sizeof(WeaponName)-1]);
}
SendClientMessageToAll2(COLOR_WHITE, string);
SendDeathMessage(killerid, playerid, reason);
}
try this
Re: SendDeathMessageEx -
Exhibit - 10.05.2018
not working. anyone else?
Re: SendDeathMessageEx -
CyNiC - 11.05.2018
Why use "skin hit system"? It would not be easier to update for 0.3z(or above)?
https://sampwiki.blast.hk/wiki/Server.cfg#Lag_compensation
...
However, the following code is the cause of suicide deaths, your code is setting player health to 0:
pawn Код:
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;
}
Re: SendDeathMessageEx -
Exhibit - 11.05.2018
Anyway how I can fix this?
Maybe getting the name of the player who has done damage and when the player dies it gives the name of the player that has done the damage?
Re: SendDeathMessageEx -
Exhibit - 11.05.2018
Sorry for double posting but I just noticed that this only happens with id 0. if someone kills id 0 it gives the message that the player has suicided. I hope this will help out more