UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[TUT] Random Spawn Weapons

broken avatar :(
Created 12 years ago
by jjbradman
0 Members and 1 Guest are viewing this topic.
2,600 views
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok this script makes bassically what the tiitle says lol
copy this code to the end of your map_name.gsc

Code Snippet
Plaintext
getweap()
{
weapArray = [];
weapArray[ weapArray.size ] = "zombie_bar";
weapArray[ weapArray.size ] = "zombie_doublebarrel";
weapArray[ weapArray.size ] = "zombie_30cal";
weapArray[ weapArray.size ] = "zombie_stg44";
weapArray[ weapArray.size ] = "m2_flamethrower_zombie";
weapArray[ weapArray.size ] = "zombie_type100_smg";
weapArray[ weapArray.size ] = "zombie_thompson";
weapArray[ weapArray.size ] = "zombie_ppsh";
weapArray[ weapArray.size ] = "zombie_mg42";
keys = GetArrayKeys( weapArray );
return weapArray[RandomInt( weapArray.size )];
}

weap_spawn()
{
rand = getweap();

players = getplayers();
for( i=0; i<players.size; i++ )
{
wait 1.5;
players[i] GiveWeapon( rand );
players[i] SwitchToWeapon( rand );
wait .01;
}
}

and add
Code Snippet
Plaintext
thread weap_spawn();
after
Code Snippet
Plaintext
maps\_zombiemode::main();
like this

Code Snippet
Plaintext
maps\_zombiemode::main();
thread weap_spawn();

ok now to make your own random weapon options just to to the
Code Snippet
Plaintext
getweap()
function and you'll see an array(list) that contains the weapons that the script will take a random choice and give it to players.
so just add that weapons you want to be choices in the same format:
Code Snippet
Plaintext
weapArray[ weapArray.size ] = "weapon_name";
i think thats all :)
Last Edit: March 01, 2014, 06:28:35 am by jjbradman
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
Code Snippet
Plaintext
players[0] EnableWeaponCycling();
players[1] EnableWeaponCycling();
players[2] EnableWeaponCycling();
players[3] EnableWeaponCycling();
}

...use for() loops. lean them, love them, become them.

Code Snippet
Plaintext
for(j=0;j<players.size;j++)
    players[j] EnableWeaponCycling();
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
that part was inside the for loop but asdfghjkl maybe you can help me trem
this code works but after you star your weapons slots get reduced from 2 to 1  :poker:
i dont know how to make it so you only start holding the random weapon and  still be able to carry another gun  :'(
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
that part was inside the for loop but asdfghjkl maybe you can help me trem
I'm aware. The code I provided is intended to go inside your for loop. You can have loops within loops...

this code works but after you star your weapons slots get reduced from 2 to 1  :poker:
i dont know how to make it so you only start holding the random weapon and  still be able to carry another gun  :'(
Don't have time to look more right now but it's probably because the stock _zombiemode_weapons functions for buying weapons don't all have checks for the player's current inventory size.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Where would we be without YaPh1ll..

http://www.zombiemodding.com/index.php?topic=14740.msg140161#msg140161

btw. the tut look's an awefull lot like one over at ZM (correct me if i'm wrong..), perhaps you could give credit to the original scripter?
Last Edit: February 28, 2014, 11:22:26 am by BluntStuffy
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
i made the code by myself o.o i looked tutorials about how to get random strings from an array in C# lol
and the mystery box code helped a lot xD

but i think i may do what yaphil said first and replace the colt too, to get 2 spawn weapons :P

 
Loading ...