All pastes #549030 Raw Edit

Filterscript: AddVehicleComponet

public cpp v1 · immutable
·published 2007-06-07 23:19 UTC
rendered paste body
#include <a_samp>#define COLOR_YELLOW 0xFFFF00AA#define ADMIN_ONLY false // Change this to true if you want /addcomp accessible to only administrators.public OnFilterScriptInit(){	print("\n--------------------------------------");	print(" AddVehicleComponet Filterscript by `Michael^ (LilDude) loaded.");	print("--------------------------------------\n");	return 1;}public OnFilterScriptExit(){	print("\n--------------------------------------");	print(" AddVehicleComponet Filterscript by `Michael^ (LilDude) unloaded.");	print("--------------------------------------\n");	return 1;}public OnPlayerCommandText(playerid, cmdtext[]) {	#if ADMIN_ONLY == true	if(IsPlayerAdmin(playerid)) {	#endif		new cmd[256], idx;		cmd = strtok(cmdtext, idx);		if (strcmp(cmd, "/addcomp", true)==0)		{		    new tmp[256], string[256];			tmp = strtok(cmdtext, idx);   			if(!strlen(tmp)) {				SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /addcomp [componetid]");				return 1;			}         	new compid = strval(tmp);         	if(IsPlayerInAnyVehicle(playerid)) {				if(compid < 1000 || compid > 1193) {				   	SendClientMessage(playerid,COLOR_YELLOW,"ERROR: Invalid componet ID.");						return 1;				} else {			    	new carid = GetPlayerVehicleID(playerid);				    AddVehicleComponent(carid,compid);				    format(string,sizeof(string),"Successfuly added the requested componet (%d).",compid);				    SendClientMessage(playerid,COLOR_YELLOW, string);				    return 1;				}			} else {			    SendClientMessage(playerid,COLOR_YELLOW,"ERROR: You are not in a vehicle.");			    return 1;			}		}	#if ADMIN_ONLY == true	}	#endif	return 0;}//// Strtok for the command//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;}