SA-MP Forums Archive
[help] lock command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [help] lock command (/showthread.php?tid=240200)



[help] lock command - InsaniManES - 15.03.2011

I want to check.
If the player in the radious of the car (1.00000), you can lock/unlock the car.
How can I do that?


Re: [help] lock command - Ironboy - 15.03.2011

try this
pawn Код:
if (strcmp(cmdtext, "/unlock", true)==0)
        {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new State=GetPlayerState(playerid);
            if(State!=PLAYER_STATE_DRIVER)
            {
                SendClientMessage(playerid,0xFFFF00AA,"You can only unlock the doors as the driver.");
                return 1;
            }
            new i;
            for(i=0;i<MAX_PLAYERS;i++)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
            }
            SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1057,pX,pY,pZ);
        }
        else
        {
            SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
        }
        return 1;
        }
    if (strcmp(cmdtext, "/lock", true)==0)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new State=GetPlayerState(playerid);
                if(State!=PLAYER_STATE_DRIVER)
                {
                    SendClientMessage(playerid,0xFFFF00AA,"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, 0xFFFF00AA, "Vehicle locked!");
                new Float:pX, Float:pY, Float:pZ;
                GetPlayerPos(playerid,pX,pY,pZ);
                PlayerPlaySound(playerid,1056,pX,pY,pZ);
            }
            else
            {
                SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
            }
            return 1;
        }



Re: [help] lock command - InsaniManES - 15.03.2011

if(!strcmp(cmd, "/lock", true))
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(vehicleid, vehx, vehy, vehz);
if(IsPlayerInRangeOfPoint(playerid,1.0,vehx,vehy,v ehz))
{
//CarsInfo[vehicleid][lock]=-1
if(CarsInfo[vehicleid][lock]==-1 || CarsInfo[vehicleid][lock]==0)
CarsInfo[vehicleid][lock]=1;
else
CarsInfo[vehicleid][lock]=0;
SetVehicleParamsForPlayer(vehicleid,playerid,0,Car sInfo[vehicleid][lock]);
}
return 1;
}


It doesn't working.
I mean, I can lock/unlock the car but only if I'm in the car.