BillyTheKid I do not know if you are working on this plugin anymore or not but knifesonly I think should be knivesonly. And the way you programmed the plugin it did not check for the admin access for the cvars so anyone could turn it on and off. Also v3x and teame06 coded a new way so it would not have to drop the weapons all over the ground. So if you do update it to this code give them credit.
Code:
/*********************************************************************
AMX Mod Script
Created by BillyTheKid
Test it first @ 69.31.7.140:27016
Knives Only
Version 0.7
Email = admin@madtechview
Commands -
amx_knivesonly <1|0> Default off
1 = on
0 = off
Client Command -
say /voteknivesonly
Starts a vote to turn knives Only On and off...
Description - This will force users to knife only
If guns are drawn they will be dropped
BugFixes - Added Admin Level Access to the amx_knivesonly Command
and added vote Level Access for the /voteknivesonly
Added - I added a command for voting instead of /voteknivesonly
an admin can do a amx_voteknivesonly
Thanks to Zaltoa @ [email protected]
I used his code as a template to make this one
*********************************************************************/
#include <amxmodx>
#include <amxmisc>
new knifeonly = 0
new choice[2]
new voteknifesonly[] = "\yKnives Only?\w^n^n1. Yes^n2. No"
public plugin_init(){
register_plugin("Knives Only","0.1","BillyTheKid")
register_concmd("amx_knivesonly","cmdknifes_only",ADMIN_LEVEL_A,"- disable and enable knife war 1 = on 0 = off")
register_concmd("amx_voteknivesonly","cmdvoteknifes_only",ADMIN_LEVEL_A,"- Starts a vote for Knives Only")
register_concmd("say /voteknivesonly","cmdvote",ADMIN_LEVEL_A,"- Starts a vote for Knives Only")
register_menucmd(register_menuid("\yKnives Only?"),(1<<0)|(1<<1),"count_votes")
register_event("CurWeapon","knife","b","1=1")
}
public cmdknifes_only(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_CONTINUE
new arg[2]
read_argv(1,arg,1)
new cAdmin[32], cAuthid[32]
get_user_name(id, cAdmin, 31)
get_user_authid(id, cAuthid, 31)
set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)
if(equal(arg,"1")){
knifeonly = 1
client_cmd(id,"weapon_knife")
console_print(id,"Knives Only has been turned on.")
show_hudmessage(0,"Knives Only has been turned on.")
log_amx("%s<%s> has turned Knives Only on", cAdmin, cAuthid)
} else if(equal(arg,"0")){
knifeonly = 0
console_print(id,"Knives Only has been turned off.")
show_hudmessage(0,"Knives Only has been turned off.")
log_amx("%s<%s> has turned Knives Only off", cAdmin, cAuthid)
} else {
if (knifeonly==0){
console_print(id,"Usage: amx_knivesonly 1 = 0n 0 = off Currently: OFF")
}
if (knifeonly==1){
console_print(id,"Usage: amx_knivesonly 1 = 0n 0 = off Currently: ON")
}
}
return PLUGIN_CONTINUE
}
public knife(id)
{
if(knifeonly)
{
new wpID = read_data(2)
if(wpID != CSW_KNIFE && wpID != CSW_C4)
{
engclient_cmd(id, "weapon_knife")
}
}
return PLUGIN_CONTINUE
}
public cmdvote(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_CONTINUE
new Float:voting = get_cvar_float("amx_last_voting")
new cAdmin[32], cAuthid[32]
get_user_name(id, cAdmin, 31)
get_user_authid(id, cAuthid, 31)
if (voting > get_gametime()){
client_print(id,print_chat,"*A vote has already been cast.*")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
client_print(id,print_chat,"*Please wait awhile before you can vote again.*")
return PLUGIN_HANDLED
}
new menu_msg[256]
format(menu_msg,255,voteknifesonly)
new Float:votetime = get_cvar_float("amx_vote_time") + 10.0
set_cvar_float("amx_last_voting", get_gametime() + votetime )
show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))
set_task(votetime,"check_the_votes")
client_print(0,print_chat,"*Voting has started.*")
log_amx("%s<%s> started a vote for Knives Only", cAdmin, cAuthid)
choice[0]=choice[1]=0
return PLUGIN_HANDLED
}
public cmdvoteknifes_only(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_CONTINUE
new cAdmin[32], cAuthid[32]
get_user_name(id, cAdmin, 31)
get_user_authid(id, cAuthid, 31)
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()){
client_print(id,print_chat,"*A vote has already been cast.*")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
client_print(id,print_chat,"*Please wait awhile before you can vote again.*")
return PLUGIN_HANDLED
}
new menu_msg[256]
format(menu_msg,255,voteknifesonly)
new Float:votetime = get_cvar_float("amx_vote_time") + 10.0
set_cvar_float("amx_last_voting", get_gametime() + votetime )
show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))
set_task(votetime,"check_the_votes")
client_print(0,print_chat,"*Voting has started.*")
log_amx("%s<%s> started a vote for Knives Only", cAdmin, cAuthid)
choice[0]=choice[1]=0
return PLUGIN_HANDLED
}
public count_votes(id,key){
if (get_cvar_float("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
client_print(0,print_chat,"* %s voted %s", name, key ? "against Knives Only" : "for Knives Only" )
}
++choice[key]
return PLUGIN_HANDLED
}
public check_the_votes(id){
if (choice[0] > choice[1]){
server_cmd("amx_knivesonly 1")
client_print(0,print_chat,"* Votes For Knives Only Succeded (yes ^"%d^") (no ^"%d^"). *",choice[0],choice[1])
} else {
server_cmd("amx_knivesonly 0")
client_print(0,print_chat,"* Votes Against Knives Only Succeded (yes ^"%d^") (no ^"%d^"). *",choice[0],choice[1])
}
return PLUGIN_CONTINUE
}