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)
}
}