Little help assist kill :#
#1

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
Reply
#2

bump
Reply
#3

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'
Reply
#4

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.
Reply
#5

Thanks, worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)