SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
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
Re: SetVehicleNumberPlate -
CrunkBankS - 18.12.2010
for(new i; i<=CopCar[30]; i++)
{
SetVehicleNumberPlate(CopCar[i], "Polizei");
}
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
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
Re: SetVehicleNumberPlate -
WillyP - 18.12.2010
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
Re: SetVehicleNumberPlate -
Stefan_Toretto - 18.12.2010
Respawn the cars after SetVehicleNumberPlate, to make it work...
Re: SetVehicleNumberPlate -
Dark_Kostas - 18.12.2010
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"
Re: SetVehicleNumberPlate -
toneysix - 18.12.2010
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]);
}
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
It doesn't works
Re: SetVehicleNumberPlate -
CrunkBankS - 18.12.2010
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
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
Oops...this answer is for the reply from Victious^^ I will try this of toneysix
Re: SetVehicleNumberPlate -
toneysix - 18.12.2010
CrunkBankS Learning to read, as i said "after the procedure for creating vehicles".
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
Дhm it doesn't work...I have respawned the cars with an command but nothing happens. The number plate is XYZR 000
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
Oh, ok, after the third respawn it works. Thank you all
Re: SetVehicleNumberPlate -
toneysix - 18.12.2010
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;
}
AW: SetVehicleNumberPlate -
ThomasTailor93 - 18.12.2010
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