OnPlayerDeath
#1

Hello All..
I need little help when i kill someone ( You killed "NAME" ) when they kill me ( You got killed by "NAME" )

+REP
Reply
#2

add this to onplayerdeath

pawn Код:
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
new name1[MAX_PLAYER_NAME+1];
GetPlayerName(killerid, name1, sizeof(name1));
new string[128];
format(string,sizeof(string),"You got killed by %s",name1);
SendClientMessage(playerid,color,string);
format(string,sizeof(string),"You killed %s",name);
SendClientMessage(killerid,color,string);
Reply
#3

Don't say you're gonna +REP, it makes a lot of noobs reply with the wrong answer.


UNTESTED
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[100];
    format(string, 100, "You've been killed by %s", GetName(killerid));
    SendClientMessage(playerid, -1, string);
    format(string, 100, "You killed %s", GetName(playerid));
    SendClientMessage(killerid, -1, string);
    return 1;
}
IF YOU DONT HAVE GETNAME
pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#4

Get the players and killers name and put it inside a string.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == playerid) return 1; // They either fell, or took self-inflicted damage somehow.
new string[256];
format(string, sizeof(string), "You have killed %s.", GetName(playerid));
SendClientMessage(killerid, -1, string);
format(string, sizeof(string), "You have been killed by %s." GetName(killerid));
SendClientMessage(killerid, -1, string);
return 1;
}
Reply
#5

you can also use this
https://sampforum.blast.hk/showthread.php?pid=3025454#pid3025454
it's more better ^^
Reply
#6

#Abagail:
pawn Код:
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1350) : error 017: undefined symbol "GetName"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1352) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1352) : error 017: undefined symbol "GetName"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1352) : error 029: invalid expression, assumed zero
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1352) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
Reply
#7

Must've missed the comma by accident. Also, I've provided the GetName stock below:
pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}

public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == playerid) return 1; // They either fell, or took self-inflicted damage somehow.
new string[256];
format(string, sizeof(string), "You have killed %s.", GetName(playerid));
SendClientMessage(killerid, -1, string);
format(string, sizeof(string), "You have been killed by %s.", GetName(killerid));
SendClientMessage(killerid, -1, string);
return 1;
}
Reply
#8

pawn Код:
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1366) : error 021: symbol already defined: "SetPlayerVirtualWorld"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1369) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1378) : error 021: symbol already defined: "TextDrawShowForPlayer"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1383) : error 021: symbol already defined: "TextDrawHideForPlayer"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1391) : error 021: symbol already defined: "TextDrawHideForPlayer"
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1395) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1400) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1402) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1406) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1407) : error 010: invalid function or declaration
C:\Users\Khan_vb\Desktop\Server.UFS\XRS\gamemodes\XSE.pwn(1412) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


11 Errors.
Reply
#9

pawn Код:
//==============================================================================
//OnPlayerDeath
//==============================================================================
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == playerid) return 1; // They either fell, or took self-inflicted damage somehow.
new string[256];
format(string, sizeof(string), "You have killed %s.", GetName(playerid));
SendClientMessage(killerid, -1, string);
format(string, sizeof(string), "You have been killed by %s.", GetName(killerid));
SendClientMessage(killerid, -1, string);
return 1;
}

stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
    //--------------------------------------------------------------------------
    //Settings & Others
    //--------------------------------------------------------------------------
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerWantedLevel(playerid, 0);
    SendDeathMessage(killerid, playerid, reason);
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
    }
    GivePlayerMoney(killerid, 100);
    GivePlayerMoney(playerid, 0);
    //--------------------------------------------------------------------------
    //Textdraw's Hide/Show
    //--------------------------------------------------------------------------
    TextDrawShowForPlayer(playerid, Textdraw27);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //TextDrawHideForPlayer(playerid, Textdraw0);
    //TextDrawHideForPlayer(playerid, Textdraw4);
    //TextDrawHideForPlayer(playerid, Textdraw5);
    TextDrawHideForPlayer(playerid, Textdraw6);
    TextDrawHideForPlayer(playerid, Textdraw7);
    TextDrawHideForPlayer(playerid, Textdraw8);
    TextDrawHideForPlayer(playerid, Textdraw81);
    TextDrawHideForPlayer(playerid, Textdraw82);
    TextDrawHideForPlayer(playerid, Textdraw83);
    TextDrawHideForPlayer(playerid, Textdraw84);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    TextDrawHideForPlayer(playerid, TeleTD1);
    TextDrawHideForPlayer(playerid, TeleTD2);
    TextDrawHideForPlayer(playerid, TeleTD3);
Reply
#10

Moved the GetName thing, and the return and closing brace were in the wrong spot. Also the second SendClientMessage was wrong, string too large. Fixed it.

pawn Код:
//==============================================================================
//OnPlayerDeath
//==============================================================================
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == playerid) return 1; // They either fell, or took self-inflicted damage somehow.
new string[75];
format(string, sizeof(string), "You have killed %s.", GetName(playerid));
SendClientMessage(killerid, -1, string);
format(string, sizeof(string), "You have been killed by %s.", GetName(killerid));
SendClientMessage(playerid, -1, string);

    //--------------------------------------------------------------------------
    //Settings & Others
    //--------------------------------------------------------------------------
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerWantedLevel(playerid, 0);
    SendDeathMessage(killerid, playerid, reason);
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
    }
    GivePlayerMoney(killerid, 100);
    GivePlayerMoney(playerid, 0);
    //--------------------------------------------------------------------------
    //Textdraw's Hide/Show
    //--------------------------------------------------------------------------
    TextDrawShowForPlayer(playerid, Textdraw27);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //TextDrawHideForPlayer(playerid, Textdraw0);
    //TextDrawHideForPlayer(playerid, Textdraw4);
    //TextDrawHideForPlayer(playerid, Textdraw5);
    TextDrawHideForPlayer(playerid, Textdraw6);
    TextDrawHideForPlayer(playerid, Textdraw7);
    TextDrawHideForPlayer(playerid, Textdraw8);
    TextDrawHideForPlayer(playerid, Textdraw81);
    TextDrawHideForPlayer(playerid, Textdraw82);
    TextDrawHideForPlayer(playerid, Textdraw83);
    TextDrawHideForPlayer(playerid, Textdraw84);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    TextDrawHideForPlayer(playerid, TeleTD1);
    TextDrawHideForPlayer(playerid, TeleTD2);
    TextDrawHideForPlayer(playerid, TeleTD3);
        return 1;
}
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)