Vehicle /lock
#1

Hello! Sorry for my English. I have a problem with vehicle /lock. When I get in a car, I write /lock, car locks, then I get out of it after a while when I get back,I can enter it without having to write / lock. I do not have to write /lock to unlock it. Can solve this problem?
Reply
#2

i had the same prob anyway post your /lock code
Reply
#3

here is my /lock command :

Код:
new locked[MAX_PLAYERS];
if(strcmp(cmd, "/lock", true) == 0)	{
	  if(IsPlayerInAnyVehicle(playerid)) {
		 	for(new i = 0; i < MAX_PLAYERS; i++) SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i,false,true); locked[playerid] = 1;
		} else return SendClientMessage(playerid,red,"ERROR: You need to be in a vehicle to lock the doors");
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(locked[playerid] == 1) SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),playerid,false,false);
return 1;
}
Reply
#4

Etch ❽ H you are Ytu ?
Anyway post the whole /lock command
Reply
#5

lol i am not , i was just showing him an example for /lock
Reply
#6

Vehicles are streamed, you have to relock it when it streams back in.
Reply
#7

Quote:
Originally Posted by Johnny <~~
i had the same prob anyway post your /lock code
that's my /lock code
Код:
if(strcmp(cmd, "/lock", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			new carid;
			if (gTeam[playerid] == 2 || gTeam[playerid] == 1)
			{
				if(gLastCar[playerid] == 0 && PlayerInfo[playerid][pPhousekey] == 255)
				{
					SendClientMessage(playerid, COLOR_GRAD2, "  You dont have a Vehicle.");
					return 1;
				}
				else if(gLastCar[playerid] != 0 && gLastCar[playerid] != PlayerInfo[playerid][pPhousekey]+1)
				{
					if (HireCar[playerid] != gLastCar[playerid] && HireCar[playerid] != 299)
					{
						gLastDriver[HireCar[playerid]] = 300;
						gCarLock[HireCar[playerid]] = 0;
						UnLockCar(HireCar[playerid]);
					}
					HireCar[playerid] = gLastCar[playerid];
				}
			}
			if (PlayerInfo[playerid][pPhousekey] == 255)
			{
				if(HireCar[playerid] == 299)
				{
					SendClientMessage(playerid, COLOR_GRAD2, "  You dont have a Vehicle.");
					return 1;
				}
			}
			carid = PlayerInfo[playerid][pPhousekey]+1;
			if(HireCar[playerid] != 299 && !SwitchKey[playerid])
			{
				carid = HireCar[playerid];
			}
			//new driver = gLastDriver[carid];
			new lockstatus = gCarLock[carid];
			new Float:cx,Float:cy,Float:cz;
			GetVehiclePos(carid, cx, cy, cz);
			switch (lockstatus)
			{
				case 0:
				{
					if(HireCar[playerid] == 299 && PlayerInfo[playerid][pPhousekey] == 255)
					{
						SendClientMessage(playerid, COLOR_GRAD2, "  You dont have a Vehicle");
						return 1;
					}
					if(HireCar[playerid] == carid && !SwitchKey[playerid])
					{
						GameTextForPlayer(playerid, "~w~Hire Vehicle ~r~Locked", 5000, 6);
						PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
						gCarLock[carid] = 1;
						LockCar(carid);
					}
					else if (PlayerInfo[playerid][pPhousekey] == carid-1)
					{
						GameTextForPlayer(playerid, "~w~House Vehicle ~r~Locked", 5000, 6);
						PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
						gCarLock[carid] = 1;
						LockCar(carid);
						return 1;
					}
				}
				case 1:
				{
					if(HireCar[playerid] == 299 && PlayerInfo[playerid][pPhousekey] == 255)
					{
						SendClientMessage(playerid, COLOR_GRAD2, "  You dont have a Vehicle");
						return 1;
					}
					if(HireCar[playerid] == carid && !SwitchKey[playerid])
					{
						GameTextForPlayer(playerid, "~w~Hire Vehicle ~g~Unlocked", 5000, 6);
						PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
						gCarLock[carid] = 0;
						UnLockCar(carid);
					}
					if (PlayerInfo[playerid][pPhousekey] == carid-1)
					{
						GameTextForPlayer(playerid, "~w~House Vehicle ~g~Unlocked", 5000, 6);
						PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
						gCarLock[carid] = 0;
						UnLockCar(carid);
						return 1;
					}
				}
				default:
				{
					SendClientMessage(playerid, COLOR_GRAD2, "  Error");
				}
			}
			if(carid == 256)
			{
				SendClientMessage(playerid, COLOR_GRAD2, "  You dont have a Vehicle !");
			}
		}
Reply
#8

O_O Good luck

* Johnny walks away
Reply
#9

Quote:
Originally Posted by Donny
Vehicles are streamed, you have to relock it when it streams back in.
I know this, but i seen on a server roleplay, as this bug is fixed.
Reply
#10

http://forum.sa-mp.com/index.php?topic=2868.0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)