All pastes #825019 Raw Edit

spawn

public c v1 · immutable
#825019 ·published 2007-12-20 08:13 UTC
rendered paste body
// -- Simple Spawn Protection Filterscript --// --       By Donny / Donny_K (2007)      --// -- It has basic protection against spawn killers --// -- You can control how long the protection time  --// -- is by using the -- /sst [amount] command...   --// --              (Admins only)                    --#include <a_samp>//Credit to DracoBlue and Y_Less for DCMD (http://forum.sa-mp.com/index.php?topic=1858.0)#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1new gSpawnProtectionTime = 8;dcmd_sst(playerid, params[]){	if (!strlen(params)) return SendClientMessage(playerid, 0xafafafff, "Usage: /sst [amount]"); //Grey colour	if (!IsNumeric(params)) return SendClientMessage(playerid, 0xafafafff, "The [amount] param must be numerical"); //Grey colour	if (strval(params) < 1) return SendClientMessage(playerid, 0xafafafff, "The amount has to be greater than zero"); //Grey colour		new str[96];		format(str, sizeof(str), "Spawn protection time is now set to %d seconds", strval(params));	SendClientMessage(playerid, 0xffe600ff, str); //yellow (yolk) colour	gSpawnProtectionTime = strval(params);	return 1;}public OnPlayerCommandText(playerid, cmdtext[]){	if (IsPlayerAdmin(playerid))	{		dcmd(sst, 3, cmdtext);	}	return 0;}public OnPlayerSpawn(playerid){	new ii = gSpawnProtectionTime;	do	{		SetTimerEx("SpawnProtect", (gSpawnProtectionTime - ii) * 1000, false, "ii", playerid, ii);		ii --;	}	while (ii != -1);		return 1;}forward SpawnProtect(playerid, num);public SpawnProtect(playerid, num){	new str[32];	if (num)	{		format(str, sizeof(str), "%i", num);		GameTextForPlayer(playerid, str, 1001, 4); //Orange/bronze colour (standard for style 4)				if (IsPlayerInAnyVehicle(playerid))		{		    SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.000);		}		else		{			SetPlayerHealth(playerid, 250.000);		}	}	else	{		GameTextForPlayer(playerid, "~g~No longer protected", 3000, 4); //Green colour				SetPlayerHealth(playerid, 100.000);	}}IsNumeric(const string[]) //By Mike (samp-dev) (http://forum.sa-mp.com/index.php?topic=638.msg6610;topicseen#msg6610){	for (new i = 0, j = strlen(string); i < j; i++)	{	    if (string[i] > '9' || string[i] < '0') return 0;	}	return 1;}