Two death message [HELP] +REP
#1

so i use this code that it will tell all player if someone was killed by the other player..

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new gunname[32],string[145],fName[MAX_PLAYER_NAME],sName[MAX_PLAYER_NAME];
    GetWeaponName(reason,gunname,sizeof gunname);
    GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
    GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has been killed by %s with %s",fName,sName,gunname);
    SendClientMessageToAll(COLOR_RED,string);
    GameTextForPlayer(playerid, "~r~Wasted", 5000, 6);
    SendDeathMessage(killerid, playerid, reason);
}
and i tested it..but when i died by jumping off the cliff.. the message appear :%s has been killed by %s with

how to make it when i died by jumping off the cliff or drowing not by killed by other player.. the message appeared Example: Player 1 died... HELP ME!
Reply
#2

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new gunname[32],string[145],fName[MAX_PLAYER_NAME],sName[MAX_PLAYER_NAME];
    GetWeaponName(reason,gunname,sizeof gunname);
    GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
    GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has been killed by %s with %s",fName,sName,gunname);
    SendClientMessageToAll(COLOR_RED,string);
    GameTextForPlayer(playerid, "~r~Wasted", 5000, 6);
    SendDeathMessage(killerid, playerid, reason);

    new msg[128]
    if (killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
            case 1: format(msg, sizeof(msg), "Player %s died. (Drowned)", playerName);
            case 2: format(msg, sizeof(msg), "Player %s died. (Collision)", playerName);
            default: format(msg, sizeof(msg), "Player %s died.", playerName);
        }
        SendClientMessageToAll(-1, msg);
    }
    return 1;
}
Reply
#3

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
fName[MAX_PLAYER_NAME],string[256];
    
GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
    if(
amount >= 100 )
    {
        
format(string,sizeof string,"%s has been died",fName);
        
SendClientMessageToAll(-1,string);
    }
    return 
1;

Reply
#4

GAMEMODE.pwn(477) : error 001: expected token: ";", but found "if"
GAMEMODE.pwn(481) : error 017: undefined symbol "playerName"
GAMEMODE.pwn(482) : error 017: undefined symbol "playerName"
GAMEMODE.pwn(483) : error 017: undefined symbol "PlayerName"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase[/code]

HELP!
Reply
#5

expected token: ";"
Forgot a semicolon.
pawn Code:
new msg[128]
if (killerid != INVALID_PLAYER_ID)
Should be
pawn Code:
new msg[128];
if (killerid != INVALID_PLAYER_ID)
Reply
#6

Quote:
Originally Posted by CalvinC
View Post
expected token: ";"
Forgot a semicolon.
pawn Code:
new msg[128]
if (killerid != INVALID_PLAYER_ID)
Should be
pawn Code:
new msg[128];
if (killerid != INVALID_PLAYER_ID)
now this:

Code:
D:\Barang2\samp_server\gamemodes\GAMEMODE.pwn(488) : error 017: undefined symbol "playerName"
D:\Barang2\samp_server\gamemodes\GAMEMODE.pwn(489) : error 017: undefined symbol "playerName"
D:\Barang2\samp_server\gamemodes\GAMEMODE.pwn(490) : error 017: undefined symbol "playerName"
Reply
#7

Hybris' code can be simplified to this:

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[145], fName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,fName,MAX_PLAYER_NAME);

    if (killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
            case 1: format(string, sizeof(string), "Player %s died. (Drowned)", fName);
            case 2: format(string, sizeof(string), "Player %s died. (Collision)", fName);
            default: format(string, sizeof(string), "Player %s died.", fName);
        }

    } else {
        new sName[MAX_PLAYER_NAME], gunname[32];
        GetWeaponName(reason,gunname,sizeof gunname);
        GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
        format(string,sizeof string,"%s has been killed by %s with %s",fName,sName,gunname);
    }

    SendClientMessageToAll(COLOR_RED,string);
    GameTextForPlayer(playerid, "~r~Wasted", 5000, 6);
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)