Raised This Month: $ Target: $400
 0% 

Help with putting flag to plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Spec0wn
New Member
Join Date: Feb 2013
Old 02-05-2013 , 07:14   Re: Help with putting flag to plugin
Reply With Quote #3

Quote:
//#define engine

#include <amxmodx>
#include <amxmisc>
#include <fun>
#if defined engine
#include <engine>
#else
#include <fakemeta>
#endif

#define ADMIN_LEVEL_Q ADMIN_LEVEL_C

new bool:hook[33]
new hook_to[33][3]
new hook_speed_cvar
new hook_enabled_cvar
new bool:has_hook[33]

new beamsprite

public plugin_init()
{
register_plugin("Hook","1.0","Future")
register_concmd("+hook","hook_on",ADMIN_LEVEL _H," - Use: bind key +hook")
register_concmd("-hook","hook_off")
register_concmd("hook_toggle","hook_toggle",A DMIN_LEVEL_H,"Toggles your hook on and off")

register_concmd("amx_give_hook","cmd_givetake ",ADMIN_LEVEL_H,"Give a player the ability to hook <nick>")

register_concmd("amx_take_hook","cmd_givetake ",ADMIN_LEVEL_H,"Take a player's ability to hook <nick>")

register_concmd("amx_hook_menu","menu_cmd",AD MIN_LEVEL_Q,"Shows a menu that allows you to turn on/off non-admin use of hook.")

register_menucmd(register_menuid("hook_menu") ,(1<<0)|(1<<1)|(1<<2)|(1<<9), "Pressedhook")

hook_speed_cvar = register_cvar("hook_speed","5")
hook_enabled_cvar = register_cvar("hook_enabled","0")

}


/**********************************
Register beam sprite + Hook Sound
**********************************/

public plugin_precache()
{
beamsprite = precache_model("sprites/dot.spr")
precache_sound("weapons/xbow_hit2.wav")
precache_sound("weapons/xbow_fire1.wav")
}

/*****************************
Reset VARs on client connect
*****************************/

public client_putinserver(id)
{
has_hook[id]=false
}

/*****
Menu
*****/

public menu_cmd(id,level,cid)
{
if(cmd_access(id,level,cid,1))
{
show_hook(id)
console_print(id,"[AMXX] Menu launched.")
}
}

public show_hook(id)
{
static aaa[32]
if(get_pcvar_num(hook_enabled_cvar)==1) format(aaa,31,"No")
else format(aaa,31,"Yes")

new menuBody[576]

if(colored_menus())
{
new len = format(menuBody,575,"\bAllow Players To Use:^n^n")
len += format(menuBody[len],575-len, "\w1. Hook\R\w%s^n",aaa)
len += format(menuBody[len],575-len, "\r0. Exit")
}
else
{
new len = format(menuBody,575,"Allow Players To Use:^n^n")
len += format(menuBody[len],575-len, "1. Hook\R%s^n",aaa)
len += format(menuBody[len],575-len, "0. Exit")
}
show_menu(id,(1<<0)|(1<<1)|(1<<2)|(1<<9),menu Body,-1,"hook_menu")

return PLUGIN_CONTINUE
}

public Pressedhook(id,key)
{
switch(key)
{
case 0:
{
if(get_pcvar_num(hook_enabled_cvar)==0)
{
set_pcvar_num(hook_enabled_cvar,1)
client_print(0,print_chat,"[AMXX] Admin has enabled Hook for all clients. Use: bind key +hook")
}
else
{
set_pcvar_num(hook_enabled_cvar,0)
client_print(0,print_chat,"[AMXX] Admin has disabled Hook for all non-admins.")
}
show_hook(id)
}
}
}

/****************
Handle Commands
****************/

public cmd_givetake(id,level,cid)
{
if(!cmd_access(id,level,cid,2))
{
return PLUGIN_HANDLED
}

new arg1[32]
read_argv(1,arg1,31)

new target = cmd_target(id,arg1,9)
if(!target)
{
return PLUGIN_HANDLED
}

new name[32]
get_user_name(target,name,31)
if(get_user_flags(target) & ADMIN_LEVEL_Q)
{
console_print(id,"[AMXX] Cannot give/take hook from admin %s.",name)
return PLUGIN_HANDLED
}

new arg0[32]
read_argv(0,arg0,31)
if(containi(arg0,"give")!=-1)
{
if(containi(arg0,"hook")!=-1)
{
if(has_hook[target])
{
console_print(id,"[AMXX] %s already has hook",name)
}
else
{
has_hook[target]=true
console_print(id,"[AMXX] %s has been given hook",name)
client_print(target,print_chat,"[AMXX] An admin has given you hook. Use: bind key +hook")
}
}
}
if(containi(arg0,"take")!=-1)
{
if(containi(arg0,"hook")!=-1)
{
if(!has_hook[target])
{
console_print(id,"[AMXX] %s doesn't have hook",name)
}
else
{
has_hook[target]=false
console_print(id,"[AMXX] %s's hook has been taken away.",name)
client_print(target,print_chat,"[AMXX] An admin has taken your hook away.")
}
}
}
return PLUGIN_HANDLED
}

