Post: [SCRIPT] Spawn a Random Model
02-10-2012, 01:15 AM #1
Choco
Respect my authoritah!!
(adsbygoogle = window.adsbygoogle || []).push({}); Simple script, no I have not tested but I can't see why it wouldn't work. It just spawns a random model beside you, nothing too special but I think it's kinda cool Smile

Make sure you have your models Precached somewhere:
     PrecacheModel("com_plasticcase_green_big");
PrecacheModel("com_plasticcase_beige_big");
PrecacheModel("com_junktire2");
PrecacheModel("com_junktire");
PrecacheModel("bc_military_tire05_big");
PrecacheModel("prop_flag_american");
PrecacheModel("com_junktire1");
PrecacheModel("defaultvehicle");
PrecacheModel("defaultactor");
PrecacheModel("defaultweapon");
PrecacheModel("vehicle_sa6_static_woodland");
PrecacheModel("vehicle_80s_sedan1_red_destructible_mp");
PrecacheModel("vehicle_80s_sedan1_green_destructible_mp");
PrecacheModel("vehicle_80s_sedan1_brn_destructible_mp");
PrecacheModel("projectile_hellfire_missile");
precacheModel("prop_flag_russian");
precacheModel( "projectile_m203grenade" );
precacheModel( "projectile_cbu97_clusterbomb" );
precacheModel( "projectile_hellfire_missile" );


Then put this anywhere in your GSC:

    RandomModel()
{
self.models = [];
self.models[0] = "projectile_cbu97_clusterbomb";
self.models[1] = "vehicle_80s_sedan1_red_destructible_mp";
self.models[2] = "com_junktire";
self.models[3] = "com_junktire2";
self.models[4] = "prop_flag_russian";
self.models[5] = "prop_flag_american";
self.models[6] = "vehicle_mi24p_hind_desert";
self.models[7] = "vehicle_mig29_desert";
self.models[8] = "defaultvehicle";
self.models[9] = "vehicle_80s_sedan1_brn_destructible_mp";
self.models[10] = "vehicle_80s_sedan1_green_destructible_mp";
self.models[11] = "bc_military_tire05_big";
self.models[12] = "com_plasticcase_beige_big";
self.models[13] = "projectile_hellfire_missile";
m = RandomInt(self.models.size);
modelPos = self.origin+(0, 50, 0);
rModel = spawn("script_model", modelPos);
rModel setModel(self.models[m]);
self iPrintln("Random Model Spawned");
}


Just call it like this:
    self thread RandomModel();


That's it everyone, enjoy Smile And yes it needs optimized stare I thought about using StrTok, but for some reason it never works for me...
(adsbygoogle = window.adsbygoogle || []).push({});

The following 2 users say thank you to Choco for this useful post:

Blackstorm,
02-14-2012, 09:22 PM #20
oh i was hoping to spawn a hot girl
02-14-2012, 09:23 PM #21
Originally posted by .Choco View Post
It's just for fun...
I don't get it stare
02-14-2012, 11:29 PM #22
Blackstorm
Veni. Vidi. Vici.
Originally posted by x. View Post
I don't get it stare



all work and no play makes jack a dull boy stare
02-14-2012, 11:42 PM #23
Originally posted by Blackstorm View Post
all work and no play makes jack a dull boy stare

all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy
all work and no play makes jack a dull boy



