Lock Command Doesnt Work? - 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 Command Doesnt Work? (
/showthread.php?tid=314251)
Lock Command Doesnt Work? -
Nuke547 - 29.01.2012
This is the command. It only shows that it is locked for you, but not anybody else.
PHP Code:
command(lock, playerid, params[])
{
new string[256];
if(Player[playerid][PlayerCarModel] > 0 && IsPlayerInRangeOfVehicle(playerid, Player[playerid][CarLinkID], 4))
{
if(Player[playerid][CarLinkID] > 0)
{
if(Player[playerid][LockedCar] == 0)
{
Player[playerid][LockedCar] = 1;
format(string, sizeof(string), "* %s takes out their keys and locks their car.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i == playerid)
{
SetVehicleParamsForPlayer(Player[playerid][CarLinkID], i, 0, 1);
}
}
return 1;
}
else
{
format(string, sizeof(string), "* %s takes out their keys and unlocks their car.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
Player[playerid][LockedCar] = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(Player[playerid][CarLinkID], i, 0, 0);
}
return 1;
}
}
}
}
Re: Lock Command Doesnt Work? -
mineralo - 29.01.2012
it should work, you maybe forgot to write stuff OnPlayerEnterVehicle
write something like this:
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger == 0)
{
if locked
{
GetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
SetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
SendClientMessage(playerid,COLOR_GREY,"( ! ) This vehicle is locked by the owner !");
}
}
}return 1;
}