31.12.2014, 08:10
OnPlayerChainKill
This callback is called whenever a player gains multiple kills in the given time, basically forming a kill chain.
Parameters:
playerid - The player who does the kill chain.
deadid - The last player who killed by the player while achieving kill chain.
reason - The reason/weaponid used for kill.
chaincounts - The value of player's total chaincounts processed on this callback. It automatically gets reset if player doesn't achieve another kill in given time.
Code:
This callback is called whenever a player gains multiple kills in the given time, basically forming a kill chain.
Parameters:
playerid - The player who does the kill chain.
deadid - The last player who killed by the player while achieving kill chain.
reason - The reason/weaponid used for kill.
chaincounts - The value of player's total chaincounts processed on this callback. It automatically gets reset if player doesn't achieve another kill in given time.
Code:
pawn Код:
#define KILL_CHAIN_TIME 10000 //10 seconds, the given time. Reduce or increase it according to your wish.
new
g_PlayerLastKillTime[MAX_PLAYERS] = {0, ...},
g_PlayerChainCount[MAX_PLAYERS] = {0, ...};
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID && killerid != playerid)
{
if((GetTickCount() - g_PlayerLastKillTime[killerid]) <= KILL_CHAIN_TIME)
{
g_PlayerChainCount[killerid]++;
CallLocalFunction("OnPlayerChainKill", "iiii", killerid, playerid, reason, g_PlayerChainCount[killerid]);
}
else g_PlayerChainCount[killerid] = 0;
}
g_PlayerLastKillTime[killerid] = GetTickCount();
return 1;
}
forward OnPlayerChainKill(playerid, deadid, reason, chaincount);
public OnPlayerChainKill(playerid, deadid, reason, chaincount)
{
// printf("Chain count : %d", chaincount); //debug
return 1;
}