Код
//
// WROTEN BY RAINS ~ CODE LAST EDITED 18 may 2006 19:13
//
// Hello whoever is there and editing my code. :)
// I have some information which maybe make the editing easier for you.
// First off, the different variable/function prefixes (the SOMETHING_ that comes
// before all variables and functions).
// o_ (other) does almost always mean a integer (variable with numbers) and in some cases a bool.
// f_ (functions) is a function (I hope you know what that means ^^)
// menu_ (menu) is a menu (duuh?).
//
// If you need help, either mail me at: gtc_goku@hotmail.com or write a pm to me
// at http://www.amxmodx.com/forums/ my username is Rains.
// Please give me feedback too, both negative and positive critique are appreciated.
// (With negative I DO NOT mean "UR RETARD!!1 UR PLUGINZ DOZZNT WURK!!" and not
// "Lol, ur coding suxx" but more constructive critique.)
//
#include <amxmodx>
#include <fun>
new vote
new votes
new players[32]
new knife_rounds
new knife_cooldown
new show[6]
#define CHANNEL 4
public plugin_init() {
register_plugin("Vote Knife Plugin", "1.0", "Rains")
register_cvar("amx_vote_knife","1") // Turns plugin on
register_cvar("amx_vote_knife_time","20.0") // How long time people can vote
register_cvar("amx_vote_knife_ratio","0.5") // How many votes needed for knife only
register_cvar("amx_vote_knife_rounds","3") // How many rounds it will be knife only
register_cvar("amx_vote_knife_hud","1") // Set hudmessage on/off
register_cvar("amx_vote_knife_cooldown","3") // How many rounds it will wait between knife only and next vote
if (get_cvar_num("amx_vote_knife") == 1)
{
register_event("ResetHUD", "hook_hud", "be")
register_event("CurWeapon", "cur_weapon", "be", "1=0", "2=29")
register_clcmd("amx_kniferound", "knife_vote")//заменяешь на amx_kniferound,чтоб через консоль
}
}
public hook_hud(id,level,cid)
{
if(get_user_flags(id)&ADMIN_KICK)//если юзер админ,то он может вызвать команду hook_hud правильно
if (get_cvar_num("amx_vote_knife") == 1)
{
if (knife_rounds > 0)
vote = 0
else if (knife_cooldown > 0)
{
vote = 2
if (show[5] == 0)
knife_cooldown -= 1
show[5] = 1
set_task(5.0, "reset_show")
}
else
vote = 1
if (vote == 0)
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "Knife only for %i more rounds!", knife_rounds)
}
if (show[0] == 0)
client_print(0,print_chat,"[Knife] Knife only for %i more rounds!", knife_rounds)
show[0] = 1
if (show[5] == 0)
knife_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_knife_time"),"check_vote")
new i
for (i=0;i<32;i++)
{
players[i] = 0
}
votes = 0
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "Write /knife or /voteknife to vote for knife only!^nYou have %i seconds to vote!", get_cvar_num("amx_vote_knife_time"))
}
if (show[1] == 0)
client_print(0,print_chat,"[Knife] Write /knife to vote for knife only! You have %i seconds to vote!", get_cvar_num("amx_vote_knife_time"))
show[1] = 1
}
else if(vote == 2)
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "Normal play for %i more rounds!^nThen you will be able to vote again!", (knife_cooldown+1))
}
if (show[2] == 0)
client_print(0,print_chat,"[Knife] Normal play for %i more rounds! Then you will be able to vote again!", (knife_cooldown+1))
show[2] = 1
}
}
}
public knife_vote(id)
{
if (get_cvar_num("amx_vote_knife") == 1)
{
if (players[id] == 1 && vote == 1)
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "You can't vote more than one time!")
}
client_print(id,print_chat,"[Knife] You can't vote more than one time!")
}
else if (players[id] == 0 && vote == 1)
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "You have succesfully voted!")
}
client_print(id,print_chat,"[Knife] You have succesfully voted!")
votes = votes+1
players[id] = 1
}
else
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "You can't vote!")
}
client_print(id,print_chat,"[Knife] You can't vote!")
}
}
}
public check_vote(id)
{
if (get_cvar_num("amx_vote_knife") == 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_knife_ratio"))>=check)
{
knife_rounds = get_cvar_num("amx_vote_knife_rounds")
knife_cooldown = get_cvar_num("amx_vote_knife_cooldown")
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "Voting succeded!^nNext %i rounds will be knife only", get_cvar_num("amx_vote_knife_rounds"))
}
if (show[3] == 0)
client_print(0,print_chat,"[Knife] Voting succeded! Next %i rounds will be knife only", get_cvar_num("amx_vote_knife_rounds"))
show[3] = 1
}
else
{
if (get_cvar_num("amx_vote_knife_hud") == 1)
{
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 5.0, 0.1, 0.2, CHANNEL)
show_hudmessage(id, "Voting failed, to few votes.")
}
if (show[4] == 0)
client_print(0,print_chat,"[Knife] Voting failed, to few votes.")
show[4] = 1
}
}
}
public cur_weapon(id)
{
if (get_cvar_num("amx_vote_knife") == 1 && knife_rounds > 0 && knife_rounds < get_cvar_num("amx_vote_knife_rounds") || knife_cooldown == get_cvar_num("amx_vote_knife_cooldown"))
{
engclient_cmd(id,"weapon_knife")
}
}
public reset_show()
{
if (get_cvar_num("amx_vote_knife") == 1)
{
new i
for (i=0;i<6;i++)
{
show[i] = 0
}
}
}
Ничего сложного нету
[code]//
Ничего сложного нету
Отредактировал: Pawn?, - 15.6.2009, 20:49