Random Vehicle Plate
#1

Hello Everyone,

I tried to make a function using for loop for all vehicle's which set's Vehicle's number plate according to the vehicleid.

I mean if the vehicleid = 1 then the Plate will be CW 1 Or something. For Vehicleid = 2 it shud be CW 2.

Im out of idea's and how can i do it , Not able to use SetVehicleNumberPlate correctly. If someone can suggest something or code me this function , will be fucking awesome.!

Thanks
Ballu Miaa
Reply
#2

EDIT:Here is the code
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new str[32]; format(str, sizeof str, "SAMP %i", vehicleid);
SetVehicleNumberPlate(vehicleid, str);
SetVehicleToRespawn(vehicleid);
return 1;
}
This will work.
Note - don't change the 32 cell bit to something else in the str[32] code and also don't remove SetVehicleToRespawn cause the effects and changes take place after respawn.
Reply
#3

Thanks Mate! Need to use /rac to take affect always. Anyway to avoid it?
Reply
#4

Guy after using the above code vehicle plate's doesnt change. I have to use /rac to take affect.
Even though i've added this function under OnGameModeInIt()
pawn Код:
forward UpdatePlates();
public UpdatePlates()
{
    for(new i=0;i >= MAX_VEHICLES;i++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}
Im still not able to set vehicle plate's. Only /rac make's it working but its need an admin to /rac always!
Is there any fix for that?
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Guy after using the above code vehicle plate's doesnt change. I have to use /rac to take affect.
Even though i've added this function under OnGameModeInIt()
pawn Код:
forward UpdatePlates();
public UpdatePlates()
{
    for(new i=0;i >= MAX_VEHICLES;i++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}
Im still not able to set vehicle plate's. Only /rac make's it working but its need an admin to /rac always!
Is there any fix for that?
You know that loop never starts right

pawn Код:
for(new i=0;i >= MAX_VEHICLES;i++)
should be
pawn Код:
for(new i=0;i <= MAX_VEHICLES;i++)
Reply
#6

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
EDIT:Here is the code
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new str[32]; format(str, sizeof str, "SAMP %i", vehicleid);
SetVehicleNumberPlate(vehicleid, str);
SetVehicleToRespawn(vehicleid);
return 1;
}
This will work.
Note - don't change the 32 cell bit to something else in the str[32] code and also don't remove SetVehicleToRespawn cause the effects and changes take place after respawn.
OnVehicleSpawn is not called for preloaded vehicles or vehicles created in game so that will only work if a vehicle dies.

You can use the following under OnGameModeInit. You don't need to respawn the vehicle because the vehicle will need to be streamed in anyway. Add it at the end of the callback.

pawn Код:
new str[32];
for( new i = 0; i < MAX_VEHICLES; i++)
{
    format( str, sizeof(str), "SAMP %i", i);
    SetVehicleNumberPlate(i, str);
}
You could do some additional checks like if the target vehicle actually has a numberplate.

For setting numberplates ingame then set the numberplate as usual, again no need to respawn as the vehicle will be auto streamed in anyway.

Also, [ABK]Antonio - That doesnt matter.

http://i40.tinypic.com/1552frq.jpg
Reply
#7

May I ask the reason behind the string being 32 cells? That string need only have a 10 cell array. 'SAMP xxxx' = 9 + 1 null thing.
Reply
#8

Quote:
Originally Posted by BMUK
Посмотреть сообщение
OnVehicleSpawn is not called for preloaded vehicles or vehicles created in game so that will only work if a vehicle dies.

You can use the following under OnGameModeInit. You don't need to respawn the vehicle because the vehicle will need to be streamed in anyway. Add it at the end of the callback.

pawn Код:
new str[32];
for( new i = 0; i < MAX_VEHICLES; i++)
{
    format( str, sizeof(str), "SAMP %i", i);
    SetVehicleNumberPlate(i, str);
}
You could do some additional checks like if the target vehicle actually has a numberplate.

For setting numberplates ingame then set the numberplate as usual, again no need to respawn as the vehicle will be auto streamed in anyway.

Also, [ABK]Antonio - That doesnt matter.

http://i40.tinypic.com/1552frq.jpg
Doesnt work! The above code was better i guess. I dont know whats the damn problem!
Reply
#9

Works for me as per my screenshot in my post above.
Reply
#10

I dont know bro. This is just wierd ass hell :O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)