求一个回合结束后自动装好弹药的插件
就是一回合打完后,大家都把枪里的子弹装满.但是有个前提,备用子弹要足够.详细见例子
比如:
M4A1 打完一局后剩余12发,备用60发,则下回合变为剩余30发,备用42发.
M4A1 打完一局后剩余12发,备用10发,则下回合变为剩余22发,备用0发.
其他的枪也如此.
应该比较好实现.
想法来自CS:Source #include <amxmodx>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
new g_MaxBPAmmo = {
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 = {
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 = {
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 = {
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[] = {
"",
"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
new bool:g_HideGiveClips
new bool:g_FirstSpawn
new g_LastMessageID
new g_LastMessageType
new g_LastMessage
new g_LastWeapPickup
new bool:g_Spawned
new g_BoughtWeapon
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 = false
g_HideGiveClips = false
g_FirstSpawn = true
g_LastMessage = 0
g_LastWeapPickup = 0
g_Spawned = false
g_BoughtWeapon = 0
}
public client_disconnect(id)
{
g_restart_attempt = false
g_HideGiveClips = false
g_FirstSpawn = true
g_LastMessage = 0
g_LastWeapPickup = 0
g_Spawned = false
g_BoughtWeapon = 0
}
public clcmd_fullupdate()
{
return PLUGIN_HANDLED
}
public event_restart_attempt()
{
new players, num_players
get_players(players, num_players, "a")
for (new i; i < num_players; ++i)
g_restart_attempt] = true
}
public event_hud_reset(id)
{
if (g_restart_attempt) {
g_restart_attempt = false
return
}
event_player_spawn(id)
}
public event_player_spawn(id)
{
if (get_pcvar_num(pv_fa_enable) == 1) {
g_HideGiveClips = true
g_Spawned = true
}
}
public do_player_spawn(id)
{
new weap_ids, num_weaps
get_user_weapons(id, weap_ids, num_weaps)
for (new i = 0; i < num_weaps; i++) {
new weap_id = weap_ids
if (fill_weapon(id, weap_id)) {
if (g_FirstSpawn) {
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 = false
}
public event_new_round()
{
if (get_pcvar_num(pv_fa_enable) == 1) {
new players, num_players
get_players(players, num_players, "a")
for (new j = 0; j < num_players; j++) {
new id = players
new weap_ids, num_weaps
get_user_weapons(id, weap_ids, num_weaps)
for (new i = 0; i < num_weaps; i++)
if (fill_weapon(id, weap_ids))
fill_bpammo(id, weap_ids)
}
}
}
public message_ammo_pickup(msg_id, id, ent)
{
if (get_pcvar_num(pv_fa_enable) == 1) {
if (g_HideGiveClips) {
g_HideGiveClips = false
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public forward_message_begin(msg_dest, msg_type, const Float:ORIGIN, const ED)
{
if (ED < 1 || ED > 32)
return
new id = ED
if (msg_type == g_MoneyMsg && g_LastMessage == g_WeapPickupMsg)
event_weapon_buy(id, g_LastWeapPickup)
g_LastMessageID = id
g_LastMessageType = msg_type
g_LastMessage = msg_type
}
public forward_write_byte(value)
{
if (g_LastMessageType == g_WeapPickupMsg)
g_LastWeapPickup = value
}
public event_weapon_buy(id, weap_id)
{
g_BoughtWeapon = 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) {
g_Spawned = false
do_player_spawn(id)
}
if (g_BoughtWeapon != 0) {
new weap_id = g_BoughtWeapon
g_BoughtWeapon = 0
do_weapon_buy(id, weap_id)
}
}
return PLUGIN_CONTINUE
}
public bool:weapon_has_ammo(weap_id)
{
return g_AmmoName] != 0
}
public bool:fill_bpammo(id, weap_id)
{
if (get_pcvar_num(pv_fa_altclips) == 1) {
new ammo_clips = g_MaxClips
if (weapon_has_ammo(weap_id)) {
for (new i = 1; i <= ammo_clips; i++) {
g_HideGiveClips = true
give_item(id, g_AmmoName])
}
g_HideGiveClips = false
return true
}
}
else {
new ammo = g_MaxBPAmmo
if (weapon_has_ammo(weap_id)) {
cs_set_user_bpammo(id, weap_id, ammo)
g_HideGiveClips = false
return true
}
}
return false
}
public bool:fill_weapon(id, weap_id)
{
new clip_size = g_ClipSize
if (clip_size != 0) {
new weap_name
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 = false
if (ammount <= 0)
return
message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), {0,0,0}, id)
write_byte(g_AmmoType)
write_byte(ammount)
message_end()
}
public bool:fill_bpammo_show(id, weap_id)
{
new given_ammo = g_MaxBPAmmo
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
}
页:
[1]