SA-MP Forums Archive
/lock not working - 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: /lock not working (/showthread.php?tid=633358)



/lock not working - aoky - 29.04.2017

When you type /lock it doesn't lock/unlock the vehicle, but it locks a business/house perfectly fine.
Код:
CMD:lock(playerid, params[])
{
	new str[128], id = GetNearestVehicle(playerid, 5.0);
	if(id != INVALID_VEHICLE_ID)
	{
		if(Vehicles[id][Locked] == 0)
		{
			SetVehicleParamsEx(id, Engine[id], Lights[id], alarm[id], doors[id], bonnet[id], boot[id], objective[id]);

		}
		return 1;
	}

	id = InRangeOfHouse(playerid);
    if(id != 0)
 	{
 	    if(Character[playerid][House] == id)
 	    {
 	        if(Houses[id][Locked] == 0)
 	        {
         		format(str, sizeof(str), "* %s places the key in the door, locking it.*", GetRoleplayName(playerid), str);
				SendLocalMessage(playerid, str, Range_Short, COLOR_RP, COLOR_RP);
				Houses[id][Locked] = 1;
				MYSQL_Update_Interger(Houses[id][SQLID], "Houses", "Locked", 1);
				return 1;
 	        }
 	        else
 	        {
 	            format(str, sizeof(str), "* %s places the key in the door, unlocking it.*", GetRoleplayName(playerid), str);
				SendLocalMessage(playerid, str, Range_Short, COLOR_RP, COLOR_RP);
				Houses[id][Locked] = 0;
				MYSQL_Update_Interger(Houses[id][SQLID], "Houses", "Locked", 0);
				return 1;
 	        }
 	    }
 	}

    id = InRangeOfBiz(playerid);
    if(id != 0)
 	{
 	    if(Character[playerid][Business_1] == id || Character[playerid][Business_2] == id)
 	    {
 	        if(Business[id][Locked] == 0)
 	        {
         		format(str, sizeof(str), "* %s places the key in the door, locking it.*", GetRoleplayName(playerid), str);
				SendLocalMessage(playerid, str, Range_Short, COLOR_RP, COLOR_RP);
				Business[id][Locked] = 1;
				MYSQL_Update_Interger(Houses[id][SQLID], "Business", "Locked", 1);
				return 1;
 	        }
 	        else
 	        {
 	            format(str, sizeof(str), "* %s places the key in the door, unlocking it.*", GetRoleplayName(playerid), str);
				SendLocalMessage(playerid, str, Range_Short, COLOR_RP, COLOR_RP);
				MYSQL_Update_Interger(Houses[id][SQLID], "Business", "Locked", 1);
				Business[id][Locked] = 0;
				return 1;
 	        }
 	    }
 	}

	return 0;
}



Re: /lock not working - BiosMarcel - 29.04.2017

Should do it:

PHP код:
SetVehicleParamsEx(idEngine[id], Lights[id], alarm[id], 1bonnet[id], boot[id], objective[id]);
doors[id] = 1
To me, it looks like, you are just reapplying the actual value