SA-MP Forums Archive
How do I do this - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do I do this (/showthread.php?tid=158656)



[SOLVED] How do I do this - [DK]JaloNik - 10.07.2010

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


Re: How do I do this - Kar - 10.07.2010

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;
}



Re: How do I do this - Mauzen - 10.07.2010

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

if (OnPlayerKill[playerid] == 1)


Edit: Oops, late post


Re: How do I do this - [DK]JaloNik - 10.07.2010

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.


Re: How do I do this - Kar - 10.07.2010

No problem.