SA-MP Forums Archive
help on: If(reason!=54) - 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)
+--- Thread: help on: If(reason!=54) (/showthread.php?tid=515366)



help on: If(reason!=54) - DarK_FeneR - 25.05.2014

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


Re: help on: If(reason!=54) - Koala818 - 25.05.2014

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



Re: help on: If(reason!=54) - Abagail - 25.05.2014

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



Re: help on: If(reason!=54) - MikE1990 - 25.05.2014

Should be if(!reason == 47)


Re: help on: If(reason!=54) - DarK_FeneR - 25.05.2014

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