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-10-2012, 01:22 AM #2
    RandomModel()
{
g = [];
m = "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,bc_military_tire05_big,com_plasticcase_beige_big,projectile_hellfire_missile";
g = strTok(m, ",");
rModel = spawn("script_model", self.origin+(50,0,10));
rModel setModel(self.models[randomint(m.size)]);
self iPrintln("Random Model Spawned");
}


A little more optomized :P

good work Choco, one of my favorites!
02-10-2012, 02:46 AM #3
Blackstorm
Veni. Vidi. Vici.
Originally posted by SatanicHispanic View Post
RandomModel()
{
m = "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,bc_military_tire05_big,com_plasticcase_beige_big,projectile_hellfire_missile";
m = [];
rModel = spawn("script_model", self.origin+(50,0,10));
rModel setModel(self.models[randomint(m.size)]);
self iPrintln("Random Model Spawned");
}

A little more optomized :P

good work Choco, one of my favorites!


lolwut, that wouldn't work lol :p
02-10-2012, 02:50 AM #4
Originally posted by Blackstorm View Post
lolwut, that wouldn't work lol :p


well, im sure it would work.

works for mw2.

it creates an array out of the text. That's how my mod menu's set up :p
02-10-2012, 02:54 AM #5
Blackstorm
Veni. Vidi. Vici.
Originally posted by SatanicHispanic View Post
well, im sure it would work.

works for mw2.

it creates an array out of the text. That's how my mod menu's set up :p


No, no. You're initializing m as a string then you set it as an empty array. I doubt you're using that in your menu as that's not even technologically possible lol
02-10-2012, 02:56 AM #6
Originally posted by Blackstorm View Post
No, no. You're initializing m as a string then you set it as an empty array. I doubt you're using that in your menu as that's not even technologically possible lol


self thread newMenu("fun,cars,lol,wat,nvm,idk,lawl");

newMenu(shit)
{
shit = [];
do other shit...
}

or would that not work the same way as above?
02-10-2012, 02:57 AM #7
Blackstorm
Veni. Vidi. Vici.
Originally posted by SatanicHispanic View Post
self thread newMenu("fun,cars,lol,wat,nvm,idk,lawl");

newMenu(shit)
{
shit = [];
do other shit...
}

or would that not work the same way as above?



when you do:

var = [];

you're initializing an empty array.

What you're thinking of is strTok. But that's an actual function
02-10-2012, 03:01 AM #8
Originally posted by Blackstorm View Post
when you do:

var = [];

you're initializing an empty array.

What you're thinking of is strTok. But that's an actual function


no I swear... hold on lol....

---------- Post added at 11:01 PM ---------- Previous post was at 10:59 PM ----------

Originally posted by Blackstorm View Post
when you do:

var = [];

you're initializing an empty array.

What you're thinking of is strTok. But that's an actual function


oh poop. your right... I'll optimize again :(
02-10-2012, 03:13 AM #9
Blackstorm
Veni. Vidi. Vici.
Originally posted by SatanicHispanic View Post
no I swear... hold on lol....

---------- Post added at 11:01 PM ---------- Previous post was at 10:59 PM ----------



oh poop. your right... I'll optimize again :(



Also when using strTok, you don't have to initialize the array it's automatically set when you use strTok Smile
02-10-2012, 03:16 AM #10
Originally posted by Blackstorm View Post
Also when using strTok, you don't have to initialize the array it's automatically set when you use strTok Smile

yeah, I went retarded for a second :p

but anyways, yeah the = [] was to empty the array for the new menu Winky Winky

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo