[Help me!?!?]Double step
Can somebody show me how to change this plugins flags so that the plugins command only triggers double step on the one who uses the command?
I woulda ask the owner but he isnt active anymore..
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define UT_NONE -1
#define UT_JUMP 0
#define UT_FORWARD 1 //DOF stands for DOFORWARD
#define UT_BACK 2
#define UT_RIGHT 3
#define UT_LEFT 4
#define TMINUS 0.3 //The amount of time between keystrokes to activate the plugin.
new bool:hasjumped[33] = false
new bool:cando[33] = false
new domove[33] = 0
new lasthit[33] = 0 //Store the last direction they pressed
new bool:roundactive = false
new baseforce
new bool:vcheck = true
public plugin_init()
{
register_plugin("UT Doublesteps","1.4","twistedeuphoria")
baseforce = register_cvar("utds_baseforce","750")
register_logevent("roundstart",2,"0=World triggered","1=Round_Start")
register_logevent("roundend",2,"0=World triggered","1=Round_End")
register_concmd("utds_nosave","nosave",ADMIN_KICK,"<1|0> : Sets whether or not players can save themselves from fall damage by jumping in air.")
}
public nosave(id,level,cid)
{
if(!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new anumstr[3], anum
read_argv(1,anumstr,3)
anum = str_to_num(anumstr)
if(anum == 0)
{
vcheck = false
console_print(id,"Players may now jump at the last second to save themselves from damage.")
}
else
{
vcheck = true
console_print(id,"Players may no longer jump at the last second to save themselves from damage.")
}
return PLUGIN_HANDLED
}
public roundstart()
{
roundactive = true
}
public roundend()
{
roundactive = false
}
public client_putinserver(id)
{
domove[id] = UT_NONE
hasjumped[id] = false
cando[id] = false
lasthit[id] = 0
}
public client_PreThink(id)
{
if(!roundactive)
return PLUGIN_CONTINUE
new nbut = get_user_button(id) //Get the button the player is currently pressing.
new obut = get_user_oldbutton(id) //Get the last button the player pressed. (This will get the button they are holding down if they are holding a button down.)
new flags = get_entity_flags(id)
if(nbut & IN_JUMP)
{
if(flags & FL_ONGROUND)
{
hasjumped[id] = false
return PLUGIN_CONTINUE
}
else
{
if(!(obut & IN_JUMP) && !hasjumped[id])
{
domove[id] = UT_JUMP
hasjumped[id] = true
return PLUGIN_CONTINUE
}
}
}
if((nbut & IN_FORWARD) && (flags & FL_ONGROUND) && !(obut & IN_FORWARD)) //Same as the jump if line but for forward
{
if(cando[id] == false)
{
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",352+id,pstr,1)
cando[id] = true
lasthit[id] = UT_FORWARD
return PLUGIN_CONTINUE
}
if(cando[id] == true)
{
if(lasthit[id] == UT_FORWARD)
{
domove[id] = UT_FORWARD
cando[id] = false
return PLUGIN_CONTINUE
}
else
{
cando[id] = false
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",314+id,pstr,1)
cando[id] = true
lasthit[id] = UT_FORWARD
return PLUGIN_CONTINUE
}
}
}
if((nbut & IN_BACK) && (get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_BACK))
{
if(cando[id] == false)
{
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",352+id,pstr,1)
cando[id] = true
lasthit[id] = UT_BACK
return PLUGIN_CONTINUE
}
if(cando[id] == true)
{
if(lasthit[id] == UT_BACK)
{
domove[id] = UT_BACK
cando[id] = false
return PLUGIN_CONTINUE
}
else
{
cando[id] = false
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",314,pstr,1)
cando[id] = true
lasthit[id] = UT_BACK
return PLUGIN_CONTINUE
}
}
}
if((nbut & IN_MOVERIGHT) && (get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_MOVERIGHT))
{
if(cando[id] == false)
{
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",352+id,pstr,1)
cando[id] = true
lasthit[id] = UT_RIGHT
return PLUGIN_CONTINUE
}
if(cando[id] == true)
{
if(lasthit[id] == UT_RIGHT)
{
domove[id] = UT_RIGHT
cando[id] = false
return PLUGIN_CONTINUE
}
else
{
cando[id] = false
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",314,pstr,1)
cando[id] = true
lasthit[id] = UT_RIGHT
return PLUGIN_CONTINUE
}
}
}
if((nbut & IN_MOVELEFT) && (get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_MOVELEFT))
{
if(cando[id] == false)
{
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",352+id,pstr,1)
cando[id] = true
lasthit[id] = UT_LEFT
return PLUGIN_CONTINUE
}
if(cando[id] == true)
{
if(lasthit[id] == UT_LEFT)
{
domove[id] = UT_LEFT
cando[id] = false
return PLUGIN_CONTINUE
}
else
{
cando[id] = false
new pstr[2]
pstr[0] = id
set_task(TMINUS,"can_switch",314,pstr,1)
cando[id] = true
lasthit[id] = UT_LEFT
return PLUGIN_CONTINUE
}
}
}
return PLUGIN_CONTINUE
}
public can_switch(pstr[])
{
cando[pstr[0]] = false
}
public client_PostThink(id) //All normal movement happens in PostThink so I put the actual movements in here.
{
if(!roundactive)
return PLUGIN_CONTINUE
switch(domove[id])
{
case UT_JUMP:
{
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity) //Get their current velocity (to carry other movement/inertia into the jump)
if(vcheck)
{
if(velocity[2] > -300.0)
velocity[2] = 275.0 //MAGIC NUMBAR OLOLO
}
else
velocity[2] = 275.0 //MAGIC NUMBAR OLOLO
entity_set_vector(id,EV_VEC_velocity,velocity) //Set the player's new vector.
domove[id] = UT_NONE
return PLUGIN_CONTINUE
}
case UT_FORWARD:
{
new Float:force = float(get_pcvar_num(baseforce))
new Float:vector[3]
entity_get_vector(id,EV_VEC_angles,vector)
engfunc(EngFunc_MakeVectors,vector)
new Float:v_forward[3]
get_global_vector(GL_v_forward,v_forward)
entity_get_vector(id,EV_VEC_velocity,vector)
vector[0] = v_forward[0] * force
vector[1] = v_forward[1] * force
vector[2] = 220.0 //HOLY SHIT ANOTHER MAGIC NUMAR!
entity_set_vector(id,EV_VEC_velocity,vector)
domove[id] = UT_NONE
return PLUGIN_CONTINUE
}
case UT_BACK:
{
new Float:force = float(get_pcvar_num(baseforce)) * -1.0
new Float:vector[3]
entity_get_vector(id,EV_VEC_angles,vector)
engfunc(EngFunc_MakeVectors,vector)
new Float:v_forward[3]
get_global_vector(GL_v_forward,v_forward)
entity_get_vector(id,EV_VEC_velocity,vector)
vector[0] = v_forward[0] * force
vector[1] = v_forward[1] * force
vector[2] = 220.0 //HOLY SHIT ANOTHER MAGIC NUMAR!
entity_set_vector(id,EV_VEC_velocity,vector)
domove[id] = UT_NONE
return PLUGIN_CONTINUE
}
case UT_RIGHT:
{
new Float:force = float(get_pcvar_num(baseforce))
new Float:vector[3]
entity_get_vector(id,EV_VEC_angles,vector)
engfunc(EngFunc_MakeVectors,vector)
new Float:v_right[3]
get_global_vector(GL_v_right,v_right)
entity_get_vector(id,EV_VEC_velocity,vector)
vector[0] = v_right[0] * force
vector[1] = v_right[1] * force
vector[2] = 220.0
entity_set_vector(id,EV_VEC_velocity,vector)
domove[id] = UT_NONE
return PLUGIN_CONTINUE
}
case UT_LEFT:
{
new Float:force = float(get_pcvar_num(baseforce)) * -1.0
new Float:vector[3]
entity_get_vector(id,EV_VEC_angles,vector)
engfunc(EngFunc_MakeVectors,vector)
new Float:v_right[3]
get_global_vector(GL_v_right,v_right)
entity_get_vector(id,EV_VEC_velocity,vector)
vector[0] = v_right[0] * force
vector[1] = v_right[1] * force
vector[2] = 220.0
entity_set_vector(id,EV_VEC_velocity,vector)
domove[id] = UT_NONE
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
|