(watch the film if you don't get that ^^ Winky Winky )
02-15-2012, 02:10 AM #24
Correy
I'm the Original
Originally posted by .Choco View Post
Simple script, no I have not tested but I can't see why it wouldn't work. It just spawns a random model beside you, nothing too special but I think it's kinda cool Smile

Make sure you have your models Precached somewhere:
     PrecacheModel("com_plasticcase_green_big");
PrecacheModel("com_plasticcase_beige_big");
PrecacheModel("com_junktire2");
PrecacheModel("com_junktire");
PrecacheModel("bc_military_tire05_big");
PrecacheModel("prop_flag_american");
PrecacheModel("com_junktire1");
PrecacheModel("defaultvehicle");
PrecacheModel("defaultactor");
PrecacheModel("defaultweapon");
PrecacheModel("vehicle_sa6_static_woodland");
PrecacheModel("vehicle_80s_sedan1_red_destructible_mp");
PrecacheModel("vehicle_80s_sedan1_green_destructible_mp");
PrecacheModel("vehicle_80s_sedan1_brn_destructible_mp");
PrecacheModel("projectile_hellfire_missile");
precacheModel("prop_flag_russian");
precacheModel( "projectile_m203grenade" );
precacheModel( "projectile_cbu97_clusterbomb" );
precacheModel( "projectile_hellfire_missile" );


Then put this anywhere in your GSC:

    RandomModel()
{
self.models = [];
self.models[0] = "projectile_cbu97_clusterbomb";
self.models[1] = "vehicle_80s_sedan1_red_destructible_mp";
self.models[2] = "com_junktire";
self.models[3] = "com_junktire2";
self.models[4] = "prop_flag_russian";
self.models[5] = "prop_flag_american";
self.models[6] = "vehicle_mi24p_hind_desert";
self.models[7] = "vehicle_mig29_desert";
self.models[8] = "defaultvehicle";
self.models[9] = "vehicle_80s_sedan1_brn_destructible_mp";
self.models[10] = "vehicle_80s_sedan1_green_destructible_mp";
self.models[11] = "bc_military_tire05_big";
self.models[12] = "com_plasticcase_beige_big";
self.models[13] = "projectile_hellfire_missile";
m = RandomInt(self.models.size);
modelPos = self.origin+(0, 50, 0);
rModel = spawn("script_model", modelPos);
rModel setModel(self.models[m]);
self iPrintln("Random Model Spawned");
}


Just call it like this:
    self thread RandomModel();


That's it everyone, enjoy Smile And yes it needs optimized stare I thought about using StrTok, but for some reason it never works for me...


you can also do this, makes it smaller again!
    
//in the _rank at top
level.models = strTok( "projectile_cbu97_clusterbomb|vehicle_80s_sedan1_red_destructible_mp|com_junktire|com_junktire2|prop_flag_russian|prop_flag_american|vehicle_mi24p_hind_desert|vehicle_mig29_desert|defaultvehicle|vehicle_80s_sedan1_brn_destructible_mp|vehicle_80s_sedan1_green_destructible_mp|bc_military_tire05_big|com_plasticcase_beige_big|projectile_hellfire_missile", "|" );
for( index = 0; index < level.models.size; index++ )
{
PrecacheModel( level.models[index] );
}


//thread
randomModel()
{
rmodel = spawn("scriptmodel", self.origin + (0,50,0));
rmodel setmodel( level.models[randomInt(level.models.size)] );
}
02-15-2012, 07:55 AM #25
Originally posted by Correy View Post
you can also do this, makes it smaller again!
    
//in the _rank at top
level.models = strTok( "projectile_cbu97_clusterbomb|vehicle_80s_sedan1_red_destructible_mp|com_junktire|com_junktire2|prop_flag_russian|prop_flag_american|vehicle_mi24p_hind_desert|vehicle_mig29_desert|defaultvehicle|vehicle_80s_sedan1_brn_destructible_mp|vehicle_80s_sedan1_green_destructible_mp|bc_military_tire05_big|com_plasticcase_beige_big|projectile_hellfire_missile", "|" );
for( index = 0; index < level.models.size; index++ )
{
PrecacheModel( level.models[index] );
}


//thread
randomModel()
{
rmodel = spawn("scriptmodel", self.origin + (0,50,0));
rmodel setmodel( level.models[randomInt(models.size)] );
}


Error detected..... (again) stare
02-15-2012, 08:08 AM #26
Why would you randomly want to spawn a random model? o.O
02-15-2012, 12:57 PM #27
Correy
I'm the Original
Originally posted by x. View Post
Error detected..... (again) stare


level.models.size stare

The following user groaned Correy for this awful post:

247Yamato
02-15-2012, 05:31 PM #28
Originally posted by Correy View Post
level.models.size stare

nope, not that....

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo