Skip to content

Instantly share code, notes, and snippets.

@billz0101
Last active July 3, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billz0101/3002d3263bf082d137c9e45a2b3a050e to your computer and use it in GitHub Desktop.
Save billz0101/3002d3263bf082d137c9e45a2b3a050e to your computer and use it in GitHub Desktop.
/*
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