No components
#1

Hi!
I addedd this to OnVehicleSpawn:
Код:
  if(vehicleid == needsmods0) {
  AddVehicleComponent(vehicleid, 1029);
  AddVehicleComponent(vehicleid, 1169);
  AddVehicleComponent(vehicleid, 1140);
  AddVehicleComponent(vehicleid, 1033);
  AddVehicleComponent(vehicleid, 1138);
  AddVehicleComponent(vehicleid, 1031);
  AddVehicleComponent(vehicleid, 1080);
  AddVehicleComponent(vehicleid, 1086);
  AddVehicleComponent(vehicleid, 1087);
  AddVehicleComponent(vehicleid, 1010);
  }
And this in gamemodeinit:
needsmods0 = AddStaticVehicle(560,-1686.8374,1036.6555,17.2915,89.4750,0,0);

But when I go check if the car has mods... there are no mods for the car!
Why's that?
Oh and what does this mean?
new somearray[999] = {-1, ...};
The syntax...
Reply
#2

SetTimerEx
Reply
#3

Hmm, well ok, that will include adding the component even if it exists.
But maybe could start the timer OnVehicleDeath!
Does SetVehicleToRespawn(vehicleid); cycle include the OnVehicleDeath callback?
Reply
#4

Use it this way.

pawn Код:
#include <a_samp>

forward Modcar();

new needsmods0;

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Vehicle Modding by Abernethy");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Vehicle Modding by Abernethy");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
   
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
   
    needsmods0 = AddStaticVehicle(560,-1686.8374,1036.6555,17.2915,89.4750,0,0);
   
    Modcar();
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public Modcar()
{
  AddVehicleComponent(needsmods0, 1029);
  AddVehicleComponent(needsmods0, 1169);
  AddVehicleComponent(needsmods0, 1140);
  AddVehicleComponent(needsmods0, 1033);
  AddVehicleComponent(needsmods0, 1138);
  AddVehicleComponent(needsmods0, 1031);
  AddVehicleComponent(needsmods0, 1080);
  AddVehicleComponent(needsmods0, 1086);
  AddVehicleComponent(needsmods0, 1087);
  AddVehicleComponent(needsmods0, 1010);
  SetVehicleNumberPlate(needsmods0,"Abrnethy");
  return 1;
}
I compiled it, & it works fine. Enjoy.
Reply
#5

There is a bit of a problem with that.
I could use that way, but if the car dies, it won't have the mods after respawn.
Also I found that if the component is set OnGamemodeInit then afte gmx this will crash everyone's game.
I took the advice from yezizhu and used SetTimerEx.
SetTimerEx("SetComponents",13000,0,"x",needsmods0) ; //in OnGamemodeInit

And to make sure the car has mods after death:
if(vehicleid == needsmods0) {
SetTimerEx("SetComponents",3000,0,"x",vehicleid); //in OnVehicleSpawn
}

It seems that AddVehicleComponent doesn't work on the exact the same time when OnVehicleSpawn is executed.
But thanks anyway!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)