need help with auto unlock
#1

I need help with my /lock and /unlock....

how could i make it so it detects to see if a player used the /lock command? instead of just saying "vehicle unlocked" every time a player gets out of the vehicle.


Here are my /lock and /unlock commands

Код:
if (strcmp(cmdtext, "/lock", true)==0)
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				new State=GetPlayerState(playerid);
				if(State!=PLAYER_STATE_DRIVER)
				{
					SendClientMessage(playerid,0xFFFF00AA,"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, 0xFFFF00AA, "Vehicle locked!");
		  	new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1056,pX,pY,pZ);
				locked[playerid][GetPlayerVehicleID(playerid)] = 1;
			}
			else
			{
				SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
			}
			return 1;
		}


	if (strcmp(cmdtext, "/unlock", true)==0)
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				new State=GetPlayerState(playerid);
				if(State!=PLAYER_STATE_DRIVER)
				{
					SendClientMessage(playerid,0xFFFF00AA,"You can only lock the doors as the driver.");
					return 1;
				}
				new i;
				for(i=0;i<MAX_PLAYERS;i++)
				{
					SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
				}
				SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
				new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1057,pX,pY,pZ);
				locked[playerid][GetPlayerVehicleID(playerid)] = 0;
			}
			else
			{
				SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
			}
			return 1;
		}
Now, i need a auto unlock when a player leaves the car, so i did this but this does not detect it...

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    new i;
	for(i=0;i<MAX_PLAYERS;i++)
	{
	SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
	}
	SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
	new Float:pX, Float:pY, Float:pZ;
	GetPlayerPos(playerid,pX,pY,pZ);
	PlayerPlaySound(playerid,1057,pX,pY,pZ);
	locked[playerid][GetPlayerVehicleID(playerid)] = 0;
	}
  	return 1;
}
Reply
#2

Anyone?
Reply
#3

Whats this do exactly?

pawn Код:
locked[playerid][GetPlayerVehicleID(playerid)] = 0;
Also you do realise by the looks of that code it will only unlock it for that one player
Reply
#4

Quote:
Originally Posted by Torran
Whats this do exactly?

pawn Код:
locked[playerid][GetPlayerVehicleID(playerid)] = 0;
Also you do realise by the looks of that code it will only unlock it for that one player
Seriously? Can you give me /lock and /unlock codes then....i had no idea lol... and can you give me code for how to detect if player /locked his car and then automatically unlock, instead of automatically unlock everytime
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)