All pastes #832157 Raw Edit

Someone

public cpp v1 · immutable
#832157 ·published 2007-12-25 21:33 UTC
rendered paste body
#include <a_samp>#include <string>#define COLOR_GREY 0xAFAFAFAA#define COLOR_GREEN 0x33AA33AA#define COLOR_RED 0xAA3333AA#define COLOR_YELLOW 0xFFFF00AA#define COLOR_WHITE 0xFFFFFFAA#pragma tabsize 0forward Kill(playerid);forward InfiniteLife();new GodTimer;new God[MAX_PLAYERS];main(){		print("\n----------------------------------");		print("        LarzI's GameMode\n");		print("          Made by LarzI");		print("         aka. RookieCarz");		print("----------------------------------\n");}public OnGameModeInit(){	SetGameModeText("LarzI's GameMode");	GodTimer = SetTimer("InfiniteLife",50,1);	//Player classes	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);	//Static vehicles	return 1;}public OnGameModeExit(){	GameTextForAll("GameMode restarting or changing", 5000, 5);	KillTimer(GodTimer);	return 1;}public OnPlayerRequestClass(playerid, classid){	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);	return 1;}public OnPlayerConnect(playerid){	new str[256];	new pname[MAX_PLAYER_NAME];	GetPlayerName(playerid, pname, sizeof(pname));	format(str, sizeof(str), "%s has joined the game", pname);	SendClientMessageToAll(COLOR_GREEN, str);	return 1;}public OnPlayerDisconnect(playerid, reason){    new str[256];	new pname[MAX_PLAYER_NAME];	GetPlayerName(playerid, pname, sizeof(pname));	format(str, sizeof(str), "%s has left the game", pname);	SendClientMessageToAll(COLOR_RED, str);	return 1;}public OnPlayerSpawn(playerid){	SetPlayerCheckpoint(playerid, 2413.6001, 1123.7188, 10.8203, 4.0);	return 1;}public OnPlayerDeath(playerid, killerid, reason){	return 1;}public OnPlayerCommandText(playerid, cmdtext[]){	new cmd[256];	new idx;	new Float:x, Float:y, Float:z;	new IsAdmin = IsPlayerAdmin(playerid);	new vehicleid = GetPlayerVehicleID(playerid);	new InVehicle = IsPlayerInVehicle(playerid, vehicleid);	cmd = strtok(cmdtext, idx);		if (strcmp(cmd, "/getvehicle", true) == 0)	{	    if(IsAdmin == 1)	    {			new carcolor;			new carcolor2;			new VehicleID;			new tmp[256];			tmp = strtok(cmdtext, idx);					if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /getvehicle [vehicleid] [color1] [color2]");				return 1;			}			VehicleID = strval(tmp);			tmp = strtok(cmdtext, idx);			if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /getvehicle [vehicleid] [color1] [color2]");				return 1;			}			carcolor = strval(tmp);			tmp = strtok(cmdtext, idx);			if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /getvehicle [vehicleid] [color1] [color2]");				return 1;			}			carcolor2 = strval(tmp);			GetPlayerPos(playerid, x, y, z);			CreateVehicle(VehicleID, x+2, y+2, z+2, 0, carcolor, carcolor2, 1000000);		}		return 1;	}	else if(strcmp(cmd, "/repair", true) == 0)	{		if(InVehicle == 0)		{			SendClientMessage(playerid, COLOR_RED, "You must be in/on a vehicle");		}		else if(IsAdmin == 1)		{			SetVehicleHealth(vehicleid, 1000);		}		else		{			SendClientMessage(playerid, COLOR_RED, "You are not an admin!");		}		return 1;	}	else if(strcmp(cmd, "/setcoord", true) == 0)	{		if(IsAdmin == 1)		{			new fx, fy, fz;			new tmp[256];			tmp = strtok(cmdtext, idx);			if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setcoord [float:x] [float:y] [float:z]");				return 1;			}			fx = strval(tmp);			tmp = strtok(cmdtext, idx);			if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setcoord [float:x] [float:y] [float:z]");				return 1;			}			fy = strval(tmp);			tmp = strtok(cmdtext, idx);			if(!strlen(tmp))			{				SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setcoord [float:x] [float:y] [float:z]");				return 1;			}			fz = strval(tmp);			SetPlayerPos(playerid, fx, fy, fz);		}		else		{			SendClientMessage(playerid, COLOR_RED, "You are not an admin!");		}		return 1;	}		else if(strcmp(cmd, "/spawn", true) == 0)	{		if(InVehicle == 1)		{		    SetPlayerInterior(playerid, 0);			SetVehiclePos(vehicleid, 2028.3151,1343.1859,10.8203);			SetVehicleZAngle(vehicleid, 271.7135);		}		else		{		    SetPlayerInterior(playerid, 0);		    SetPlayerPos(playerid, 2028.3151,1343.1859,10.8203);		    SetPlayerFacingAngle(playerid, 271.7135);		    SetCameraBehindPlayer(playerid);		}		return 1;	}		else if(strcmp(cmd, "/kill", true) == 0)	{	    Kill(playerid);	    return 1;	}		else if(strcmp(cmd, "/uphigh", true) == 0)	{	    if(IsAdmin == 1)	    {	    	GetPlayerPos(playerid, x, y, z);  		 	SetPlayerPos(playerid, x, y, z+100);	    }	    return 1;	}		else if(strcmp(cmd, "/god", true) == 0)    {        if (IsPlayerAdmin(playerid))        {            if(God[playerid] == 0)            {                God[playerid] = 1;                SendClientMessage(playerid,COLOR_GREEN,"GODMODE ON");            }            else            {                God[playerid] = 0;                SendClientMessage(playerid,COLOR_RED,"GODMODE OFF");                SetPlayerHealth(playerid, 100);            }        }        else        {            SendClientMessage(playerid,COLOR_RED,"You are not an admin!");        }        return 1;    }        else if(strcmp(cmd, "/jail", true) == 0)    {		if(IsAdmin == 1)		{        	new tmp[256];        	new str[256];        	new str2[256];        	new PlayerID;       		new aname[MAX_PLAYER_NAME];        	new vname[MAX_PLAYER_NAME];        	new vid[MAX_PLAYERS];        	new aid[MAX_PLAYERS];        	tmp = strtok(cmdtext, idx);        	        	if(!strlen(tmp))        	{        	    SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /jail [playerid]");        	    return 1;			}			PlayerID = strval(tmp);			if(IsPlayerConnected(PlayerID))			{			    SetPlayerInterior(PlayerID, 3);			    SetPlayerPos(PlayerID, 198.3797, 160.8905, 1003.0300);				TogglePlayerControllable(PlayerID, 0);				GetPlayerName(playerid, aname, sizeof(aname));				GetPlayerName(PlayerID, vname, sizeof(vname));				format(str, sizeof(str), "You have jailed %s (ID:%d)", vname, vid);				format(str2, sizeof(str2), "You have been jailed by %s (ID:%d)", aname, aid);				SendClientMessage(playerid, COLOR_YELLOW, str);				SendClientMessage(playerid, COLOR_YELLOW, str2);			}			else			{			    SendClientMessage(playerid, COLOR_YELLOW, "Invalid ID");			}		}		else		{		    SendClientMessage(playerid,COLOR_RED,"You are not an admin!");		}		return 1;	}		else if(strcmp(cmd, "/unjail", true) == 0)    {		if(IsAdmin == 1)		{        	new tmp[256];        	new str[256];        	new str2[256];        	new PlayerID;       		new aname[MAX_PLAYER_NAME];        	new vname[MAX_PLAYER_NAME];        	new vid[MAX_PLAYERS];        	new aid[MAX_PLAYERS];        	tmp = strtok(cmdtext, idx);        	if(!strlen(tmp))        	{        	    SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /unjail [playerid]");        	    return 1;			}			PlayerID = strval(tmp);			if(IsPlayerConnected(PlayerID))			{			    SetPlayerInterior(PlayerID, 0);			    SetPlayerPos(PlayerID, 2028.3151,1343.1859,10.8203);				TogglePlayerControllable(PlayerID, 1);				GetPlayerName(playerid, aname, sizeof(aname));				GetPlayerName(PlayerID, vname, sizeof(vname));				format(str, sizeof(str), "You have unjailed %s (ID:%d)", vname, vid);				format(str2, sizeof(str2), "You have been unjailed by %s (ID:%d)", aname, aid);				SendClientMessage(playerid, COLOR_YELLOW, str);				SendClientMessage(playerid, COLOR_YELLOW, str2);			}			else			{			    SendClientMessage(playerid, COLOR_YELLOW, "Invalid ID");			}		}		else		{		    SendClientMessage(playerid,COLOR_RED,"You are not an admin!");		}		return 1;	}    else    {    	SendClientMessage(playerid, COLOR_WHITE, "Unknown Command!");    }		return 1;}public OnPlayerEnterCheckpoint(playerid){    new IsAdmin = IsPlayerAdmin(playerid);	new Float:x, Float:y, Float:z, Float:angle;    new vehicleid = GetPlayerVehicleID(playerid);	new InVehicle = IsPlayerInVehicle(playerid, vehicleid);		if(InVehicle == 1)	{	    SendClientMessage(playerid, COLOR_RED, "You can't be in/on any vehicle!");	}	else if(IsAdmin == 1)	{		SetPlayerInterior(playerid, 3);		SetPlayerPos(playerid, x, y, z);		SetPlayerFacingAngle(playerid, angle);		SetCameraBehindPlayer(playerid);	}	else	{		SendClientMessage(playerid, COLOR_RED, "You are not an admin!");		SetPlayerInterior(playerid, 0);  		SetPlayerPos(playerid, 2028.3151,1343.1859,10.8203);	    SetPlayerFacingAngle(playerid, 271.7135);	}	return 1;}public Kill(playerid){	SetPlayerHealth(playerid, 0);}public InfiniteLife(){    for (new i = 0; i < MAX_PLAYERS; i++)    {        if (IsPlayerConnected(i) && God[i] == 1)        {            SetPlayerHealth(i, 250);        }    }}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;}