SetVehicleParamsEx at OnVehicleSpawn
#1

I have a problem with this:

public OnVehicleSpawn(vehicleid)
{
SetVehicleParamsEx(vehicleid,...............);
return 1;
}

Vehicle parameters won't work with this callback, whats the problem?
Reply
#2

If I'm not wrong, first you need to GetVehicleParamsEx and then try using Set.
Reply
#3

Well it depends on when you want some params set. You should use GetVehicleParamsEx first, then set. If you are wanting some params set when you first create a vehicle (say in OnGameModeInit) you need to do your get and set in OnGameModeInit seeing that OnVehicleSpawn does not seem to get called on newly created vehicles only when a vehicle Respawns. Not sure why the callback is named as such, would make more sense calling it OnVehicleRespawn.
Reply
#4

Quote:
Originally Posted by Audiophr3ak
Посмотреть сообщение
I have a problem with this:

public OnVehicleSpawn(vehicleid)
{
SetVehicleParamsEx(vehicleid,...............);
return 1;
}

Vehicle parameters won't work with this callback, whats the problem?
Try to use timer.
Reply
#5

Quote:
Originally Posted by =WoR=Varth
Посмотреть сообщение
Try to use timer.
Why? I use SetVehicleParamsEx all the time in OnVehicleSpawn it works fine no need for a timer just to understand that the callback only works for vehicles respawning.
Reply
#6

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx

You have to get the params before setting them.
Reply
#7

Weird... Im using SetVehicleToRespawn after CreateVehicle and also using GetVehicleParamsEx first but still won't work... -_-

public OnVehicleSpawn(vehicleid)
{
ChangeVehicleColor(vehicleid, vInfo[vehicleid][vC1], vInfo[vehicleid][vC2]);
if(vInfo[vehicleid][mod1] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod1]);}
if(vInfo[vehicleid][mod2] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod2]);}
if(vInfo[vehicleid][mod3] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod3]);}
if(vInfo[vehicleid][mod4] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod4]);}
if(vInfo[vehicleid][mod5] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod5]);}
if(vInfo[vehicleid][mod6] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod6]);}
if(vInfo[vehicleid][mod7] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod7]);}
if(vInfo[vehicleid][mod8] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod8]);}
if(vInfo[vehicleid][mod9] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod9]);}
if(vInfo[vehicleid][mod10] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod10]);}
if(vInfo[vehicleid][mod11] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod11]);}
if(vInfo[vehicleid][mod12] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod12]);}
if(vInfo[vehicleid][mod13] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod13]);}
if(vInfo[vehicleid][mod14] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod14]);}
if(vInfo[vehicleid][mod15] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod15]);}
if(vInfo[vehicleid][mod16] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod16]);}
if(vInfo[vehicleid][mod17] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod17]);}
if(vInfo[vehicleid][vPJ] != -1) {ChangeVehiclePaintjob(vehicleid, vInfo[vehicleid][vPJ]);}
if(vInfo[vehicleid][vCond] == 0) {SetVehicleVirtualWorld(vehicleid, 10);}

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
return 1;
}

BTW im also using ManualVehicleEngine at OnGameModeInit
Reply
#8

Post your whole code then.
Which param are you setting?
I ask that because you could setting doors to 1, and expecting the doors to get opened.
Reply
#9

And also i had this problem at 0.3c version. This shi' don't wanna work after vehicle respawns too. It works only when im controlling em with commands.
Reply
#10

Quote:
Originally Posted by Audiophr3ak
Посмотреть сообщение
Weird... Im using SetVehicleToRespawn after CreateVehicle and also using GetVehicleParamsEx first but still won't work... -_-

public OnVehicleSpawn(vehicleid)
{
ChangeVehicleColor(vehicleid, vInfo[vehicleid][vC1], vInfo[vehicleid][vC2]);
if(vInfo[vehicleid][mod1] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod1]);}
if(vInfo[vehicleid][mod2] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod2]);}
if(vInfo[vehicleid][mod3] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod3]);}
if(vInfo[vehicleid][mod4] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod4]);}
if(vInfo[vehicleid][mod5] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod5]);}
if(vInfo[vehicleid][mod6] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod6]);}
if(vInfo[vehicleid][mod7] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod7]);}
if(vInfo[vehicleid][mod8] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod8]);}
if(vInfo[vehicleid][mod9] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod9]);}
if(vInfo[vehicleid][mod10] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod10]);}
if(vInfo[vehicleid][mod11] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod11]);}
if(vInfo[vehicleid][mod12] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod12]);}
if(vInfo[vehicleid][mod13] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod13]);}
if(vInfo[vehicleid][mod14] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod14]);}
if(vInfo[vehicleid][mod15] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod15]);}
if(vInfo[vehicleid][mod16] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod16]);}
if(vInfo[vehicleid][mod17] != 0) {AddVehicleComponent(vehicleid, vInfo[vehicleid][mod17]);}
if(vInfo[vehicleid][vPJ] != -1) {ChangeVehiclePaintjob(vehicleid, vInfo[vehicleid][vPJ]);}
if(vInfo[vehicleid][vCond] == 0) {SetVehicleVirtualWorld(vehicleid, 10);}

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
return 1;
}

BTW im also using ManualVehicleEngine at OnGameModeInit
Quote:
Originally Posted by Audiophr3ak
Посмотреть сообщение
And also i had this problem at 0.3c version. This shi' don't wanna work after vehicle respawns too. It works only when im controlling em with commands.
Why are you setting them all to 0?

From a_vehicles.inc
pawn Код:
#define VEHICLE_PARAMS_UNSET    -1
#define VEHICLE_PARAMS_OFF      0
#define VEHICLE_PARAMS_ON       1
When you create a vehicle params are UNSET you are setting them to 0 or OFF what are you expecting to happen?
Maybe try setting something to 1
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)