[Help] Car lock... Whats wrong ?
#1

If i lock a car it works i cant enter it.. but if i enter another car and lock it i can enter my locked car ? what can be the problem ?



Код:
	if(strcmp(cmd, "/lock", true) == 0)
 	{
                new keycar = PlayerInfo[playerid][pPcarkey];
                if(keycar != 999)
                {
                    new locked[256];
                    locked = strtok(cmdtext, idx);
                    if(CarInfo[keycar][cLock] == 1)
                    {
                    	for(new i = 0; i < MAX_PLAYERS; i++)
		{
		if (IsPlayerConnected(i))
	             {
		SetVehicleParamsForPlayerEx(keycar,i,0,0);
		}
		}
					format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
					GameTextForPlayer(playerid, string, 4000, 3);
					CarInfo[keycar][cLock] = 0;
					OnPropUpdate();
					return 1;
					}
					else if(CarInfo[keycar][cLock] == 0)
					{
					    for(new i = 0; i < MAX_PLAYERS; i++)
						{
							if (IsPlayerConnected(i))
							{
							SetVehicleParamsForPlayerEx(keycar,i,0,1);
							}
						}
						format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
						GameTextForPlayer(playerid, string, 4000, 3);
						CarInfo[keycar][cLock] = 1;
						OnPropUpdate();
						return 1;
					}
                   }
                   else
                   {
                    SendClientMessage(playerid, COLOR_GREY, "* You don't have a vehicle for carlock 1");
                    return 1;
                    }
	       }
Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
	new p1, p2;
	p1 = vParams[vehicleid][forplayerid] & 2;
	p2 = vParams[vehicleid][forplayerid] & 1;
	SetVehicleParamsForPlayer(vehicleid, forplayerid, p1, p2);
            return 1;
}

public SetVehicleParamsForPlayerEx(vehicleid, playerid, para1, para2)
{
	vParams[vehicleid][playerid] = para1*2 + para2;
	if(IsVehicleStreamedIn(vehicleid, playerid))
 	SetVehicleParamsForPlayer(vehicleid, playerid, para1, para2);
	return 1;
}
Reply
#2

Try this:

Код:
dcmd_lockcar(playerid,params[]) {
	#pragma unused params
	    if(IsPlayerInAnyVehicle(playerid)) {
		 	for(new i = 0; i < MAX_PLAYERS; i++) SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i,false,true);
			PlayerInfo[playerid][DoorsLocked] = 1;
		} else return SendClientMessage(playerid,red,"ERROR: You need to be in a vehicle to lock the doors");
}
Reply
#3

At the top also add:

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

and
here
OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(lockcar,7,cmdtext);

andherethecommandItoldyou
Reply
#4

Hope that worked, it works for me, it will work for you too.
Reply
#5

Or if you don't wan't dcmd:

Код:
if (strcmp(cmdtext, "/lock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_RED,"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_BASIC, "Vehicle locked!");
	    	new Float:pX, Float:pY, Float:pZ;
			GetPlayerPos(playerid,pX,pY,pZ);
			PlayerPlaySound(playerid,1056,pX,pY,pZ);
			PlayerPlaySound(playerid, 1137,pX,pY,pZ);
			locked[playerid][GetPlayerVehicleID(playerid)] = 1;
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
		}
		return 1;
	}
And if u wan't COLOR_BASIC
Add #define COLOR_BASIC 0x0066FFAA
at the bottom of the script, or edit something.
Reply
#6

Okey i will try it now.. It another lock sytem.. i need to fix mine
Reply
#7

It another lock system? What is that ? xD
Reply
#8

Quote:
Originally Posted by Jimbo01
Посмотреть сообщение
Okey i will try it now.. It another lock sytem.. i need to fix mine
What is It another lock system?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)