/*
DF_Hook Frontend
Copyright (C) 2006-2007 Ian (Juan) Cammarata
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
--------------------------------------------------------------------------------
* http://ian.cammarata.us
* 8/16/2005 3:39:25 AM
*==============================================================================
* Change Log:
* Key (+ added | - removed | c changed | f fixed | r refactored)
* v1.0.1
* r: Execute "-hook" on client when their hook is revoked.
*/
#include
#include
new hookflag[32],toggleflag[32],custompassmsg[47]="You must finish the map before you get a hook."
public client_putinserver(id){
toggleflag[id]=0
hookflag[id]=0
new ida[1]
ida[0]=id
if(get_user_flags(id)&ADMIN_SLAY)set_task(2.0,"adminhook",0,ida,1)
return PLUGIN_CONTINUE
}
public adminhook(ida[]){
new id=ida[0]
hookflag[id]=0
server_cmd("amx_givehook #%d",get_user_userid(id))
return PLUGIN_HANDLED
}
public givehook(id,level,cid){
if(cmd_access(id,level,cid,2)){
new arg[32],player,name[32]
read_argv(1,arg,31)
player=cmd_target(id,arg,8)
if(player&&hookflag[player]==0){
get_user_name(player,name,32)
new pass[32]
get_cvar_string("df_hook_password",pass, 32)
client_cmd(player,"hook_login ^"%s^"",pass)
client_print(player,print_chat,"[AMX] : You have recieved hook privileges.")
client_print(id,print_console,"[AMX] : %s - hook privileges recieved.",name)
hookflag[player]=1
}
}
return PLUGIN_HANDLED
}
public revokehook(id,level,cid){
if(cmd_access(id,level,cid,2)){
new arg[32],player,name[32]
read_argv(1,arg,31)
player=cmd_target(id,arg,8)
if(player&&hookflag[player]==1){
get_user_name(player,name,32)
client_cmd(player,"-hook")
client_cmd(player,"hook_login ^"^"")
client_print(player,print_chat,"[AMX] : You have lost hook privileges.")
client_print(id,print_console,"[AMX] : %s - hook privileges revoked.",name)
hookflag[player]=0
}
}
return PLUGIN_HANDLED
}
public banhook(id,level,cid){
if(cmd_access(id,level,cid,2)){
new arg[32],player,name[32]
read_argv(1,arg,31)
player=cmd_target(id,arg,8)
if(player){
get_user_name(player,name,32)
client_cmd(player,"hook_login ^"^"")
client_print(player,print_chat,"[AMX] : You have been banned from using hook.")
client_print(id,print_console,"[AMX] : %s - has been banned from using hook.",name)
hookflag[player]=2
}
}
return PLUGIN_HANDLED
}
public unbanhook(id,level,cid){
if(cmd_access(id,level,cid,2)){
new arg[32],player,name[32]
read_argv(1,arg,31)
player=cmd_target(id,arg,8)
if(player&&hookflag[player]==2){
get_user_name(player,name,32)
//client_cmd(player,"hook_login ^"^"")
client_print(player,print_chat,"[AMX] : You have been unbanned for hook privileges.")
client_print(id,print_console,"[AMX] : %s - has been unbanned for hook privileges.",name)
hookflag[player]=0
}
}
return PLUGIN_HANDLED
}
public phook(id){
toggleflag[id]=1
if(!hookflag[id]){
new ida[1]
ida[0]=id
set_task(0.1,"custmsg",0,ida,1)
}
return PLUGIN_HANDLED
}
public mhook(id){
toggleflag[id]=0
return PLUGIN_CONTINUE
}
public custmsg(ida[]){
client_print(ida[0],print_center,custompassmsg)
return 1
}
public tog(id){
if(toggleflag[id])client_cmd(id, "-hook")
else{
client_cmd(id, "+hook")
if(!hookflag[id])client_cmd(id, "-hook")
}
return PLUGIN_HANDLED
}
public plugin_init(){
register_plugin("DF_Hook Frontend","1.0.1","Don Juan-jello")
register_concmd("amx_givehook","givehook",ADMIN_SLAY,"")
register_concmd("amx_revokehook","revokehook",ADMIN_SLAY,"")
register_concmd("amx_banhook","banhook",ADMIN_SLAY,"")
register_concmd("amx_unbanhook","unbanhook",ADMIN_SLAY,"")
register_clcmd("togglehook","tog",0,"- Toggle hook on and off.")
register_clcmd("+hook","phook",0)
register_clcmd("-hook","mhook",0)
return PLUGIN_CONTINUE
}