讓BOT也能使用武器菜單選槍

Home Home
引用 | 編輯 s091140
2014-04-18 10:56
樓主
推文 x0


new g_czbot

RegisterHam(Ham_Spawn, "player", "Spawn_post", 1)




public client_putinserver(id)                                 // 讓BOT也能讀到Spawn_post
{
      new classname[32]
      pev(id, pev_classname, classname, 31)
     
      if (!equal(classname, "player") && !g_czbot)
      {
            set_task(0.1, "registerham_from_czbot", id)
            g_czbot = 1
      }
}
public registerham_from_czbot(id)
{
      RegisterHamFromEntity(Ham_Spawn, id, "Spawn_post", 1)
      if (is_user_alive(id)) Spawn_post(id)
}





public Spawn_post(id)  
{   
      
    if(is_user_bot(id))              //如果玩家是BOT
    { 
        strip_user_weapons(id)                   //扒光他
        give_item(id, "weapon_knife")         //給刀
        random_weapon(id)                         //隨機主槍
        random_weapon2(id)                       //隨機小槍
    }  
   
    return PLUGIN_HANDLED
}



隨機主槍部分

public random_weapon(id)
{

 if(!is_user_alive(id))
 return

  if(!is_user_bot(id))
  return

 new num = random_num(0,2)    //隨機抽0至2

        if(num == 0){                        //抽中0就給ak47
 give_item(id, "weapon_ak47")
 cs_set_user_bpammo(id, CSW_AK47, 270)
        }

        if(num == 1){                        //抽中1就給galil
 give_item(id, "weapon_galil")
 cs_set_user_bpammo(id, CSW_GALIL, 270)
        }
       
        if(num == 2){                        //抽中2就給awp
 give_item(id, "weapon_awp")
 cs_set_user_bpammo(id, CSW_AWP, 60)
        }
            
}

隨機小槍部分如此類推

public random_weapon2(id)
{

 if(!is_user_alive(id))
 return

  if(!is_user_bot(id))
  return

 new num = random_num(0,2)

        if(num == 0){
 give_item(id, "weapon_usp")
 cs_set_user_bpammo(id, CSW_USP, 270)
        }

        if(num == 1){
 give_item(id, "weapon_glock18")
 cs_set_user_bpammo(id, CSW_GLOCK18, 270)
        }
       
        if(num == 2){
 give_item(id, "weapon_elite")
 cs_set_user_bpammo(id, CSW_ELITE, 270)
        }
 
}

獻花 x1
引用 | 編輯 zxzx45248
2014-04-21 18:46
1樓
  
原來隨機的寫法是這樣的啊,
謝謝您的教導,
最近一次學到了好多~

獻花 x0
引用 | 編輯 studard1521
2014-05-13 15:52
2樓
  
这么好的东西没人赞呢

獻花 x0
引用 | 編輯 s091140
2014-05-14 18:37
3樓
  
下面是引用 studard1521 於 2014-05-13 15:52 發表的 Re:让BOT也能使用武器菜单选枪: 到引言文
这么好的东西没人赞呢
說完你也沒讚我

獻花 x1
引用 | 編輯 cokegtal
2014-05-20 10:18
4樓
  
防止幸存者采取了一枚手榴弹伤害

獻花 x0
引用 | 編輯 dw312382354
2014-06-20 16:25
5樓
  
怎么让bot购买自己添加的枪啊?比如金蛇剑。这些不是经典武器。

獻花 x0
引用 | 編輯 飆瘋阿翰
2014-06-22 09:29
6樓
  
謝謝大大的指導
真的是受益良多!!

獻花 x0
引用 | 編輯 s091140
2014-06-27 14:32
7樓
  
下面是引用 dw312382354 於 2014-06-20 16:25 發表的 : 到引言文
怎么让bot购买自己添加的枪啊?比如金蛇剑。这些不是经典武器。
加入inc

獻花 x0
引用 | 編輯 q5288849
2015-07-15 05:55
8樓
  
的萨达是大时代

獻花 x0
引用 | 編輯 陳冠冠
2023-12-27 14:30
9樓
  
每次看到BOT買槍 都亂買 很好笑 表情

獻花 x0