SA-MP Forums Archive
Little help assist kill :# - 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: Little help assist kill :# (/showthread.php?tid=564292)



Little help assist kill :# - ReD_HunTeR - 20.02.2015

pawn Код:
new assistkill[MAX_PLAYERS] = INVALID_PLAYER_ID, Float: assist[MAX_PLAYERS];

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
   if(issuerid != INVALID_PLAYER_ID)
   {
      if(GetPlayerTeam(issuerid) != NO_TEAM && IsPlayerConnected(playerid) && GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
      {
         assistkill[issuerid] = playerid;
         assist[issuerid] += amount;
      }
   }
   return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
      if(i != INVALID_PLAYER_ID && killerid != INVALID_PLAYER_ID)
      {
         if(assistkill[i] != playerid && assist[i] >= 70)
         {
            new string50[300];
            format(string50, sizeof(string50), "[Assist] 500$ for assisting %s(%d) in killing %s(%d) (%.2f)", PlayerName(killerid), killerid, PlayerName(playerid), playerid, assist[i]);
            SendClientMessage(assistkill[i], COLOR_LIME, string50);
            GivePlayerCash(assistkill[i], 500);
            assistkill[i] = INVALID_PLAYER_ID;
            assist[i] = 0;
         }
      }
   }
   return 1;
}
not working, send message to the guy who got killed by random player :3


Re: Little help assist kill :# - ReD_HunTeR - 21.02.2015

bump


Re: Little help assist kill :# - Sawalha - 21.02.2015

at the first callback, you set assistkill variable value as playerid (the player who took damage)
why did you add '!' between these two variables, while they should be checked as equal be cause, 'i' is the guy who shot the 'playerid' before his death
pawn Код:
if(assistkill[i] != playerid // .... )
and replace assistkill[i] with i , in sendclientmessage part:
pawn Код:
SendClientMessage(i, COLOR_LIME, string50);
be cause by that , you are sending the message to the value of assistkill variable, not 'i'


Re: Little help assist kill :# - Gammix - 21.02.2015

pawn Код:
new assistkill[MAX_PLAYERS] = INVALID_PLAYER_ID, Float: assist[MAX_PLAYERS];

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
   if(issuerid != INVALID_PLAYER_ID)
   {
      if(GetPlayerTeam(issuerid) != NO_TEAM && IsPlayerConnected(playerid) && GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
      {
         assistkill[issuerid] = playerid;
         assist[issuerid] += amount;
      }
   }
   return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
      if(playerid != INVALID_PLAYER_ID && killerid != INVALID_PLAYER_ID)
      {
         if(assistkill[i] == playerid && i != killerid && assist[i] >= 70)
         {
            new string50[300];
            format(string50, sizeof(string50), "[Assist] 500$ for assisting %s(%d) in killing %s(%d) (%.2f)", PlayerName(killerid), killerid, PlayerName(playerid), playerid, assist[i]);
            SendClientMessage(i, COLOR_LIME, string50);
            GivePlayerCash(i, 500);
            assistkill[i] = INVALID_PLAYER_ID;
            assist[i] = 0.0;
         }
      }
   }
   return 1;
}
Try this, you have just mis placed the ids and made few unnecessary checks.


Re: Little help assist kill :# - ReD_HunTeR - 21.02.2015

Thanks, worked