Security on all cars
#3

Quote:
Originally Posted by Allan
As posting random "OnPlayerCommandText" is frowned upon in the Useful Functions topic, I thought I'd make a topic for posting some fun/useful/Downright useless functions to add to your OnPlayerCommandText script!

For those in need of it:
strtok:
Код:
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;
}
/lock: Locks Car Doors
Код:
if (strcmp(cmdtext, "/lock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				if(i != playerid)
				{
					SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
				}
			}
			SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
			GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1056,X,Y,Z);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
		}
	return 1;
	}
/unlock: Unlocks Car Doors
Код:
	
if (strcmp(cmdtext, "/unlock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_GREY,"You can only unlock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
			}
			SendClientMessage(playerid, COLOR_GREY, "Vehicle unlocked!");
			GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1057,X,Y,Z);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
		}
	return 1;
	}
A simple lock/unlock command , simply found by searching.
Reply


Messages In This Thread
Security on all cars - by Wes_Lucchese - 18.02.2009, 16:03
Re: Security on all cars - by Bodo4you - 18.02.2009, 17:29
Re: Security on all cars - by BioFreeze - 18.02.2009, 18:21
Re: Security on all cars - by Wes_Lucchese - 19.02.2009, 09:20
Re: Security on all cars - by Redirect Left - 19.02.2009, 09:38

Forum Jump:


Users browsing this thread: 1 Guest(s)