how can i store the last killer in a variable
#1

hey the title says it all.

pawn Код:
if(dSpree[playerid] == 1)
        {
        killerid = pKiller;
        revenge[playerid] = true;
        SendClientMessage(playerid, COLOR_HOTORANGE, "You have died enough. Use /revenge to kill your last killer.");
        }
i want to know how can i store who was playerid killer into a variable so i can use it. As in the attempt above ^.

Actually this is a prototype of what i am trying to create right below

pawn Код:
CMD:revenge(playerid, params[])
{
    new playaname[2][MAX_PLAYER_NAME];
    if(!IsPlayerConnected(pKiller)) return SendClientMessage(playerid, COLOR_RED, "Your victim is not connected.");
    if(revenge[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "You haven't died enough to have your revenge.");
    else
    {
        new Float:x, Float:y, Float:z;
        new Float:a, Float:b, Float:c;
        GetPlayerPos(playerid, x, y, z);
        SetPlayerPos(pKiller, x+10, y+10, z);
        GetPlayerPos(pKiller, a, b, c);
        CreateExplosion(a, b, c, 1, 9.0);
        GetPlayerName(playerid, playaname[0], MAX_PLAYER_NAME);
        GetPlayerName(pKiller, playaname[1], MAX_PLAYER_NAME);
        format(szMessage, sizeof(szMessage), "[%d]%s has unleashed his dying spree and eliminated [%d]%s satisfying their lust for blood.", playerid, playaname[1], pKiller, playaname[1]);
        SendClientMessageToAll(COLOR_HOTORANGE, szMessage);
        revenge[playerid] = false;
        dSpree[playerid] = 0;
       
    }
    return 1;
}
Reply
#2

1.) You need to save the id of the killer of player killed in a variable.
pawn Код:
Example. MyKiller[playerid] = killerid;
2.) You don't want to use IsPlayerConnected() instead what you want to do is check when a player logs out if they are in another players MyKiller variable.
Example.
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(!IsPlayerConnected(i)) continue;
    if(MyKiller[i] == i) MyKiller[i] = INVALID_PLAYER_ID;

}
3.) Check for a revenge kill on death
pawn Код:
if(MyKiller[killerid] == playerid)
I hope that helps.
Reply
#3

Didn't test it out yet, as i didnt have the chance to get someone online to help me test, but just to make sure, this is what you mean right?

pawn Код:
/* OnPlayerConnect */
    foreach(Player, i)
    {
    if(!IsPlayerConnected(i)) continue;
    if(pKiller[i] == i) pKiller[i] = INVALID_PLAYER_ID;
    }
    return 1;

/*  OnPlayerDeath(playerid) */
{
        if(dSpree[playerid] == 1 && pKiller[playerid] == playerid)
        {
        killerid = pKiller[playerid];
        revenge[playerid] = true;
        SendClientMessage(playerid, COLOR_HOTORANGE, "You have died enough. Use /revenge to kill your last killer.");
        }
}

/* /revenge cmd... */
Reply
#4

Well you want to do you foreach() loop in OnPlayerDisconnect() actually also you don't if(!IsPlayerConnected(i)) when using foreach. Also this assignment is incorrect.

pawn Код:
killerid = pKiller[playerid];

//should be
pKiller[playerid] = killerid;
But it also looks like your revenge system is not what I expected so you might have to explain a bit more.
Reply
#5

ok, i fixed everything you pointed out. Basically its a death spree, when the variable dSpree increments up to a determined value which for example 3, the player with the death spree can, or is supposed to kill the last killer which caused his 3rd death.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)