How do I do this
#1

Hey guys!

Okay, I've been trying out stuff in some time now, I can't find the solution. (I have searched on forum / wiki too..)
Here's what I want.
I've made /kill commando, simple using SetPlayerHealth. I want it to make a string saying "%s has commited suciside!" when the /kill sets the healt to 0 on OnPlayerDeath, so I define this:
pawn Код:
new OnPlayerKill[MAX_PLAYERS];
and puts this on my kill:
pawn Код:
OnPlayerKill[playerid] = 1;
Okay, I now go up to my OnPlayerDeath, and makes these lines:
pawn Код:
if OnPlayerKill[playerid] == 1
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has committed suicide.", pName);
    SendClientMessageToAll(COLOR_GREY, string);
    }
Note: I know I just can add it to /kill, but that's not what I want. Because of spam!


Okay, but I get this error:
pawn Код:
(376) : error 029: invalid expression, assumed zero
Line 376 is the { after my if.
I've tried to change the { directions, but I can't find how to make it work.

[k]My whole OnPlayerDeath public, if you think there's something with that?[/k]
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    {
    OnPlayerDeathSpawn[playerid] = 1;
    SendDeathMessage(killerid,playerid,reason);
    }
    if OnPlayerKill[playerid] == 1
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has committed suicide.", pName);
    SendClientMessageToAll(COLOR_GREY, string);
    }
    return 1;
}
Thanks!
/JaloNik
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    {
    OnPlayerDeathSpawn[playerid] = 1;
    SendDeathMessage(killerid,playerid,reason);
    }
    if (OnPlayerKill[playerid] == 1)
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has committed suicide.", pName);
    SendClientMessageToAll(COLOR_GREY, string);
    }
    return 1;
}
Reply
#3

You always have to put the if-statement in brackets in pawn:

if (OnPlayerKill[playerid] == 1)


Edit: Oops, late post
Reply
#4

Quote:
Originally Posted by Kar
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    {
    OnPlayerDeathSpawn[playerid] = 1;
    SendDeathMessage(killerid,playerid,reason);
    }
    if (OnPlayerKill[playerid] == 1)
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has committed suicide.", pName);
    SendClientMessageToAll(COLOR_GREY, string);
    }
    return 1;
}
This made it, thanks! I can see what I did wrong now.
Reply
#5

No problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)