SetVehicleNumberPlate
#1

Hello guys,

today I updated my Server to 0.3c RC5. Now I want to script for each faction car an number plate but I dont know how. I know, that I need to use SetVehicleNumberPlate(vehicle, "SAMP4EVER");
My problem is: how can I bind this parameter into the faction cars?

E. g.:
The police cars are definied with "CopCar". Like:
forward IsACopCar;
..other things
new CopCar[30];
...other things
CopCar = CreateVehicle(596,.......);

There are 30 cars for the cops in the script. On these 30 cars I want to add the number plate "Polizei" but I don't know how. I hope anybody can help me.

Regards, Thomas
Reply
#2

for(new i; i<=CopCar[30]; i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
}
Reply
#3

Thanks for reply. I put it in this function:

public IsACopCar(carid)
{
for(new i = 0; i < sizeof(CopCar); i++)
{
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
}
if(carid == CopCar[i])
{
return 1;
}
}
return 0;
}

But it doesn't works.

//edit 1: Deleted [pwn] -> Don't know the real Pawn-BBCodes :P
Reply
#4

pawn Код:
public IsACopCar(carid)
{
if(carid == CopCar[i])
{
for(new i = 0; i < sizeof(CopCar); i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
}
return 1;
}
return 0;
}
Sorry for crappy indentation :P
Reply
#5

Respawn the cars after SetVehicleNumberPlate, to make it work...
Reply
#6

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
pawn Код:
public IsACopCar(carid)
{
if(carid == CopCar[i])
{
for(new i = 0; i < sizeof(CopCar); i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
}
return 1;
}
return 0;
}
Sorry for crappy indentation :P
if statement should be IN the loop, fixed indentation too.
pawn Код:
public OnGameModeInit()
{
    //at the bottom of your callback, AFTER you create the police cars
    for(new i = 0; i < sizeof(CopCar); i++)
    {
        SetVehicleNumberPlate(CopCar[i], "Polizei");
        SetVehicleToRespawn(CopCar[i]);
    }
    return 1;
}
EDIT: This should be ok now, idk why the code was in "IsACopCar"
Reply
#7

ThomasTailor93 You must put this OnGameModeInit, after the procedure for creating vehicles:
pawn Код:
for(new i = 0; i < sizeof(CopCar); i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
SetVehicleToRespawn(CopCar[i]);
}
Reply
#8

It doesn't works
Reply
#9

Quote:
Originally Posted by toneysix
Посмотреть сообщение
ThomasTailor93 You must put this OnGameModeInit, after the procedure for creating vehicles:
pawn Код:
for(new i = 0; i < sizeof(CopCar); i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
SetVehicleToRespawn(CopCar[i]);
}
SetVehicleToRespawn(CopCar[i]); to use when the vehicle has already spawned. In OnGameModeInit do not need
Reply
#10

Oops...this answer is for the reply from Victious^^ I will try this of toneysix
Reply
#11

CrunkBankS Learning to read, as i said "after the procedure for creating vehicles".
Reply
#12

Дhm it doesn't work...I have respawned the cars with an command but nothing happens. The number plate is XYZR 000
Reply
#13

Oh, ok, after the third respawn it works. Thank you all
Reply
#14

Ok, i can only assume that the vehicles are not ready yet (was not created).
And now:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    static once = 0;
    if(!(once) && (IsACopCar(vehicleid)))
    {
          once = 1;
          SetVehicleNumberPlate(vehicleid, "Polizei");
          SetVehicleToRespawn(vehicleid);
    }
     return true;
}
Reply
#15

It was my fault. I put it wrong...I have overread, that I need to put it down to the CreateVehicle procedure...now it works fine. Thank you all for help
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)