SA-MP Forums Archive
Car lock problem - 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)
+--- Thread: Car lock problem (/showthread.php?tid=411243)



Car lock problem - batonsa - 28.01.2013

Hello! I got a problem i kinda need help with, long story short its when u /lock you car, it sends the message it is locked, but you still can enter it, so does everyone else. Doesn't matter if you are admin or not.
All kinds of help is very much appreciated.

HERE IS THE /LOCK CODE:
Код:
		new key;
		if(ForwardOwnCar(1,playerid))
		{
			key = PlayerInfo[playerid][pCarkey];

		}
		else if(ForwardOwnCar(2,playerid))
		{
			key = PlayerInfo[playerid][pCarkey2];

		}
		else if(ForwardOwnCar(3,playerid))
		{
			key = PlayerInfo[playerid][pCarkey3];

		}
		else
		{
			return 1;

		}
		if(CarInfo[key][cLock] == 0)
		{
			CarInfo[key][cLock] = 0;
			format(string, sizeof(string), "~p~%s~n~~g~UNLOCKED",CarInfo[key][cDescription]);
			GameTextForPlayer(playerid, string, 7000, 4);
			SaveCars();
			return 1;


		}
		else if(CarInfo[key][cLock] == 1)
		{
			CarInfo[key][cLock] = 1;
			format(string, sizeof(string), "~g~%s~n~~r~LOCKED",CarInfo[key][cDescription]);
			GameTextForPlayer(playerid, string, 7000, 4);
			SaveCars();
			return 1;
HERE IS THE CODE, WHAT SHOULD HAPPEN, BUT DOESN'T:
Код:
	if(IsAnOwnableCar(vehicleid) && CarInfo[VehicleOwned[vehicleid]][cLock] != 1) {
		if(AdminDuty[playerid] == 0) {
			ApplyAnimationEx(playerid, "ped", "CAR_doorlocked_LHS", 3.0, 0, 0, 0, 0, 0);
			SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
			new Float:cx, Float:cy, Float:cz;
			GetPlayerPos(playerid, cx, cy, cz);
			DOO_SetPlayerPos(playerid, cx, cy, cz);
			SendClientMessage(playerid,COLOR_LIGHTRED,"[ERROR] This vehicle is currently locked!");
			LockCar[playerid][0] = 3;
			LockCar[playerid][1] = vehicleid;
			ApplyAnimationEx(playerid, "ped", "CAR_doorlocked_LHS", 3.0, 0, 0, 0, 0, 0);
			}
		}
	}
	return 1;
}



Re: Car lock problem - Amora187 - 28.01.2013

I know whats the problem make sure you make it ==1 because !=1 means its unlocked


Re: Car lock problem - batonsa - 28.01.2013

Doesn't seem to work, thanks though. I dont think thats the problem, since i have created most functions like that, all seem to work...except /lock :/


Re: Car lock problem - Amora187 - 28.01.2013

oh yes, in the /lock use this code instead:
Код:
if(CarInfo[key][cLock] == 0)
{
	CarInfo[key][cLock] = 1;
	format(string, sizeof(string), "~p~%s~n~~g~LOCKED",CarInfo[key][cDescription]);
	GameTextForPlayer(playerid, string, 7000, 4);
	SaveCars();
	return 1;


}
else if(CarInfo[key][cLock] == 1)
{
	CarInfo[key][cLock] = 0;
	format(string, sizeof(string), "~g~%s~n~~r~UNLOCKED",CarInfo[key][cDescription]);
	GameTextForPlayer(playerid, string, 7000, 4);
	SaveCars();
	return 1;
}



Re: Car lock problem - batonsa - 28.01.2013

Im gonna go off atm, ill test it later, thanks very much.