PDA

View Full Version : Is this right?


EliteApple
11/05/2013, 03:44 PM
While re-vamping something in my script, I wind up putting this:

for(new i = 0; i < sizeof(DynamicCars); i++)
{
if(DynamicCars[i][CarType] != 1)
{
SetVehicleParamsForPlayer(i, playerid, 1, 0);
}
}


But it's not working. But I'm also not getting any errors, is it even right?

feartonyb
11/05/2013, 04:34 PM
This looks fine. What do you want to make with this? To lock the car?

EliteApple
11/05/2013, 04:35 PM
Unlocking it. It won't unlock. I've turned it into this:


for (new carid =0; carid<MAX_VEHICLES; carid++)
{

if(DynamicCars[carid][CarType] == 1)
{
SetVehicleParamsForPlayer(carid, playerid, 0, 0);
SendClientMessage(playerid, COLOR_RED, "This works.");
}

}


I get the message three times (3 vehicles have type '1', so yeah that should be legit.) But they aren't unlocking.

feartonyb
11/05/2013, 04:49 PM
You dont need for if you are unlocking just that car.
Use this



if(DynamicCars[GetPlayerVehicleID(playerid)][CarType] == 1)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playe rid),playerid,0,1);
}

EliteApple
11/05/2013, 04:50 PM
1) It's unlocking /THREE/ cars of the same TYPE.

2) The player is not in a vehicle during the time this is processed.

Blackazur
11/05/2013, 04:50 PM
Yep, that should work.

feartonyb
11/05/2013, 04:52 PM
Bro where do you put this code. In onplayerentervehicle on onplayerstatechange?

EliteApple
11/05/2013, 04:52 PM
Inside of a command, actually.

feartonyb
11/05/2013, 04:54 PM
Man put the command here.

EliteApple
11/05/2013, 04:55 PM
Nevermind it. Found a way to bypass it.

Knappen
11/05/2013, 05:00 PM
You could put it under the native "OnVehicleSpawn". You don't need a loop for it then.