SA-MP Forums Archive
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(lockplayeridparams[])
{
    new 
string[256];
    if(
Player[playerid][PlayerCarModel] > && IsPlayerInRangeOfVehicle(playeridPlayer[playerid][CarLinkID], 4))
    {
           if(
Player[playerid][CarLinkID] > 0)
           {
               if(
Player[playerid][LockedCar] == 0)
               {
                   
Player[playerid][LockedCar] = 1;
                   
format(stringsizeof(string), "* %s takes out their keys and locks their car."GetName(playerid));
                   
NearByMessage(playeridNICESKYstring);
                for(new 
0MAX_PLAYERSi++)
                {
                    if(
== playerid)
                    {
                        
SetVehicleParamsForPlayer(Player[playerid][CarLinkID], i01);
                    }
                }
                return 
1;
            }
            else
            {
                
format(stringsizeof(string), "* %s takes out their keys and unlocks their car."GetName(playerid));
                   
NearByMessage(playeridNICESKYstring);
                
Player[playerid][LockedCar] = 0;
                for(new 
0MAX_PLAYERSi++)
                {
                    
SetVehicleParamsForPlayer(Player[playerid][CarLinkID], i00);
                }
                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;
}