Results 1 to 7 of 7

Thread: Random weapon box

  1. #1
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts

    Random weapon box

    Hello,does someone know how to make weapon box with random weapon?

    Thanks.!

  2. #2
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    I did this:
    PHP Code:
    weaponbox()
    {
        
    spawnpoints getentarray("mp_tdm_spawn""classname");
        
    num randomint(spawnpoints.size);
        
    players getentarray("player""classname");
        
    level.weaponbox spawn("script_model"bulletTracespawnpoints[num].originspawnpoints[num].origin + (0,0,-100), falseundefined)["position"]);
        
    level.weaponbox.angles spawnpoints[num].angles;
        
    level.weaponbox setModel("xmodel/rocky_weapon_box");

        
    box_icon newHudElem();
        
    box_icon.level.weaponbox.origin[0];
        
    box_icon.level.weaponbox.origin[1];
        
    box_icon.level.weaponbox.origin[2] + 70;
        
    box_icon.alpha .9;
        
    box_icon setShader("random_item_icon"88);
        
    box_icon setwaypoint(true);

        for(;;)
        {
            
    players getentarray("player""classname");
            for(
    i=0;i<players.size;i++)
            {
                
    player players[i];
                if(
    player.sessionstate == "playing" && player.pers["team"] == "allies" && !self.delay)
                {
                    if(
    distance(player.originself.origin) < 48)
                    {
                        if(
    player useButtonPressed())
                        {
                            
    weapon spawn(weapons(), self.origin + (0,032));
                            
    weapon.angles self.angles;
                            
    weapon linkTo(self);
                            
    weapon thread weap();

                            
    self thread delay_box();
                        }
                    }
                }
            }
            
    wait 0.2;
        }
        
    box_icon destroy();
        
    level.weaponbox delete();
    }
    delay_box()
    {
        
    self.delay true;
        
    wait 4;

        if(
    isDefined(self))
            
    self.delay false;
    }

    weapons()
    {
        
    weapname "";
        
    weap randomint(22); // 22 total
        
    if(weap == 0)
            
    weapname "weapon_bar_mp";
        if(
    weap == 1)
            
    weapname "weapon_bren_mp";
        if(
    weap == 2)
            
    weapname "weapon_g43_mp";
        if(
    weap == 3)
            
    weapname "weapon_greasegun_mp";
        if(
    weap == 4)
            
    weapname "weapon_luger_mp";
        if(
    weap == 5)
            
    weapname "weapon_m1carbine_mp";
        if(
    weap == 6)
            
    weapname "weapon_m1garand_mp";
        if(
    weap == 7)
            
    weapname "weapon_mp40_mp";
        if(
    weap == 8)
            
    weapname "weapon_mp44_mp";
        if(
    weap == 9)
            
    weapname "weapon_frag_grenade_american_mp";
        if(
    weap == 10)
            
    weapname "weapon_panzerschreck_mp";
        if(
    weap == 11)
            
    weapname "weapon_pps42_mp";
        if(
    weap == 12)
            
    weapname "weapon_ppsh_mp";
        if(
    weap == 13)
            
    weapname "weapon_shotgun_mp";
        if(
    weap == 14)
            
    weapname "weapon_springfield_mp";
        if(
    weap == 15)
            
    weapname "weapon_sten_mp";
        if(
    weap == 16)
            
    weapname "weapon_svt40_mp";
        if(
    weap == 17)
            
    weapname "weapon_thompson_mp";
        if(
    weap == 18)
            
    weapname "weapon_tt30_mp";
        if(
    weap == 19)
            
    weapname "weapon_webley_mp";
        if(
    weap == 20)
            
    weapname "weapon_frag_grenade_american_mp";
        if(
    weap == 21)
            
    weapname "weapon_kar98k_mp";
        return 
    weapname;
    }

    weap()
    {
        
    self thread weap_timer();


        
    self waittill("trigger"user);
        
    self notify("weap_picked");
    }

    weap_timer()
    {
        
    notused 0;
        
    self endon("weap_picked");
        for(
    i=0;i<30;i++)
        {
            
    notused++;

            if(
    notused >= 30)
                
    self delete();
            
    wait 0.1;
        }

    This 1 isn't working!
    Last edited by kung foo man; 17th March 2014 at 15:38. Reason: This is not working! :] kung foo man: fixed color

  3. #3
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Rocky View Post
    This 1 isn't working!
    What is exactly not working? Spawning the weapon correctly? Or the delay?

    who is self? player? level?
    PHP Code:
    if(player.sessionstate == "playing" && player.pers["team"] == "allies" && !self.delay
    Please (re)read this thread: http://killtube.org/showthread.php?1...sking-for-help

    Edit: also use php bbcode instead of code. (makes it easier to read your code)
    Edit2: perhaps if explaining is too hard then make a video.
    Last edited by Mitch; 17th March 2014 at 15:18.

  4. The Following User Says Thank You to Mitch For This Useful Post:

    kung foo man (17th March 2014)

  5. #4
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    spawning box is working fine,but delay=not working. :]

  6. #5
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    player=self(i think )

  7. #6
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Rocky View Post
    spawning box is working fine,but delay=not working. :]
    Why not just replace:
    PHP Code:
    self thread delay_box(); 
    with
    PHP Code:
    wait 4
    Also remove all other self.delay related code.

    Edit: your code doesn't do anything anyway during this delay.
    Edit 2:

    Shouldn't this line:
    PHP Code:
    if(distance(player.originself.origin) < 48
    be this:
    PHP Code:
    if(distance(player.originlevel.weaponbox.origin) < 48
    i am sure self isn't the box.
    Last edited by Mitch; 17th March 2014 at 15:39.

  8. The Following User Says Thank You to Mitch For This Useful Post:

    Rocky (17th March 2014)

  9. #7
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    Thank you,Mitch! That was 1. problem..

  10. The Following User Says Thank You to Rocky For This Useful Post:

    Mitch (17th March 2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •