Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
new bool:cuffed[33], cuffedme[33]
new havecuff[33] = 1
new bool:bound[33], bindme[33]
new havebind[33] = 1
public plugin_init() {
register_plugin("Cuff's","1.0","Mel")
register_cvar("amx_cuffallow","1")
register_cvar("amx_cuffnumber","1")
register_cvar("amx_bindnumber","1")
register_concmd("cuff","cuff")
register_concmd("bind","bind")
register_concmd("unbind","unbind")
register_concmd("uncuff","uncuff")
register_concmd("amx_cuff","amx_cuff", ADMIN_KICK, "<authid, nick or #userid>")
register_concmd("amx_uncuff","amx_uncuff", ADMIN_KICK, "<authid, nick or #userid>")
set_task(1.0, "cuffaction",23,"",0,"b")
}
public client_putinserver(id) {
cuffed[id] = false
cuffedme[id] = 0
bound[id] = false
bindme[id] = 0
havecuff[id] = get_cvar_num("amx_cuffnumber")
havebind[id] = get_cvar_num("amx_bindnumber")
return PLUGIN_CONTINUE;
}
public client_disconnect(id) {
cuffed[id] = false
cuffedme[id] = 0
return PLUGIN_CONTINUE;
}
//44
public cuff(id){
if(!(get_cvar_num("amx_cuffallow"))){
return PLUGIN_HANDLED
}
new cuffer[33], cuffee[33], tid, body
get_user_name(id,cuffer,32)
get_user_aiming(id,tid,body)
get_user_name(tid,cuffee,31)
if(havecuff[id] < 1){
return PLUGIN_HANDLED
}
new player=find_player("a",cuffee)
if (player){
havecuff[id] = havecuff[id] - 1
cuffed[tid] = true
cuffedme[tid] = cuffer[id]
client_cmd(cuffed[tid],"drop")
client_cmd(cuffed[tid],"drop")
client_cmd(cuffed[tid],"drop")
client_cmd(cuffed[tid],"weapon_00")
client_cmd(cuffed[tid],"+attack")
client_cmd(cuffed[tid],"+attack2")
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(tid, "You have been cuffed.");
}
if (!player){
client_print(id,print_chat,"[Cuff] No target found")
}
return PLUGIN_HANDLED
}
public bind(id){
if(!(get_cvar_num("amx_cuffallow"))){
return PLUGIN_HANDLED
}
new cuffer[33], cuffee[33], tid, body
get_user_name(id,cuffer,32)
if(havecuff[id] < 1){
return PLUGIN_HANDLED
}
get_user_aiming(id,tid,body)
get_user_name(tid,cuffee,31)
new player=find_player("a",cuffee)
if (player){
havebind[id] = havebind[id] - 1
bound[tid] = true
bindme[tid] = cuffer[id]
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(tid, "You have been bound.");
}
if (!player){
client_print(id,print_chat,"[Cuff] No target found")
}
return PLUGIN_HANDLED
}
public amx_cuff(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1, arg, 31)
new user = cmd_target(id, arg, 5)
if(!user)
return PLUGIN_HANDLED
new authid[16], name2[32], authid2[16], name[32]
get_user_authid(id, authid, 15)
get_user_name(id, name, 31)
get_user_authid(user, authid2, 15)
get_user_name(user, name2, 31)
if(cuffed[user] == true)
{
console_print(id, "Client ^"%s^" is already cuffed!", name2)
return PLUGIN_HANDLED
}
else
{
cuffed[user] = true
cuffedme[user] = 1
client_cmd(cuffed[user],"drop")
client_cmd(cuffed[user],"drop")
client_cmd(cuffed[user],"drop")
client_cmd(cuffed[user],"weapon_00")
client_cmd(cuffed[user],"+attack")
client_cmd(cuffed[user],"+attack2")
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(cuffed[user], "You have been cuffed.");
}
console_print(id, "Client ^"%s^" is now cuffed", name2)
return PLUGIN_HANDLED
}
public amx_uncuff(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1, arg, 31)
new user = cmd_target(id, arg, 5)
if(!user)
return PLUGIN_HANDLED
new authid[16], name2[32], authid2[16], name[32]
get_user_authid(id, authid, 15)
get_user_name(id, name, 31)
get_user_authid(user, authid2, 15)
get_user_name(user, name2, 31)
if(cuffed[user] == false)
{
console_print(id, "Client ^"%s^" is not cuffed!", name2)
return PLUGIN_HANDLED
}
else
{
cuffed[user] = false
cuffedme[user] = 0
client_cmd(cuffed[user],"-speed")
client_cmd(cuffed[user],"-attack")
client_cmd(cuffed[user],"-attack2")
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(cuffed[user], "You have been uncuffed.");
}
console_print(id, "Client ^"%s^" is now uncuffed", name2)
return PLUGIN_HANDLED
}
public uncuff(id){
if(!(get_cvar_num("amx_cuffallow"))){
return PLUGIN_HANDLED
}
new uncuffer[33], uncuffee[33], tid, body, prevcuff[33]
get_user_name(id,uncuffer,32)
get_user_aiming(id,tid,body)
get_user_name(tid,uncuffee,31)
get_user_name(id,prevcuff,31)
if(prevcuff[id] == cuffedme[tid]){
new player=find_player("a",uncuffee)
if (player){
havecuff[id] = havecuff[id] + 1
cuffed[tid] = false
cuffedme[tid] = uncuffee[tid]
client_cmd(cuffed[tid],"-attack")
client_cmd(cuffed[tid],"-attack2")
client_cmd(cuffed[tid],"-speed")
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(player, "You have been uncuffed.");
}
if (!player){
client_print(id,print_chat,"[Cuff] No target found")
}
}else{
client_print(id,print_chat,"[Cuff] You may not uncuff them")
}
return PLUGIN_HANDLED
}
public unbind(id){
if(!(get_cvar_num("amx_cuffallow"))){
return PLUGIN_HANDLED
}
new uncuffer[33], uncuffee[33], tid, body, prevbind[33]
get_user_name(id,uncuffer,32)
get_user_aiming(id,tid,body)
get_user_name(tid,uncuffee,31)
get_user_name(id,prevbind,31)
if(prevbind[id] == bindme[tid]){
new player=find_player("a",uncuffee)
if (player){
havebind[id] = havebind[id] + 1
bound[tid] = false
bindme[tid] = uncuffee[tid]
set_hudmessage(200,100,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
show_hudmessage(player, "You have been unbound.");
}
if (!player){
client_print(id,print_chat,"[Cuff] No target found")
}
}else{
client_print(id,print_chat,"[Cuff] You may not unbind them")
}
return PLUGIN_HANDLED
}
public cuffaction(){
new players[32], inum
get_players(players,inum,"a")
for(new i = 0 ;i < inum ;++i) {
if (cuffed[players[i]] == true) {
client_cmd(players[i],"drop")
client_cmd(players[i],"weapon_00")
client_cmd(players[i],"+speed")
}
if (bound[players[i]] == true) {
new tid, id, aimvec[3], length, origin[3], direction[3], moveto[3], velocity[3], vorigin[3]
get_user_name(tid,players[i],32)
get_user_name(id,bindme[i],32)
get_user_origin(id,aimvec,3)
get_user_origin(tid,vorigin)
get_user_origin(id, origin, 1)
length = get_distance(aimvec,origin)
direction[0]=aimvec[0]-origin[0]
direction[1]=aimvec[1]-origin[1]
direction[2]=aimvec[2]-origin[2]
if (!length) length=1
moveto[0]=origin[0]+direction[0]*100/length
moveto[1]=origin[1]+direction[1]*100/length
moveto[2]=origin[2]+direction[2]*100/length
velocity[0]=(moveto[0]-vorigin[0])
velocity[1]=(moveto[1]-vorigin[1])
velocity[2]=(moveto[2]-vorigin[2])
set_user_velocity(players[i], velocity)
}
}
}