All pastes #818308 Raw Edit

SA-MP [FS] Vehicle Limiter

public cpp v1 · immutable
·published 2007-12-16 06:15 UTC
rendered paste body
#include <a_samp>#include <core>#include <float>#include <dutils>#pragma unused ret_memcpy#define COLOR_GREY 0xAFAFAFAA#define COLOR_GREEN 0x33AA33AA#define COLOR_RED 0xCC0000AA#define COLOR_YELLOW 0xFFFF00AA#define COLOR_WHITE 0xFFFFFFAA#define CarSpawnLimit 15forward CarSpawner(playerid,vehicleid);forward CarSpawnLimiter(playerid);new CarSpawn[MAX_PLAYERS];new Car[MAX_PLAYERS];new Carx[MAX_PLAYERS];new Carxx[MAX_PLAYERS];new Turn[MAX_PLAYERS];//------------------------------------------------------------------------------public OnPlayerCommandText(playerid, cmdtext[]){	new cmd[256];	new idx;	cmd = strtok(cmdtext, idx);	//--------------------------------------------------------------------------	//KART 	if(strcmp(cmd, "/kart", true) == 0) {		CarSpawner(playerid,571);  	  	return 1;	}		//--------------------------------------------------------------------------	return 0;}//------------------------------------------------------------------------------public CarSpawner(playerid,vehicleid){    new Float:x;new Float:y;new Float:z; 	GetPlayerPos(playerid, x, y, z); 	new string[256];	if(IsPlayerInAnyVehicle(playerid)){		SendClientMessage(playerid, COLOR_RED, "You already have a car!"); 	} 	else{		if(CarSpawn[playerid]==0){			CreateVehicle(vehicleid, x+3, y, z, 900.00, -1, -1, 60000);		 	CarSpawn[playerid]=CarSpawnLimit;		}		else{			format(string, sizeof(string), "** You have to wait %d  seconds to create a new car**", CarSpawn[playerid]);			SendClientMessage(playerid,COLOR_RED, string);		}	}}public CarSpawnLimiter(){	new i;	for(i=0;i<=MAX_PLAYERS;i++){	    if(CarSpawn[i]>0){   	 		CarSpawn[i]--;	    }	}}//------------------------------------------------------------------------------public OnVehicleSpawn(vehicleid){	new Float:x,Float:y,Float:z;	GetVehiclePos(vehicleid,x,y,z);		for(new i=0;i<MAX_PLAYERS;i++){	    new Float:xx,Float:yy,Float:zz;		GetPlayerPos(i,xx,yy,zz);		new Float:SpawnPos=xx+3;				if(SpawnPos==x){			if(Car[i]>0){				Car[i]=vehicleid;				Turn[i]=0;			}			else{			    if(Carx[i]>0) Carx[i]=vehicleid;			    else{		   	 		if(Carxx[i]>0) Carxx[i]=vehicleid;		   	 		else{		   	 		    switch(Turn[i]){							case 0:{							    DestroyVehicle(Car[i]);							    Car[i]=vehicleid;							    Turn[i]++;							}							case 1:{							    DestroyVehicle(Carx[i]);							    Carx[i]=vehicleid;							    Turn[i]++;							}							case 2:{							    DestroyVehicle(Carxx[i]);							    Carxx[i]=vehicleid;							    Turn[i]=0;							}		   	 		    }		   	 		}			    }			}		}	}	return 1;}//------------------------------------------------------------------------------public OnGameModeInit(){    SetTimer("CarSpawnLimiter",1000,true);}