|
发表于 2009-8-10 06:27:06
|
显示全部楼层
来自 中国–山东–济南
- #include <amxmodx>
- #include <cstrike>
- #include <fun>
- #include <engine>
- #include <fakemeta>
- new g_MaxBPAmmo[31] = {
- 0,
- 52, //CSW_P228
- 0,
- 90, //CSW_SCOUT
- 1, //CSW_HEGRENADE
- 32, //CSW_XM1014
- 1, //CSW_C4
- 100, //CSW_MAC10
- 90, //CSW_AUG
- 1, //CSW_SMOKEGRENADE
- 120, //CSW_ELITE
- 100, //CSW_FIVESEVEN
- 100, //CSW_UMP45
- 90, //CSW_SG550
- 90, //CSW_GALIL
- 90, //CSW_FAMAS
- 100, //CSW_USP
- 120, //CSW_GLOCK18
- 30, //CSW_AWP
- 120, //CSW_MP5NAVY
- 200, //CSW_M249
- 32, //CSW_M3
- 90, //CSW_M4A1
- 120, //CSW_TMP
- 90, //CSW_G3SG1
- 2, //CSW_FLASHBANG
- 35, //CSW_DEAGLE
- 90, //CSW_SG552
- 90, //CSW_AK47
- 0, //CSW_KNIFE
- 100 //CSW_P90
- }
- new g_MaxClips[31] = {
- 0,
- 4, //CSW_P228
- 0,
- 3, //CSW_SCOUT
- 0, //CSW_HEGRENADE
- 4, //CSW_XM1014
- 0, //CSW_C4
- 9, //CSW_MAC10
- 3, //CSW_AUG
- 0, //CSW_SMOKEGRENADE
- 4, //CSW_ELITE
- 2, //CSW_FIVESEVEN
- 9, //CSW_UMP45
- 3, //CSW_SG550
- 3, //CSW_GALIL
- 3, //CSW_FAMAS
- 9, //CSW_USP
- 4, //CSW_GLOCK18
- 3, //CSW_AWP
- 4, //CSW_MP5NAVY
- 7, //CSW_M249
- 4, //CSW_M3
- 3, //CSW_M4A1
- 4, //CSW_TMP
- 3, //CSW_G3SG1
- 0, //CSW_FLASHBANG
- 5, //CSW_DEAGLE
- 3, //CSW_SG552
- 3, //CSW_AK47
- 0, //CSW_KNIFE
- 2 //CSW_P90
- }
- new g_ClipSize[31] = {
- 0,
- 13, //CSW_P228
- 0,
- 10, //CSW_SCOUT
- 0, //CSW_HEGRENADE
- 7, //CSW_XM1014
- 0, //CSW_C4
- 30, //CSW_MAC10
- 30, //CSW_AUG
- 0, //CSW_SMOKEGRENADE
- 30, //CSW_ELITE
- 20, //CSW_FIVESEVEN
- 25, //CSW_UMP45
- 30, //CSW_SG550
- 35, //CSW_GALIL
- 25, //CSW_FAMAS
- 12, //CSW_USP
- 20, //CSW_GLOCK18
- 10, //CSW_AWP
- 30, //CSW_MP5NAVY
- 100, //CSW_M249
- 8, //CSW_M3
- 30, //CSW_M4A1
- 30, //CSW_TMP
- 20, //CSW_G3SG1
- 0, //CSW_FLASHBANG
- 7, //CSW_DEAGLE
- 30, //CSW_SG552
- 30, //CSW_AK47
- 0, //CSW_KNIFE
- 50 //CSW_P90
- }
- new g_AmmoType[31] = {
- 0,
- 9, //CSW_P228
- 0,
- 2, //CSW_SCOUT
- 12, //CSW_HEGRENADE
- 5, //CSW_XM1014
- 14, //CSW_C4
- 6, //CSW_MAC10
- 4, //CSW_AUG
- 13, //CSW_SMOKEGRENADE
- 10, //CSW_ELITE
- 7, //CSW_FIVESEVEN
- 6, //CSW_UMP45
- 4, //CSW_SG550
- 4, //CSW_GALIL
- 4, //CSW_FAMAS
- 6, //CSW_USP
- 10, //CSW_GLOCK18
- 1, //CSW_AWP
- 10, //CSW_MP5NAVY
- 3, //CSW_M249
- 5, //CSW_M3
- 4, //CSW_M4A1
- 10, //CSW_TMP
- 2, //CSW_G3SG1
- 11, //CSW_FLASHBANG
- 8, //CSW_DEAGLE
- 4, //CSW_SG552
- 2, //CSW_AK47
- 0, //CSW_KNIFE
- 7 //CSW_P90
- }
- new g_AmmoName[15][] = {
- "",
- "ammo_338magnum",
- "ammo_762nato",
- "ammo_556natobox",
- "ammo_556nato",
- "ammo_buckshot",
- "ammo_45acp",
- "ammo_57mm",
- "ammo_50ae",
- "ammo_357sig",
- "ammo_9mm",
- "",
- "",
- "",
- ""
- }
- new bool:g_restart_attempt[33]
- new bool:g_HideGiveClips[33]
- new bool:g_FirstSpawn[33]
- new g_LastMessageID
- new g_LastMessageType
- new g_LastMessage[33]
- new g_LastWeapPickup[33]
- new bool:g_Spawned[33]
- new g_BoughtWeapon[33]
- new g_WeapPickupMsg
- new g_MoneyMsg
- new pv_fa_enable
- new pv_fa_altclips
- public plugin_init()
- {
- register_plugin("Free ammo", "1.4", "asstolavista")
- register_event("ResetHUD", "event_hud_reset", "be")
- register_clcmd("fullupdate", "clcmd_fullupdate")
- register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in")
- register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
- register_message(get_user_msgid("AmmoPickup"), "message_ammo_pickup")
- g_WeapPickupMsg = get_user_msgid("WeapPickup")
- g_MoneyMsg = get_user_msgid("Money")
- register_forward(FM_MessageBegin, "forward_message_begin", 1)
- register_forward(FM_WriteByte, "forward_write_byte", 1)
- pv_fa_enable = register_cvar("fa_enable", "1")
- pv_fa_altclips = register_cvar("fa_altclips", "0")
- }
- public client_connect(id)
- {
- g_restart_attempt[id] = false
- g_HideGiveClips[id] = false
- g_FirstSpawn[id] = true
- g_LastMessage[id] = 0
- g_LastWeapPickup[id] = 0
- g_Spawned[id] = false
- g_BoughtWeapon[id] = 0
- }
- public client_disconnect(id)
- {
- g_restart_attempt[id] = false
- g_HideGiveClips[id] = false
- g_FirstSpawn[id] = true
- g_LastMessage[id] = 0
- g_LastWeapPickup[id] = 0
- g_Spawned[id] = false
- g_BoughtWeapon[id] = 0
- }
- public clcmd_fullupdate()
- {
- return PLUGIN_HANDLED
- }
- public event_restart_attempt()
- {
- new players[32], num_players
- get_players(players, num_players, "a")
- for (new i; i < num_players; ++i)
- g_restart_attempt[players[i]] = true
- }
- public event_hud_reset(id)
- {
- if (g_restart_attempt[id]) {
- g_restart_attempt[id] = false
- return
- }
- event_player_spawn(id)
- }
- public event_player_spawn(id)
- {
- if (get_pcvar_num(pv_fa_enable) == 1) {
- g_HideGiveClips[id] = true
- g_Spawned[id] = true
- }
- }
- public do_player_spawn(id)
- {
- new weap_ids[32], num_weaps
- get_user_weapons(id, weap_ids, num_weaps)
- for (new i = 0; i < num_weaps; i++) {
- new weap_id = weap_ids[i]
- if (fill_weapon(id, weap_id)) {
- if (g_FirstSpawn[id]) {
- if (get_pcvar_num(pv_fa_altclips) != 1)
- cs_set_user_bpammo(id, weap_id, 0)
- fill_bpammo_show(id, weap_id)
- }
- else
- fill_bpammo(id, weap_id)
- }
- }
- g_FirstSpawn[id] = false
- }
- public event_new_round()
- {
- if (get_pcvar_num(pv_fa_enable) == 1) {
- new players[32], num_players
- get_players(players, num_players, "a")
- for (new j = 0; j < num_players; j++) {
- new id = players[j]
- new weap_ids[32], num_weaps
- get_user_weapons(id, weap_ids, num_weaps)
- for (new i = 0; i < num_weaps; i++)
- if (fill_weapon(id, weap_ids[i]))
- fill_bpammo(id, weap_ids[i])
- }
- }
- }
- public message_ammo_pickup(msg_id, id, ent)
- {
- if (get_pcvar_num(pv_fa_enable) == 1) {
- if (g_HideGiveClips[id]) {
- g_HideGiveClips[id] = false
- return PLUGIN_HANDLED
- }
- }
- return PLUGIN_CONTINUE
- }
- public forward_message_begin(msg_dest, msg_type, const Float:ORIGIN[3], const ED)
- {
- if (ED < 1 || ED > 32)
- return
- new id = ED
- if (msg_type == g_MoneyMsg && g_LastMessage[id] == g_WeapPickupMsg)
- event_weapon_buy(id, g_LastWeapPickup[id])
- g_LastMessageID = id
- g_LastMessageType = msg_type
- g_LastMessage[id] = msg_type
- }
- public forward_write_byte(value)
- {
- if (g_LastMessageType == g_WeapPickupMsg)
- g_LastWeapPickup[g_LastMessageID] = value
- }
- public event_weapon_buy(id, weap_id)
- {
- g_BoughtWeapon[id] = weap_id
- }
- public do_weapon_buy(id, weap_id)
- {
- if (fill_weapon(id, weap_id))
- fill_bpammo_show(id, weap_id)
- }
- public client_PreThink(id)
- {
- if (get_pcvar_num(pv_fa_enable) == 1) {
- if (g_Spawned[id]) {
- g_Spawned[id] = false
- do_player_spawn(id)
- }
- if (g_BoughtWeapon[id] != 0) {
- new weap_id = g_BoughtWeapon[id]
- g_BoughtWeapon[id] = 0
- do_weapon_buy(id, weap_id)
- }
- }
- return PLUGIN_CONTINUE
- }
- public bool:weapon_has_ammo(weap_id)
- {
- return g_AmmoName[g_AmmoType[weap_id]][0] != 0
- }
- public bool:fill_bpammo(id, weap_id)
- {
- if (get_pcvar_num(pv_fa_altclips) == 1) {
- new ammo_clips = g_MaxClips[weap_id]
- if (weapon_has_ammo(weap_id)) {
- for (new i = 1; i <= ammo_clips; i++) {
- g_HideGiveClips[id] = true
- give_item(id, g_AmmoName[g_AmmoType[weap_id]])
- }
- g_HideGiveClips[id] = false
- return true
- }
- }
- else {
- new ammo = g_MaxBPAmmo[weap_id]
- if (weapon_has_ammo(weap_id)) {
- cs_set_user_bpammo(id, weap_id, ammo)
- g_HideGiveClips[id] = false
- return true
- }
- }
- return false
- }
- public bool:fill_weapon(id, weap_id)
- {
- new clip_size = g_ClipSize[weap_id]
- if (clip_size != 0) {
- new weap_name[41]
- get_weaponname(weap_id, weap_name, 40)
- new wpn = find_ent_by_owner(-1, weap_name, id)
- if (wpn != 0) {
- cs_set_weapon_ammo(wpn, clip_size)
- return true
- }
- }
- return false
- }
- public show_given_bpammo(id, weap_id, ammount)
- {
- g_HideGiveClips[id] = false
- if (ammount <= 0)
- return
- message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), {0,0,0}, id)
- write_byte(g_AmmoType[weap_id])
- write_byte(ammount)
- message_end()
- }
- public bool:fill_bpammo_show(id, weap_id)
- {
- new given_ammo = g_MaxBPAmmo[weap_id]
- if (get_pcvar_num(pv_fa_altclips) != 1 && weapon_has_ammo(weap_id))
- given_ammo -= cs_get_user_bpammo(id, weap_id)
- if (fill_bpammo(id, weap_id)) {
- show_given_bpammo(id, weap_id, given_ammo)
- return true
- }
- return false
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|