/*****
Hook
*****/

public hook_toggle(id,level,cid)
{
if(hook[id]) hook_off(id)
else hook_on(id,level,cid)
return PLUGIN_HANDLED
}

public hook_on(id,level,cid)
{
if(!has_hook[id] && !get_pcvar_num(hook_enabled_cvar) && !cmd_access(id,level,cid,1))
{
return PLUGIN_HANDLED
}
if(hook[id])
{
return PLUGIN_HANDLED
}
set_user_gravity(id,0.0)
set_task(0.1,"hook_prethink",id+10000,"",0,"b ")
hook[id]=true
hook_to[id][0]=999999
hook_prethink(id+10000)
emit_sound(id,CHAN_VOICE,"weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
return PLUGIN_HANDLED
}

public hook_off(id)
{
if(is_user_alive(id)) set_user_gravity(id)
hook[id]=false
return PLUGIN_HANDLED
}

public hook_prethink(id)
{
id -= 10000
if(!is_user_alive(id))
{
hook[id]=false
}
if(!hook[id])
{
remove_task(id+10000)
return PLUGIN_HANDLED
}

//Get Id's origin
static origin1[3]
get_user_origin(id,origin1)

if(hook_to[id][0]==999999)
{
static origin2[3]
get_user_origin(id,origin2,3)
hook_to[id][0]=origin2[0]
hook_to[id][1]=origin2[1]
hook_to[id][2]=origin2[2]
}

//Create blue beam
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(1) //TE_BEAMENTPOINT
write_short(id) // start entity
write_coord(hook_to[id][0])
write_coord(hook_to[id][1])
write_coord(hook_to[id][2])
write_short(beamsprite)
write_byte(1) // framestart
write_byte(1) // framerate
write_byte(2) // life in 0.1's
write_byte(5) // width
write_byte(0) // noise
write_byte(0) // red
write_byte(0) // green
write_byte(255) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()

//Calculate Velocity
static Float:velocity[3]
velocity[0] = (float(hook_to[id][0]) - float(origin1[0])) * 3.0
velocity[1] = (float(hook_to[id][1]) - float(origin1[1])) * 3.0
velocity[2] = (float(hook_to[id][2]) - float(origin1[2])) * 3.0

static Float:y
y = velocity[0]*velocity[0] + velocity[1]*velocity[1] + velocity[2]*velocity[2]

static Float
x = (get_pcvar_float(hook_speed_cvar) * 120.0) / floatsqroot(y)

velocity[0] *= x
velocity[1] *= x
velocity[2] *= x

set_velo(id,velocity)

return PLUGIN_CONTINUE
}

public get_origin(ent,Floatrigin[3])
{
#if defined engine
return entity_get_vector(id,EV_VEC_origin,origin)
#else
return pev(ent,pev_origin,origin)
#endif
}

public set_velo(id,Float:velocity[3])
{
#if defined engine
return set_user_velocity(id,velocity)
#else
return set_pev(id,pev_velocity,velocity)
#endif
}

public get_velo(id,Float:velocity[3])
{
#if defined engine
return get_user_velocity(id,velocity)
#else
return pev(id,pev_velocity,velocity)
#endif
}

public is_valid_ent2(ent)
{
#if defined engine
return is_valid_ent(ent)
#else
return pev_valid(ent)
#endif
}

public get_solidity(ent)
{
#if defined engine
return entity_get_int(ent,EV_INT_solid)
#else
return pev(ent,pev_solid)
#endif
}

stock set_rendering2(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
{
#if defined engine
return set_rendering(index,fx,r,g,b,render,amount)
#else
set_pev(index, pev_renderfx, fx);
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
set_pev(index, pev_rendercolor, RenderColor);
set_pev(index, pev_rendermode, render);
set_pev(index, pev_renderamt, float(amount));
return 1;
#endif
}
Here u go, I found admin levels at http://www.amxmodx.org/funcwiki.php?...=1#const_admin, but it still doesn't work. I'm trying to do the same thing with lasermines.

Last edited by Spec0wn; 02-05-2013 at 07:18.
Spec0wn is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode