All pastes #474935 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-05-07 02:55 UTC
rendered paste body
#include <a_samp>#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1#define COLOR_GREEN_AT 0xFF009F00#define gTeamKillsBeforeKick 3 // Set this hos you like.#define gAtksDefaultOn 1 // Set this to what you like. 1 = default is On. 2 = Off.public OnFilterScriptInit(){    printf("------------------\n");	printf("A-Teamkill BETA loaded successfully.\n");	printf("By Max.\n");	printf("------------------\n");}public OnFilterScriptExit(){	print("A-Teamkill BETA unloaded successfully.\n");}public OnPlayerDeath(playerid, killerid, reason){    new atksison = gAtksDefaultOn; 	if(atksison == 1)	{	    if(gTeam[playerid] == gTeam[killerid])	    {		    new killername[MAX_PLAYER_NAME], deadname[MAX_PLAYER_NAME], message[255], gTeamKills[MAX_PLAYERS];		    gTeamKills[playerid] ++;		    GetPlayerName(playerid, deadname, sizeof(MAX_PLAYER_NAME));		    GetPlayerName(killerid, killername, sizeof(MAX_PLAYER_NAME));		    format(message, sizeof(message), "* Player %s has been teamkilled by %s. %s has now %d teamkills. - A-Tks", deadname, killername, killername, gTeamKills[playerid]);		    SendClientMessageToAll(COLOR_GREEN_AT, message);				    if(gTeamKills[playerid] == gTeamKillsBeforeKick)		    {		    	format(message, sizeof(message), "* %s is being kicked after %s teamkills. - A-Tks", killername, gTeamKillsBeforeKick);		    	SendClientMessageToAll(COLOR_GREEN_AT, message);		    	Kick(killerid);		    }	    }	    else	    {	        return 1;    	}	return 1;	}}public OnPlayerCommandText(playerid, const cmdtext[]){	dcmd(gettks, 6, cmdtext);	dcmd(settks, 6, cmdtext);	dcmd(atks, 4, cmdtext);	return 0;}strtok(const string[], &index){	new length = strlen(string);	while ((index < length) && (string[index] <= ' '))	{		index++;	}	new offset = index;	new result[20];	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))	{		result[index - offset] = string[index];		index++;	}	result[index - offset] = EOS;	return result;}IsNumeric(const string[]){	for (new i = 0, j = strlen(string); i < j; i++)	{		if (string[i] > '9' || string[i] < '0') return 0;	}	return 1;}dcmd_gettks(playerid, params[]){    new idx;    new who[255];    who=strtok(params,idx);    if (!IsNumeric(who) || strlen(who)<1)	{       SendClientMessage(playerid, COLOR_GREEN_AT, "USAGE: /gettks [id] - A-Tks");       return true;    }    new otherid=strval(who);    if (!IsPlayerConnected(otherid))	{       SendClientMessage(playerid, COLOR_GREEN_AT, "* The ID you entered does not exist. A-Tks");       return true;    }    new suspectname[MAX_PLAYER_NAME];    new playertks[MAX_PLAYERS];    new string[255];    GetPlayerName(otherid, suspectname, MAX_PLAYER_NAME);    playertks = gTeamKills[otherid]    format(string, sizeof(string), "* Player %s has %d teamkills. - A-Tks",suspectname,playertks);    SendClientMessage(playerid, COLOR_GREEN_AT, string);    return true;}dcmd_settks(playerid, params[]){    new idx;    new who[MAX_PLAYERS];    new howmany[MAX_PLAYERS];    who=strtok(params,idx);    howmany=strtok(params, idx);	if (!IsPlayerAdmin(playerid))	{		SendClientMessage(playerid, COLOR_GREEN_AT, "* You're not an admin, log in or don't use that command! - A-Tks");		return true;	}	else if (!IsNumeric(who) || strlen(who)<1 || !IsNumeric(howmany) || strlen(howmany)<1)	{        SendClientMessage(playerid, COLOR_GREEN_AT, "USAGE: /settks [id] [howmany] - A-Tks");        return true;    }	else if (strlen(howmany) > gTeamKillsBeforeKick)	{		SendClientMessage(playerid, COLOR_GREEN_AT, "* The [howmany] is too big!");		return true;	}	new otherid=strval(who);    else if (!IsPlayerConnected(otherid))	{       SendClientMessage(playerid, COLOR_GREEN_AT, "* The ID you entered does not exist. A-Tks");       return true;    }    new suspectname[MAX_PLAYER_NAME];    new string[255];    GetPlayerName(otherid, suspectname, MAX_PLAYER_NAME);	gTeamKills[otherid] = howmany;    format(string, sizeof(string), "* Player %s has now %d teamkills. - A-Tks",suspectname,hownmany);    SendClientMessage(playerid, COLOR_GREEN_AT, string);    return true;}dcmd_atks(playerid, params[]){	new idx, onoroff[MAX_PLAYERS];	onoroff=strtok(params, idx);		if (!IsPlayerAdmin(playerid))	{		SendClientMessage(playerid, COLOR_GREEN_AT, "* You're not an admin, log in or don't use that command! - A-Tks");		return true;	}	else if (onoroff == "on")	{        atksison = 1;        SendClientMessageToAll(COLOR_GREEN_AT, "* A-Tks is now on. - A-Tks");        return true;    }    else if (onoroff == "off")	{        atksison = 0;        SendClientMessageToAll(COLOR_GREEN_AT, "* A-Tks is now off. - A-Tks");        return true;    }    	SendClientMessage(playerid, COLOR_GREEN_AT, "USAGE: /atks [on/off] - A-Tks");	return true;}