Random Weapon Help?
#1
Hello all, I am in the process of creating a mod called Shotgun Battle. I want the players to start out with a different shotgun each time. But whenever I use my mod and test it in combat training, it doesn't give me, (or the bots) any weapon at all. Here are the essential parts of my code:
Code:
onPlayerSpawned() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); self thread doSpawnStuff(); if(!isdefined(self.hud_rankscroreupdate)) { self.hud_rankscroreupdate = NewScoreHudElem(self); self.hud_rankscroreupdate.horzAlign = "center"; self.hud_rankscroreupdate.vertAlign = "middle"; self.hud_rankscroreupdate.alignX = "center"; self.hud_rankscroreupdate.alignY = "middle"; self.hud_rankscroreupdate.x = 0; if( self IsSplitscreen() ) self.hud_rankscroreupdate.y = -15; else self.hud_rankscroreupdate.y = -60; self.hud_rankscroreupdate.font = "default"; self.hud_rankscroreupdate.fontscale = 2.0; self.hud_rankscroreupdate.archived = false; self.hud_rankscroreupdate.color = (0.3,0.3,0.3); self.hud_rankscroreupdate.alpha = 0; self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit(); self.hud_rankscroreupdate.overrridewhenindemo = true; } } } doSpawnStuff() { self takeAllWeapons(); self clearPerks(); self setPerk( "specialty_Lightweight" ); self setPerk( "specialty_sleightofhand" ); self setPerk( "specialty_unlimitedsprint" ); self thread giveRandomWeapon(); } giveRandomWeapon() { weaponList = []; weaponList[weaponList.size] = "spas12_mp"; weaponList[weaponList.size] = "olympia_mp"; weaponList[weaponList.size] = "stakeout_mp"; weaponList[weaponList.size] = "hs10_mp"; weapon = weaponList[randomInt( weaponList.size )]; self giveWeapon(weaponList); self switchToWeapon(weaponList); }

If all else fails, I have attached the .gsc file to this post. Please help! Big Grin



Attached Files
.rar   Random Weapon Help.rar (Size: 5.57 KB / Downloads: 22)
[Image: mca.png]
Add me on steam! otterm
Reply

#2
1.
Stakeout - ithaca_mp
Olympia - rottweil72_mp

2.
Check the code where you copied this from.
Reply

#3
Change:

PHP Code:
weapon = weaponList[randomInt( weaponList.size )]; self giveWeapon(weaponList); self switchToWeapon(weaponList);

to:

PHP Code:
weapon = weaponList[randomInt( weaponList.size )]; self giveWeapon(weapon); self switchToWeapon(weapon);

Before, you were giving the player the weapons array, not the weapon you got from the array.
Reply

#4
soething like:

Code:
self.trololo = RandomInt( -number of weapon amount - 1(because of 0)) switch(self.trololo) { case 0: bla bla case 1: bla bla

and then put that function on onplayerspawned. then they get every spawn a diffrent weapon : )
Reply

#5
Thanks Guys! You solved it! Big Grin
[Image: mca.png]
Add me on steam! otterm
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] [SOURCE] Random Weapons. [HARD] Tony. 1 6,146 11-08-2013, 11:11
Last Post: Nekochan
  Help source random weapons [HARD] Tony. 4 6,552 11-08-2013, 05:25
Last Post: [HARD] Tony.
Question Help Mw2 weapon skin question FroxIVx4 1 3,873 10-13-2013, 16:54
Last Post: hmann
Question Help Weapon Name iRoNinja 8 8,812 10-08-2013, 08:31
Last Post: iRoNinja
  Mw2 weapon porting? Cuddlyedits 3 6,515 09-15-2013, 16:43
Last Post: DidUknowiPwn
  Help choose 2 random players?(1 each team) 26hz 6 6,279 09-12-2013, 17:32
Last Post: Yamato
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 44,646 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
Exclamation [Request] Random Weapon At Spawn Scripts18 3 6,796 07-27-2013, 23:53
Last Post: DidUknowiPwn
  Help Receiving a random primary & secondary DidUknowiPwn 5 6,024 07-22-2013, 09:47
Last Post: Yamato
  Help Mw2 weapon skin question FroxIVx4 1 4,082 07-06-2013, 19:22
Last Post: surtek

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.