Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
Script name: killAssist.fs
Version: 1d
Author: billz
Thanks to:
BigETI - constructive criticism
NaS - help with loop
*/
#include <a_samp>
#define killAssist@MAX_SLOTS 3 // total amount of people that can have assist on one player
new killAssist[MAX_PLAYERS][killAssist@MAX_SLOTS];
public OnFilterScriptInit()
{
for(new p = 0, j = GetPlayerPoolSize(); p <= j; p++)
{
for(new a; a < killAssist@MAX_SLOTS; a++)
{
killAssist[p][a] = INVALID_PLAYER_ID;
}
}
print(" ");
printf(" killAssist.fs by billz has loaded in");
print(" ");
}
public OnFilterScriptExit()
{
for(new p = 0, j = GetPlayerPoolSize(); p <= j; p++)
{
for(new a; a < killAssist@MAX_SLOTS; a++)
{
killAssist[p][a] = INVALID_PLAYER_ID;
}
}
}
public OnPlayerConnect(playerid)
{
for(new a; a < killAssist@MAX_SLOTS; a++)
{
killAssist[playerid][a] = INVALID_PLAYER_ID;
}
}
public OnPlayerDisconnect(playerid, reason)
{
for(new p = 0, j = GetPlayerPoolSize(); p <= j; p++)
{
for(new a; a < killAssist@MAX_SLOTS; a++)
{
if(killAssist[p][a] == playerid)
{
killAssist[p][a] = INVALID_PLAYER_ID;
break;
}
}
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
new slot = -1;
for(new a; a < killAssist@MAX_SLOTS; a++)
{
if(killAssist[playerid][a] == issuerid)
{
slot = -1;
break;
}
if((slot == -1) && (killAssist[playerid][a] == INVALID_PLAYER_ID))
{
slot = a;
}
}
if(slot != -1)
{
killAssist[playerid][slot] = issuerid;
}
//printf(" | playerid: %d | slot: %d | value: %d ", playerid, slot, killAssist[playerid][slot]);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
for(new a; a < killAssist@MAX_SLOTS; a++)
{
if(killAssist[playerid][a] == killerid)
{
killAssist[playerid][a] = INVALID_PLAYER_ID;
}
if((killAssist[playerid][a]!= INVALID_PLAYER_ID) && (killAssist[playerid][a] != killerid))
{
OnPlayerKillAssist(killAssist[playerid][a], playerid, killerid);
killAssist[playerid][a] = INVALID_PLAYER_ID; // keep this last
}
}
}
OnPlayerKillAssist(playerid, deathid, killerid)
{
// EXAMPLE - CHANGE THIS
new newStr[64], deathid_name[MAX_PLAYER_NAME], killerid_name[MAX_PLAYER_NAME];
GetPlayerName(deathid, deathid_name, sizeof deathid_name); GetPlayerName(killerid, killerid_name, sizeof killerid_name);
format(newStr, sizeof(newStr), "[kill-assist] You helped %s kill %s alongside:", killerid_name, deathid_name);
SendClientMessage(playerid, -1, newStr);
/*
for(new a; a < killAssist@MAX_SLOTS; a++)
{
if((killAssist[deathid][a]!= INVALID_PLAYER_ID) && (killAssist[deathid][a] != killerid))
{
new s[24];
format(s, sizeof(s), "%d", killAssist[deathid][a]);
SendClientMessage(playerid, -1, s);
}
}
*/
GivePlayerMoney(playerid, 500);
SetPlayerScore(playerid, GetPlayerScore(playerid)+5);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.