SA-MP Forums Archive
CMD:lock isn't locking? - 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: CMD:lock isn't locking? (/showthread.php?tid=419125)



CMD:lock isn't locking? - UnknownGamer - 27.02.2013

pawn Код:
CMD:lock(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new keycar = PlayerInfo[playerid][pPcarkey];
    if(keycar != 9999)
    {
        new Float:X,Float:Y,Float:Z;
        GetVehiclePos(keycar,X,Y,Z);
        if(IsPlayerInRangeOfPoint(playerid, 10,X,Y,Z))
        {
            if(CarInfo[keycar][cLock] == 1)
            {
                SCM(playerid, COLOR_LIGHTBLUE, "Vehicle Unlocked!");
                CarInfo[keycar][cLock] = 0;
                GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(keycar2, engine, lights, alarm, 0, bonnet, boot, objective);
                OnPropUpdate(4,keycar);
                return 1;
            }
            else if(CarInfo[keycar][cLock] == 0)
            {
                SCM(playerid, COLOR_LIGHTBLUE, "Vehicle Locked!");
                CarInfo[keycar][cLock] = 1;
                GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(keycar2, engine, lights, alarm, 1, bonnet, boot, objective);
                OnPropUpdate(4,keycar);
                return 1;
            }
        }
       
        // Car 2
        new keycar2 = PlayerInfo[playerid][pPcarkey2];
        if(keycar2 != 9999)
        {
            new Float:X2,Float:Y2,Float:Z2;
            GetVehiclePos(keycar2,X2,Y2,Z2);
            if(IsPlayerInRangeOfPoint(playerid, 10,X2,Y2,Z2))
            {
                if(CarInfo[keycar2][cLock] == 1)
                {
                    SCM(playerid, COLOR_LIGHTBLUE, "Vehicle 2 Unlocked!");
                    CarInfo[keycar2][cLock] = 0;
                    GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(keycar2, engine, lights, alarm, 0, bonnet, boot, objective);
                    OnPropUpdate(4,keycar2);
                    return 1;
                }
                else if(CarInfo[keycar2][cLock] == 0)
                {
                    SCM(playerid, COLOR_LIGHTBLUE, "Vehicle 2 Locked!");
                    CarInfo[keycar2][cLock] = 1;
                    GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(keycar2, engine, lights, alarm, 1, bonnet, boot, objective);
                    OnPropUpdate(4,keycar2);
                    return 1;
                }
            }
        }
        else
        {
            SCM(playerid, COLOR_GREY,"* You must be near or in your vehicle to lock it!");
            return 1;
        }
    }
    else
    {
        SCM(playerid, COLOR_GREY, "* You don't have a vehicle at slot 1/2!");
        return 1;
    }
    return 1;
}
Have I made a stupid mistake here, or why do cars not lock?

I don't see why they shudn't? They use the correct params, says it locked etc, but doors do not lock?


Respuesta: CMD:lock isn't locking? - MiGu3X - 27.02.2013

if(IsPlayerConnected(playerid) && Vehicle[GetPlayerVehicleID(playerid)][IsLocked] == 0){

maybe add?


Re: CMD:lock isn't locking? - UnknownGamer - 27.02.2013

That wont work.


Re: CMD:lock isn't locking? - Unte99 - 27.02.2013

pawn Код:
new keycar

SetVehicleParamsEx(keycar2



Re: CMD:lock isn't locking? - zxc1 - 27.02.2013

The guy above me is right. ^
pawn Код:
CMD:lock(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new keycar = PlayerInfo[playerid][pPcarkey];
    if(keycar != 9999)
    {
        new Float:X,Float:Y,Float:Z;
        GetVehiclePos(keycar,X,Y,Z);
        if(IsPlayerInRangeOfPoint(playerid, 10,X,Y,Z))
        {
            if(CarInfo[keycar][cLock] == 1)
            {
                SCM(playerid, COLOR_LIGHTBLUE, "Vehicle Unlocked!");
                CarInfo[keycar][cLock] = 0;
                GetVehicleParamsEx(keycar, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(keycar, engine, lights, alarm, 0, bonnet, boot, objective);
                OnPropUpdate(4,keycar);
                return 1;
            }
            else if(CarInfo[keycar][cLock] == 0)
            {
                SCM(playerid, COLOR_LIGHTBLUE, "Vehicle Locked!");
                CarInfo[keycar][cLock] = 1;
                GetVehicleParamsEx(keycar, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(keycar, engine, lights, alarm, 1, bonnet, boot, objective);
                OnPropUpdate(4,keycar);
                return 1;
            }
        }
       
        // Car 2
        new keycar2 = PlayerInfo[playerid][pPcarkey2];
        if(keycar2 != 9999)
        {
            new Float:X2,Float:Y2,Float:Z2;
            GetVehiclePos(keycar2,X2,Y2,Z2);
            if(IsPlayerInRangeOfPoint(playerid, 10,X2,Y2,Z2))
            {
                if(CarInfo[keycar2][cLock] == 1)
                {
                    SCM(playerid, COLOR_LIGHTBLUE, "Vehicle 2 Unlocked!");
                    CarInfo[keycar2][cLock] = 0;
                    GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(keycar2, engine, lights, alarm, 0, bonnet, boot, objective);
                    OnPropUpdate(4,keycar2);
                    return 1;
                }
                else if(CarInfo[keycar2][cLock] == 0)
                {
                    SCM(playerid, COLOR_LIGHTBLUE, "Vehicle 2 Locked!");
                    CarInfo[keycar2][cLock] = 1;
                    GetVehicleParamsEx(keycar2, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(keycar2, engine, lights, alarm, 1, bonnet, boot, objective);
                    OnPropUpdate(4,keycar2);
                    return 1;
                }
            }
        }
        else
        {
            SCM(playerid, COLOR_GREY,"* You must be near or in your vehicle to lock it!");
            return 1;
        }
    }
    else
    {
        SCM(playerid, COLOR_GREY, "* You don't have a vehicle at slot 1/2!");
        return 1;
    }
    return 1;
}



Re: CMD:lock isn't locking? - UnknownGamer - 27.02.2013

Hmm that worked.

What did I do wrong, please could you explain for future referance,

What bit of code was wrong?


Re: CMD:lock isn't locking? - Unte99 - 27.02.2013

In the first car script.

new keycar = PlayerInfo[playerid][pPcarkey];

SetVehicleParamsEx(keycar2, engine, lights, alarm, 0, bonnet, boot, objective);

Clear enough ?


Re: CMD:lock isn't locking? - UnknownGamer - 27.02.2013

Quote:
Originally Posted by Unte99
Посмотреть сообщение
In the first car script.

new keycar = PlayerInfo[playerid][pPcarkey];

SetVehicleParamsEx(keycar2, engine, lights, alarm, 0, bonnet, boot, objective);

Clear enough ?
Omd, stupid spelling mistake ;l. Thanks