and make it to HE only vote plugin..
i want to change the knife to HE..
but the result is my modify plugin failed..
and make client to use HE grenade only..
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <csx>
#include <fakemeta>
#include <fun>
new vote
new votes
new players[32]
new he_rounds
new he_cooldown
new show[6]
#define CHANNEL 4
#define OFFSET_PRIMARYWEAPON 116
#define NADEAMOUNT 2
public plugin_init() {
register_plugin("Vote HE Plugin", "1.0", "Rains/sabrioz")
register_cvar("amx_vote_he","1") // Turns plugin on
register_cvar("amx_vote_he_time","25.0") // How long time people can vote
register_cvar("amx_vote_he_ratio","0.5") // How many votes needed for he only
register_cvar("amx_vote_he_rounds","2") // How many rounds it will be he only
register_cvar("amx_vote_he_hud","1") // Set hudmessage on/off
register_cvar("amx_vote_he_cooldown","4") // How many rounds it will wait between he only and next vote
if (get_cvar_num("amx_vote_he") == 1)
{
register_event("ResetHUD", "hook_hud", "be")
register_event("CurWeapon", "cur_weapon", "be", "1=0", "2=29")
register_clcmd("say /heg", "he_vote")
register_clcmd("say /votehe", "he_vote")
}
}
public hook_hud(id)
{
if (get_cvar_num("amx_vote_he") == 1)
{
if (he_rounds > 0)
vote = 0
else if (he_cooldown > 0)
{
vote = 2
if (show[5] == 0)
he_cooldown -= 1
show[5] = 1
set_task(5.0, "reset_show")
}
else
vote = 1
if (vote == 0)
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "HE only for %i more rounds!", he_rounds)
}
if (show[0] == 0)
client_print(0,print_chat,"[HE] HE only for %i more rounds!", he_rounds)
show[0] = 1
if (show[5] == 0)
he_rounds -= 1
show[5] = 1
set_task(5.0, "reset_show")
cur_weapon(id)
}
else if (vote == 1)
{
set_task(get_cvar_float("amx_vote_he_time"),"check_vote")
new i
for (i=0;i<32;i++)
{
players[i] = 0
}
votes = 0
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] Write /votehe to vote for HE only!^nYou have %i seconds to vote!", get_cvar_num("amx_vote_he_time"))
}
if (show[1] == 0)
client_print(0,print_chat,"[HE] Write /votehe to vote for HE only! You have %i seconds to vote!", get_cvar_num("amx_vote_he_time"))
show[1] = 1
}
else if(vote == 2)
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] Normal play for %i more rounds!^nThen you will be able to vote again!", (he_cooldown+1))
}
if (show[2] == 0)
client_print(0,print_chat,"[HE] Normal play for %i more rounds! Then you will be able to vote again!", (he_cooldown+1))
show[2] = 1
}
}
}
public he_vote(id)
{
if (get_cvar_num("amx_vote_he") == 1)
{
if (players[id] == 1 && vote == 1)
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] You can't vote more than one time!")
}
client_print(id,print_chat,"[HE] You can't vote more than one time!")
}
else if (players[id] == 0 && vote == 1)
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] You have succesfully voted!")
}
client_print(id,print_chat,"[HE] You have succesfully voted!")
votes = votes+1
players[id] = 1
}
else
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] You can't vote!")
}
client_print(id,print_chat,"[HE] You can't vote!")
}
}
}
public check_vote(id)
{
if (get_cvar_num("amx_vote_he") == 1)
{
vote = 0
new i
new check = 0
for (i=0;i<32;i++)
{
if (is_user_connected(i))
check = check + 1
}
if (floatround(votes/get_cvar_float("amx_vote_he_ratio"))>=check)
{
he_rounds = get_cvar_num("amx_vote_he_rounds")
he_cooldown = get_cvar_num("amx_vote_he_cooldown")
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] Voting succeded!^nNext %i rounds will be HE only", get_cvar_num("amx_vote_he_rounds"))
}
if (show[3] == 0)
client_print(0,print_chat,"[HE] Voting succeded! Next %i rounds will be HE only", get_cvar_num("amx_vote_he_rounds"))
show[3] = 1
}
else
{
if (get_cvar_num("amx_vote_he_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "[HE] Voting failed, to few votes.")
}
if (show[4] == 0)
client_print(0,print_chat,"[HE] Voting failed, to few votes.")
show[4] = 1
}
}
}
public cur_weapon(id)
{
if (get_cvar_num("amx_vote_he") == 1 && he_rounds > 0 && he_rounds < get_cvar_num("amx_vote_he_rounds") || he_cooldown == get_cvar_num("amx_vote_he_cooldown"))
strip_user_weapons(id)
set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0)
{
engclient_cmd(id,"weapon_hegrenade")
}
}
public grenade_throw( id , greindex , wId )
{
if (get_cvar_num("amx_vote_he") == 1 && he_rounds > 0 && he_rounds < get_cvar_num("amx_vote_he_rounds") && wId == CSW_HEGRENADE || he_cooldown == get_cvar_num("amx_vote_he_cooldown"))
cs_set_user_bpammo( id , CSW_HEGRENADE, NADEAMOUNT);
}
public reset_show()
{
if (get_cvar_num("amx_vote_he") == 1)
{
new i
for (i=0;i<6;i++)
{
show[i] = 0
}
}
}
so hope you can fix the bug for this plugin.