|
下列是我的代码
我做了一个c4随机奖励武器
我不知道怎么做到,手上已经有武器的..
随机奖励武器,刚好奖励你手上的武器
怎么做到不奖励你已经有的武器呢??
- #include <amxmodx>
- #include <cstrike>
- #include <engine>
- #include <csx>
- #include <fun>
- new primary_weapon[32]
- new name[32]
- new id
- new weapon[2][21]
- new ammo_type[21]
- new gBombReward = 1
- public plugin_init()
- {
- register_plugin("C4成功拆除或爆炸,随机奖励武器", "0.1", "你的人")
- register_concmd("amx_bombreward","admin_bombreward",0,"C4成功拆除或爆炸,随机奖励武器 <1 | 0 >")
- }
- public admin_bombreward(id,level,cid)
- {
- if (!(get_user_flags(id)&ADMIN_IMMUNITY)){
- client_print(id, print_console, "你没有权限执行这个参数")
- return PLUGIN_HANDLED
- }
- if (read_argc() < 2)
- {
- console_print(id,"使用方法: amx_bombreward < 1 | 0 >")
- return PLUGIN_HANDLED
- }
- new bombtarget = find_ent_by_class(-1, "func_bomb_target")
- if ( !bombtarget )
- {
- gBombReward = 0
- console_print(id,"此地图没有炸弹安装点^nC4成功拆除或爆炸,随机奖励武器 - 已关闭")
- }
- new sArg1[32]
- read_argv(1,sArg1,31)
- if (str_to_num(sArg1) == 1)
- {
- if ( bombtarget )
- {
- gBombReward = 1
- client_print(id,print_console,"[AMXX]C4成功拆除或爆炸,随机奖励武器 - 已开启.")
- client_print(0,print_chat,"[AMXX]C4成功拆除或爆炸,随机奖励武器 - 已开启.")
- }
- }
- if (str_to_num(sArg1) == 0)
- {
- if ( bombtarget )
- {
- gBombReward = 0
- client_print(id,print_console,"[AMXX]C4成功拆除或爆炸,随机奖励武器 - 已关闭.")
- client_print(0,print_chat,"[AMXX]C4成功拆除或爆炸,随机奖励武器 - 已关闭.")
- }
- }
- if ( str_to_num(sArg1) > 1 )
- {
- console_print(id,"使用方法: amx_bombreward < 1 | 0 >")
- }
- return PLUGIN_HANDLED
- }
- public bomb_explode(planter, defuser)
- {
- if (gBombReward == 0)
- {
- }
- if (gBombReward)
- {
- get_user_name(planter,name,31)
- randomize_primary(id)
- get_weaponname(primary_weapon[id], weapon[1], 20)
- give_item(planter, weapon[1])
- ammo_type = get_ammotype(primary_weapon[id])
- give_item(planter, ammo_type)
- give_item(planter, ammo_type)
- set_hudmessage(200,200,200,-1.0,0.40,0,6.0,6.0,0.5,0.15,2)
- show_hudmessage(0,"C4爆炸成功,奖励%s给予%s", weapon[1][7], name)
- client_print(id, print_chat, "[AMXX]C4爆炸成功,奖励%s给予%s", weapon[1][7], name)
- }
- }
- public bomb_defused (defuser)
- {
- if (gBombReward == 0)
- {
- }
- if (gBombReward)
- {
- get_user_name(defuser,name,31)
- randomize_primary(id)
- get_weaponname(primary_weapon[id], weapon[1], 20)
- give_item(defuser, weapon[1])
- ammo_type = get_ammotype(primary_weapon[id])
- give_item(defuser, ammo_type)
- give_item(defuser, ammo_type)
- set_hudmessage(200,200,200,-1.0,0.40,0,6.0,6.0,0.5,0.15,2)
- show_hudmessage(0,"C4成功拆除,奖励%s给予%s", weapon[1][7], name)
- client_print(id, print_chat, "[AMXX]C4成功拆除,奖励%s给予%s", weapon[1][7], name)
- }
- }
- public randomize_primary(id)
- {
- new rand = random_num(1, 18)
-
- switch(rand)
- {
- case 1: primary_weapon[id] = CSW_SCOUT
-
- case 2: primary_weapon[id] = CSW_XM1014
-
- case 3: primary_weapon[id] = CSW_MAC10
-
- case 4: primary_weapon[id] = CSW_AUG
-
- case 5: primary_weapon[id] = CSW_UMP45
-
- case 6: primary_weapon[id] = CSW_SG550
-
- case 7: primary_weapon[id] = CSW_FAMAS
-
- case 8: primary_weapon[id] = CSW_AWP
-
- case 9: primary_weapon[id] = CSW_MP5NAVY
-
- case 10: primary_weapon[id] = CSW_M249
-
- case 11: primary_weapon[id] = CSW_M3
-
- case 12: primary_weapon[id] = CSW_M4A1
-
- case 13: primary_weapon[id] = CSW_TMP
-
- case 14: primary_weapon[id] = CSW_G3SG1
-
- case 15: primary_weapon[id] = CSW_SG552
-
- case 16: primary_weapon[id] = CSW_AK47
-
- case 17: primary_weapon[id] = CSW_P90
-
- case 18: primary_weapon[id] = CSW_HEGRENADE
- }
-
- return PLUGIN_CONTINUE
- }
- stock get_ammotype(weapon)
- {
- new ammo[21]
-
- switch(weapon)
- {
- case CSW_SCOUT: ammo = "ammo_762nato"
- case CSW_XM1014: ammo = "ammo_buckshot"
- case CSW_MAC10: ammo = "ammo_45acp"
- case CSW_AUG: ammo = "ammo_556nato"
- case CSW_UMP45: ammo = "ammo_45acp"
- case CSW_SG550: ammo = "ammo_556nato"
- case CSW_FAMAS: ammo = "ammo_556nato"
- case CSW_AWP: ammo = "ammo_338magnum"
- case CSW_MP5NAVY: ammo = "ammo_9mm"
- case CSW_M249: ammo = "ammo_556natobox"
- case CSW_M3: ammo = "ammo_buckshot"
- case CSW_M4A1: ammo = "ammo_556nato"
- case CSW_TMP: ammo = "ammo_9mm"
- case CSW_G3SG1: ammo = "ammo_762nato"
- case CSW_SG552: ammo = "ammo_556nato"
- case CSW_AK47: ammo = "ammo_762nato"
- case CSW_P90: ammo = "ammo_57mm"
- }
-
- return ammo
- }
复制代码 |
|