Problem: /kill cmd player on kill list
#1

I want when somebody writes /kill its kills him and it shows on kill list that he commited suicide... Now when i write /kill its kills the player but doenst show on list.
pawn Code:
if(strcmp(cmd, "/kill", true) == 0)
        {
        new killname[MAX_PLAYERS];
        GetPlayerName(playerid,killname,sizeof (killname));
        format(killname, sizeof killname, "%s has commited suicide.",killname);
        SendClientMessageToAll(0xA52A2AAA,killname);
        SetPlayerHealth(playerid,0.0);
        }
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid==INVALID_PLAYER_ID)
    {
    SendDeathMessage(INVALID_PLAYER_ID, playerid, 47);
    }
return 1;
}
Reply
#2

Try this instead of that :-

pawn Code:
SendDeathMessage(killerid, playerid, reason);
Also have a look at https://sampwiki.blast.hk/wiki/SendDeathMessage
Reply
#3

either try it like this (that won't kill the player but respawn)
pawn Code:
if(strcmp(cmd, "/kill", true) == 0)
        {
        new killname[MAX_PLAYERS];
        GetPlayerName(playerid,killname,sizeof (killname));
        format(killname, sizeof killname, "%s has commited suicide.",killname);
        SendClientMessageToAll(0xA52A2AAA,killname);
        TogglePlayerSpectating(playerid, 0);
        }
or like this:
pawn Code:
new killed[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    killed[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid==INVALID_PLAYER_ID && killed[playerid] == 0)
    {
        SendDeathMessage(INVALID_PLAYER_ID, playerid, 47);
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/kill", true))
    {
        new killname[MAX_PLAYERS];
        GetPlayerName(playerid,killname,sizeof (killname));
        format(killname, sizeof killname, "%s has commited suicide.",killname);
        SendClientMessageToAll(0xA52A2AAA,killname);
        killed[playerid] = 1;
        SetPlayerHealth(playerid,0.0);
        return 1;
    }
    return 0;
}
Reply
#4

Quote:
Originally Posted by Davz*|*Criss
View Post
Try this instead of that :-

pawn Code:
SendDeathMessage(killerid, playerid, reason);
Also have a look at https://sampwiki.blast.hk/wiki/SendDeathMessage
this actualy make more sense... but still doesnt work, SendDeathMessage doesnt show..

and Sascha, i did what you said, except that it read only "killed" variable when somebody died, to test if there was a problem in INVALID_PLAYER_ID

EDITED:
I made a test:
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid==INVALID_PLAYER_ID)
    {
    SendClientMessage(playerid,red,"rofl");
    SendDeathMessage(INVALID_PLAYER_ID, playerid, 47);
    }
return 1;
}
When you die, "rofl" doesnt appear in chat..
Reply
#5

Use this under OnPlayerCommandText:

pawn Code:
if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        new string[128];
        new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername));
        format(string, sizeof(string),"*%s (%d) Has Committed Suicide.",playername,playerid);
        SendClientMessageToAll(COLOR_RED,string);
        SetPlayerHealth(playerid,0);
        return 1;
    }
Under OnPlayerDeath:

pawn Code:
SendDeathMessage(killerid,playerid,reason);
Reply
#6

Seriusly, how is this different than my code? you just added "playerid" on SendClientMessageToAll
Forget the /kill cmd.. its fine.. im just asking why
pawn Code:
SendDeathMessage(killerid,playerid,reason);
doesnt show up?
Reply
#7

Maybe one of your ' if ' statements are interfering with it or something else in your script or another loaded filterscript.

And I put the /kill here command I have and it works perfectly, so just trying to help..
Reply
#8

yep there is something wrong with my GM.. i tryed that in other GM and it worked..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)