help on: If(reason!=54)
#1

hello guys,
i'm doing a money bag system with gates on area 51 (restricted area) but i have a problem in: OnPlayerDeath(playerid, killerid, reason):

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(a51_haveMB[playerid] == 1) //if you have Money bag
	{
		 if(reason!=47) //if reason isn't sucicide
		 {
             GivePlayerMoney(killerid, a51_MB_money);
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и STATO UCCISO! %s ha ora i soldi dell'area 51", name, killerid);
             SendClientMessageToAll(COLOR_RED, str);
		 }
		 else
		 {
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и MORTO e ha perso i soldi dell'area 51", name);
             SendClientMessageToAll(COLOR_RED, str);
		 }
		 a51_haveMB[playerid] = 0;
		 GivePlayerMoney(playerid, -a51_MB_money);
	}
	return 1;
}
if sucicide me he not send the message "[AREA51]%s и MORTO e ha perso i soldi dell'area 51" but send this "[AREA51]%s и STATO UCCISO! %s ha ora i soldi dell'area 51"

who can help me? THX
Reply
#2

To detect if a player commits suicide, just check if there's no killer (killerid==INVALID_PLAYER_ID)
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(a51_haveMB[playerid] == 1) //if you have Money bag
    {
         if(killerid!=INVALID_PLAYER_ID) //if reason isn't sucicide
         {
             GivePlayerMoney(killerid, a51_MB_money);
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и STATO UCCISO! %s ha ora i soldi dell'area 51", name, killerid);
             SendClientMessageToAll(COLOR_RED, str);
         }
         else
         {
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и MORTO e ha perso i soldi dell'area 51", name);
             SendClientMessageToAll(COLOR_RED, str);
         }
         a51_haveMB[playerid] = 0;
         GivePlayerMoney(playerid, -a51_MB_money);
    }
    return 1;
}
Reply
#3

Why is the weapon 47? You can check who inflicted the damage and see if they did some-how, or if it's an invalid player id.

Change it to,
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(a51_haveMB[playerid] == 1) //if you have Money bag
    {
         if(killerid != playerid || killerid != INVALID_PLAYER_ID) //if reason isn't sucicide
         {
             GivePlayerMoney(killerid, a51_MB_money);
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и STATO UCCISO! %s ha ora i soldi dell'area 51", name, killerid);
             SendClientMessageToAll(COLOR_RED, str);
         }
         else
         {
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и MORTO e ha perso i soldi dell'area 51", name);
             SendClientMessageToAll(COLOR_RED, str);
         }
         a51_haveMB[playerid] = 0;
         GivePlayerMoney(playerid, -a51_MB_money);
    }
    return 1;
}
Reply
#4

Should be if(!reason == 47)
Reply
#5

Quote:
Originally Posted by Koala818
Посмотреть сообщение
To detect if a player commits suicide, just check if there's no killer (killerid==INVALID_PLAYER_ID)
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(a51_haveMB[playerid] == 1) //if you have Money bag
    {
         if(killerid!=INVALID_PLAYER_ID) //if reason isn't sucicide
         {
             GivePlayerMoney(killerid, a51_MB_money);
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и STATO UCCISO! %s ha ora i soldi dell'area 51", name, killerid);
             SendClientMessageToAll(COLOR_RED, str);
         }
         else
         {
             new str[128], name[MAX_PLAYER_NAME];
             GetPlayerName(playerid, name, sizeof(name));
             format(str, sizeof(str), "[AREA51]%s и MORTO e ha perso i soldi dell'area 51", name);
             SendClientMessageToAll(COLOR_RED, str);
         }
         a51_haveMB[playerid] = 0;
         GivePlayerMoney(playerid, -a51_MB_money);
    }
    return 1;
}
thank you, i've add 1 rep to you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)