PDA

View Full Version : OnVehicleSpawn


CaTaLinU
25/08/2012, 06:56 AM
I have added some tunned cars on my gm
on public OnVehicleSpawn(vehicleid)
its defined
if(vehicleid == tunned1){
ChangeVehiclePaintjob(tunned1,0); // paint job
AddVehicleComponent(tunned1, 1033); // roof
AddVehicleComponent(tunned1, 1010); // nos
AddVehicleComponent(tunned1, 1080); // rim
AddVehicleComponent(tunned1, 1029); // exhaust
AddVehicleComponent(tunned1, 1026); // side
AddVehicleComponent(tunned1, 1170); // front
AddVehicleComponent(tunned1, 1140); // rear
AddVehicleComponent(tunned1, 1139); // Spoiler
}
if(vehicleid == tunned2){
ChangeVehiclePaintjob(tunned2,0); // paint job
AddVehicleComponent(tunned2, 1035); // roof
AddVehicleComponent(tunned2, 1010); // nos
AddVehicleComponent(tunned2, 1080); // rim
AddVehicleComponent(tunned2, 1037); // exhaust
AddVehicleComponent(tunned2, 1039); // side
AddVehicleComponent(tunned2, 1172); // front
AddVehicleComponent(tunned2, 1148); // back
AddVehicleComponent(tunned2, 1146); // Spoiler
}
and etc ...


but on server i need to use first /rac command (respawn all cars) then all the tunning will be loaded on cars


same with engine system, i have defined on public OnVehicleSpawn(vehicleid) to be engine off
but if i enter a car it is on, if i use /rac command (respawn all cars) then all its ok


can someone help me to fix this ?


OnVehicleSpawn - i have deleted engine system , here are only tunned cars
public OnVehicleSpawn(vehicleid)
{
if(vehicleid == tunned1){
ChangeVehiclePaintjob(tunned1,0); // paint job
AddVehicleComponent(tunned1, 1033); // roof
AddVehicleComponent(tunned1, 1010); // nos
AddVehicleComponent(tunned1, 1080); // rim
AddVehicleComponent(tunned1, 1029); // exhaust
AddVehicleComponent(tunned1, 1026); // side
AddVehicleComponent(tunned1, 1170); // front
AddVehicleComponent(tunned1, 1140); // rear
AddVehicleComponent(tunned1, 1139); // Spoiler
}
if(vehicleid == tunned2){
ChangeVehiclePaintjob(tunned2,0); // paint job
AddVehicleComponent(tunned2, 1035); // roof
AddVehicleComponent(tunned2, 1010); // nos
AddVehicleComponent(tunned2, 1080); // rim
AddVehicleComponent(tunned2, 1037); // exhaust
AddVehicleComponent(tunned2, 1039); // side
AddVehicleComponent(tunned2, 1172); // front
AddVehicleComponent(tunned2, 1148); // back
AddVehicleComponent(tunned2, 1146); // Spoiler
}
if(vehicleid == tunned3){
ChangeVehiclePaintjob(tunned3,0); // paint job
AddVehicleComponent(tunned3, 1068); // roof
AddVehicleComponent(tunned3, 1010); // nos
AddVehicleComponent(tunned3, 1080); // rim
AddVehicleComponent(tunned3, 1066); // exhaust
AddVehicleComponent(tunned3, 1070); // side
AddVehicleComponent(tunned3, 1173); // front
AddVehicleComponent(tunned3, 1161); // back
AddVehicleComponent(tunned3, 1158); // Spoiler
}
if(vehicleid == tunned4){
ChangeVehiclePaintjob(tunned4,0); // paint job
AddVehicleComponent(tunned4, 1053); // roof
AddVehicleComponent(tunned4, 1010); // nos
AddVehicleComponent(tunned4, 1080); // rim
AddVehicleComponent(tunned4, 1045); // exhaust
AddVehicleComponent(tunned4, 1048); // side
AddVehicleComponent(tunned4, 1152); // front
AddVehicleComponent(tunned4, 1151); // back
AddVehicleComponent(tunned4, 1050); // Spoiler
}
if(vehicleid == tunned5){
ChangeVehiclePaintjob(tunned5,0); // paint job
AddVehicleComponent(tunned5, 1061); // roof
AddVehicleComponent(tunned5, 1010); // nos
AddVehicleComponent(tunned5, 1080); // rim
AddVehicleComponent(tunned5, 1059); // exhaust
AddVehicleComponent(tunned5, 1057); // side
AddVehicleComponent(tunned5, 1156); // front
AddVehicleComponent(tunned5, 1157); // back
AddVehicleComponent(tunned5, 1060); // Spoiler
}
if(vehicleid == tunned6){
ChangeVehiclePaintjob(tunned6,0); // paint job
AddVehicleComponent(tunned6, 1091); // roof
AddVehicleComponent(tunned6, 1010); // nos
AddVehicleComponent(tunned6, 1080); // rim
AddVehicleComponent(tunned6, 1089); // exhaust
AddVehicleComponent(tunned6, 1057); // side
AddVehicleComponent(tunned6, 1165); // front
AddVehicleComponent(tunned6, 1167); // back
AddVehicleComponent(tunned6, 1163); // Spoiler
}
}

[MM]RoXoR[FS]
25/08/2012, 07:10 AM
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == tunned1 || vehicleid == tunned2 )//And So On
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}

CaTaLinU
25/08/2012, 07:12 AM
You don't understand me....

On GameModeInit or on PlayerConnect or on something else
how can be set that OnVehicleSpawn to be loaded automaticaly

not manual by /rac command ?

Universal
25/08/2012, 07:17 AM
Oh you mean that they auto-respawn when created? If I get it right, then you should add a custom stock function like this:


stock My_CreateVehicle(modelid, Float: x, Float: y, Float: z, Float: a, color1, color2, respawn_time)
{
new vehicleid = CreateVehicle(modelid, x, y, z, a, color1, color2, respawn_time);
// You can add your things here...
// ex.: vehicleEngine[vehicleid] = false;
SetVehicleToRespawn(vehicleid);
return vehicleid;
}

And from now on you should use My_CreateVehicle, instead of the CreateVehicle.

CaTaLinU
25/08/2012, 07:20 AM
solved with car tuning


but with engine ?

i need to use /rac first te set engine off to all vehicles

if i don't use this the engine is on to all vehicles ....


public OnVehicleSpawn(vehicleid)
{
if(IsABike(vehicleid))
{
engineOn[vehicleid] = true;
new enginem, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid,enginem, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
else
{
engineOn[vehicleid] = false;
new enginem, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid,enginem, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}


that is my new OnVehicleSpawn



or i need to add the engine script from onvehiclespawn to ongamemodeinit ?

[MM]RoXoR[FS]
25/08/2012, 07:25 AM
Try to replace this

SetVehicleParamsEx(vehicleid,false, lights, alarm, doors, bonnet, boot, objective);

Also, if you use my command, server will turn off the engine everytime a player enter's the tuned cars.

CaTaLinU
25/08/2012, 07:33 AM
ok
thx a lot :D