SA-MP Forums Archive
Locking the vehicle giving rep - 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: Locking the vehicle giving rep (/showthread.php?tid=479691)



Locking the vehicle giving rep - iBots - 06.12.2013

my code for locking the car :
pawn Код:
if(strcmp(cmd, "/lock", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            for(new i= 0; i < MAX_PLAYERS; i++)
            {
                if(i == playerid) continue;
                if(PlayerInfo[playerid][PlayerCarModel] == 0 || PlayerInfo[playerid][PlayerCarModel2] == 0)
                {
                    SendClientMessage(playerid, COLOR_GREY," You dont own a vehicle.");
                    return 1;
                }
                new Float: x, Float: y, Float: z;
                GetVehiclePos(PlayerInfo[playerid][CarLinkID], x, y, z);
                if(IsPlayerInRangeOfPoint(playerid, PlayerInfo[playerid][Car2LinkID], x, y, z))
                {
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
                    else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    PlayerInfo[playerid][LockedCar] = 1;
                    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
                }
                GetVehiclePos(PlayerInfo[playerid][Car2LinkID], x, y, z);
                if(IsPlayerInRangeOfPoint(playerid, PlayerInfo[playerid][Car2LinkID], x, y, z))
                {
                    PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
                    if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger has locked their vehicle.");
                    else format(string, sizeof(string), "* %s has locked their vehicle.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    PlayerInfo[playerid][LockedCar2] = 1;
                    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are too far away from your vehicle !");
                    return 1;
                }
            }
        }
        return 1;
    }
and SetVehicleParamsForPlayer doesnt work it doesnt lock the vehicle but i got a public called Lockcar:
pawn Код:
forward LockCar(carid);
pawn Код:
public LockCar(carid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetVehicleParamsForPlayer(carid,i,0,1);
            PlayerInfo[i][LockedCar] = 1;
        }
    }
}
how can i use the lockcar to lock it?
i have tried LockCar(carid); it shows error that it's not defined and also i tried vehicleid instead of carid it shows error,what should i write to let it work?


Re: Locking the vehicle giving rep - J4mmyHD - 06.12.2013

pawn Код:
public LockCar(carid, playerid)
{
     if(IsPlayerConnected(playerid))
     {
         new engine, lights, alarm, doors, bonnet, boot, objective;
         GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
         SetVehicleParamsEx(vehicleid, engine, lights, alarm, true, bonnet, boot, objective);
         PlayerInfo[playerid][LockedCar] = 1;
     }
}
Then used
pawn Код:
LockCar(carid, playerid);