SA-MP Forums Archive
Tutorial Lock Cars - 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: Tutorial Lock Cars (/showthread.php?tid=464542)



Tutorial Lock Cars - Bulgaria - 17.09.2013

hello friend i add this car
PHP код:
AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56); 
in my RP server in car showroom when i create but i have to lock this car and when somebody try to get this car i want the car is locked and nobody can get it


Re: Tutorial Lock Cars - EiresJason - 17.09.2013

Place this above main()
pawn Код:
new Cars[MAX_VEHICLES];
And place this under OnGameModeInit()
pawn Код:
Cars[0] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);

for(new i=1; i<MAX_VEHICLES; i++)
{
    SetVehicleParamsEx(Cars[i], 0,0,0,0,0,0,0);
}



Re: Tutorial Lock Cars - Bulgaria - 17.09.2013

little for newbie i dont understand ?


Re: Tutorial Lock Cars - EiresJason - 17.09.2013

Press Control+F and type main().

Put this "new Cars[MAX_VEHICLES];" above main(). (without the " " though.)
Like this.
pawn Код:
new Cars[MAX_VEHICLES];

main()
{
    //some code
}
Press Control+F again and type OnGameModeInit(). Then put the rest of the code in it.
Like this.
pawn Код:
public OnGameModeInit()
{

    Cars[0] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);

    for(new i=1; i<MAX_VEHICLES; i++)
    {
        SetVehicleParamsEx(Cars[i], 0,0,0,0,0,0,0);
    }
   
    return 1;
}



Re: Tutorial Lock Cars - Bulgaria - 17.09.2013

ok and when i have to add new car what i have to do ?


Re: Tutorial Lock Cars - EiresJason - 17.09.2013

Do this;
pawn Код:
Cars[number] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);
See below code;
pawn Код:
public OnGameModeInit()
{

    Cars[0] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);
    Cars[1] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);
    Cars[2] = AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);
    Cars[3]= AddStaticVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56);

    for(new i=1; i<MAX_VEHICLES; i++)
    {
        SetVehicleParamsEx(Cars[i], 0,0,0,0,0,0,0);
    }
   
    return 1;
}



Re: Tutorial Lock Cars - Bulgaria - 17.09.2013

ok tnx 1000000000000000000000000000000xxxxxxxxxxxxx )))))


Re: Tutorial Lock Cars - EiresJason - 17.09.2013

No problem


Re: Tutorial Lock Cars - Bulgaria - 17.09.2013

ok but what happend now ?


Re: Tutorial Lock Cars - EiresJason - 17.09.2013

Did you forget to put this code above main()?
pawn Код:
new Cars[MAX_VEHICLES];
Ops; my bad.

pawn Код:
public OnGameModeInit()
{

    Cars[0] = CreateVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56, 60);
    Cars[1] = CreateVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56, 60);
    Cars[2] = CreateVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56, 60);
    Cars[3]= CreateVehicle(411,535.9333,-1299.3344,17.5634,99.7864,0,56, 60);

    for(new i=0; i<MAX_VEHICLES; i++)
    {
        SetVehicleParamsEx(Cars[i], 0,0,0,0,0,0,0);
    }
   
    return 1;
}