SA-MP Forums Archive
need help with auto unlock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: need help with auto unlock (/showthread.php?tid=129815)



need help with auto unlock - ruckfules99 - 23.02.2010

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;
}



Re: need help with auto unlock - ruckfules99 - 23.02.2010

Anyone?


Re: need help with auto unlock - Torran - 23.02.2010

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


Re: need help with auto unlock - ruckfules99 - 24.02.2010

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