Weapon Death?
#1

Hi, im going to create something for the death reason and kill except i want it to appear on screen so something Like Player Darkside[id] Has Killed Player Bert[id] With Weapon: M4 This is what i got..

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  new pName[MAX_PLAYER_NAME];
  new string[48];
  new plname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "Player %s has Died", pName);
  SendClientMessageToAll(0xFF0000AA, string);
  return 1;
}
Can someone please help me Thank you
Reply
#2

You can find an example here: https://sampwiki.blast.hk/wiki/GetWeaponName
Reply
#3

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Killer;
    new Dead;
    new string[128];
    new WName[128];
    new weaponid = GetPlayerWeapon(killerid);

    GetPlayerName(killerid, Killer, sizeof Killer);
    GetPlayerName(playerid, Dead, sizeof Dead);
    GetWeaponName(weaponid, WName, sizeof WName);

    format(string, sizeof string, "The player %s (ID: %d) killed player %s (ID: %d) with a %s", Killer, killerid, Dead, playerid, WName);
    SendClientMessageToAll(0xBB0000AA, string);
    return 1;
}
Or

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Killer;
    new Dead;
    new string[128];

    GetPlayerName(killerid, Killer, sizeof Killer);
    GetPlayerName(playerid, Dead, sizeof Dead);

    format(string, sizeof string, "The player %s (ID: %d) killed player %s (%d) with a %s", Killer, killerid, Dead, playerid, reason);
    SendClientMessageToAll(0xBB0000AA, string);
    return 1;
}
Warning: untested code! (This code is only a draft!):
1є - The first code, there may be a bug if the player who killed quickly change weapon after killing the other
2є - Perhaps the second submit a bug not to say the name of the weapon
Reply
#4

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by TheNooB
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Killer;
    new Dead;
    new string[128];
    new WName[128];
    new weaponid = GetPlayerWeapon(killerid);

    GetPlayerName(killerid, Killer, sizeof Killer);
    GetPlayerName(playerid, Dead, sizeof Dead);
    GetWeaponName(weaponid, WName, sizeof WName);

    format(string, sizeof string, "The player %s (ID: %d) killed player %s (ID: %d) with a %s", Killer, killerid, Dead, playerid, WName);
    SendClientMessageToAll(0xBB0000AA, string);
    return 1;
}
Or

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Killer;
    new Dead;
    new string[128];

    GetPlayerName(killerid, Killer, sizeof Killer);
    GetPlayerName(playerid, Dead, sizeof Dead);

    format(string, sizeof string, "The player %s (ID: %d) killed player %s (%d) with a %s", Killer, killerid, Dead, playerid, reason);
    SendClientMessageToAll(0xBB0000AA, string);
    return 1;
}
Warning: untested code!
Only the first one will work. But 128 is a waste of arrays, 32 is enough.
I just edit to put the possible bugs:

Quote:
Originally Posted by TheNooB
Warning: untested code! (This code is only a draft!):
1є - The first code, there may be a bug if the player who killed quickly change weapon after killing the other
2є - Perhaps the second submit a bug not to say the name of the weapon
Reply
#5

Okay Guys, thank you so much for your help!
Reply
#6

You can use GetWeaponName on reason. As reason is the weapon ID that was used to kill, if memory serves me right.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)