Custom death reasons [Rep+]
#1

Introduction
So i'm trying to figure out these death reasons for my gamemode.
But it doesn't display anything neither i get any errors / warnings on pawno.


pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   PInfo[playerid][Deaths]++;
   PInfo[killerid][Kills]++;
   
    new weapname[50];
    new string[128];
    GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));
   
    switch (reason)
    {
        case 49:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~hit by a vehicle.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
        case 50:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~Heli-bladed.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
        case 51:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~died in explosion.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
        case 53:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~drowned.", GetPName(playerid));
            TextDrawSetString(Killpopup1, string);
        }
        case 54:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~fell to death.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
        default:
        {
            format(string, sizeof(string), "~r~%s~w~ has died.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
    }
    return 1;
}
That's the code, the problem is it doesn't show anything when i die.
EDIT: Forgot to add this https://sampwiki.blast.hk/wiki/Weapons
I used cases from there.
Reply
#2

Put it Top of under OnPlayerDeath

pawn Код:
SendDeathMessage(playerid, killerid, reason);
Reply
#3

You misunderstood me, i don't want it to show the icons on the right side of the screen under the health bar.
I want it to show in chat i used the number reasons as case.

Besides this doesnt work.
Reply
#4

Try this

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   PInfo[playerid][Deaths]++;
   PInfo[killerid][Kills]++;

    new weapname[50];
    new string[128];
    GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));

    switch (reason)
    {
        case 49:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~hit by a vehicle.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
        case 50:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~Heli-bladed.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
        case 51:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~died in explosion.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
        case 53:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~drowned.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
        case 54:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~fell to death.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
        default:
        {
            format(string, sizeof(string), "~r~%s~w~ has died.", GetPName(playerid));
            GameTextForAll(string, 3000, 3);
        }
    }
    return 1;
}
Reply
#5

Nope. Doesn't work.
Reply
#6

Bump.

Can somebody help me solve this?
Reply
#7

debug....
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   PInfo[playerid][Deaths]++;
   PInfo[killerid][Kills]++;
   
    new weapname[50];
    new string[128];
    GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));

    printf("id %d has entered Onplayerdeath",playerid);//this prints to the console if player got killed

    switch (reason)
    {
        case 49:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~hit by a vehicle.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
            printf("%d death reason: vehicle",playerid);//this prints to the console if player get killed by vehicle
        }
        case 50:
        {
            format(string, sizeof(string), "~r~%s~w~ got ~r~Heli-bladed.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
            print("case 50");
        }
        case 51:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~died in explosion.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
            print("case 51");
        }
        case 53:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~drowned.", GetPName(playerid));
            TextDrawSetString(Killpopup1, string);
            print("case 53");
        }
        case 54:
        {
            format(string, sizeof(string), "~r~%s~w~ has ~r~fell to death.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
        default:
        {
            print("player died without reason");
            format(string, sizeof(string), "~r~%s~w~ has died.", GetPName(playerid));
            SendClientMessageToAll(COL_RED, string);
        }
    }
    print("onplayerdeath done");
    return 1;
}
EDIT: post it in no time
Reply
#8

That's weird, i added that line but it didn't print anything out ...
Reply
#9

Quote:
Originally Posted by BamGuitar
Посмотреть сообщение
That's weird, i added that line but it didn't print anything out ...
i cant find anything wrong with ur code.

have u tried to kill someone?yourself? in the game?


pawn Код:
cmd:kill(playerid,params[])
{
SetPlayerHealth(playerid,0.0);
return 1;
}
//if u use this command the console will print "player died without reason"
Reply
#10

Ye, i tried to format a random message under player death and nothing, it's like it doesn't even read OnPlayerDeath
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)