Answered Raining Trucks

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
How do you rain trucks? I tried two different scripts but both didn't work. The following script does nothing at all but it works on multiplayer using a different model obviously. Ideas?
Code:
truckRain()
{
    level endon("game_ended");

    while(true)
    {
        x = randomIntRange(-2000, 2000);
        y = randomIntRange(-2000, 2000);
        z = randomIntRange(1100, 1200);
        spawnedTruck = spawn("script_model", (x, y, z));
        spawnedTruck setModel("veh_t6_civ_movingtrk_cab_dead");
        spawnedTruck physicsLaunch();
        spawnedTruck thread deleteTruckOverTime();

        wait 0.1;
    }
}

deleteTruckOverTime()
{
    wait 6.5;
    self delete();
}
@CabCon
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
It should work... :/ Maybe try to set the Positions.
Code:
x = randomIntRange(-2000, 2000);
y = randomIntRange(-2000, 2000);
z = randomIntRange(1100, 1200);

to

Code:
getRandomPos(value,value_z)
{
if(isEmpty(value_z))
 value_z = 0;
return self.origin + (randomintrange(0-value,value),randomintrange(0-value,value),value_z);
}

and use this function like this:
Code:
truckRain()
{
    level endon("game_ended");

    while(true)
    {
        spawnedTruck = spawn("script_model", getRandomPos(200,2000));
        spawnedTruck setModel("veh_t6_civ_movingtrk_cab_dead");
        spawnedTruck physicsLaunch();
        spawnedTruck thread deleteTruckOverTime();

        wait 0.1;
    }
}

deleteTruckOverTime()
{
    wait 6.5;
    self delete();
}
 
Top