AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking +jump (https://forums.alliedmods.net/showthread.php?t=27642)

WaZZeR++ 04-26-2006 04:23

Checking +jump
 
I want to "hook" the +jump command to check for bhop scripts...

But its not possible to do:
Code:
register_clcmd("+jump"....)

How should i do it?

v3x 04-26-2006 04:25

The only way is to use the Engine forward "client_PreThink" like so:
Code:
public client_PreThink(id) {   if(!is_user_alive(id))     return PLUGIN_CONTINUE;   if(get_user_button(id) & IN_JUMP)     // player is holding the jump button   else if(get_user_button(id) & IN_JUMP && !(get_user_oldbutton(id) & IN_JUMP))     // player just tapped the jump button   return PLUGIN_CONTINUE; }

WaZZeR++ 04-26-2006 04:28

So there is no way to read what commands that are sent from the client to the server?

But thx anyway, I'll try it out.

v3x 04-26-2006 04:43

Engine & Fakemeta versions:
Code:
#include <amxmodx> #include <engine> new button[33]; public client_PreThink(id) {   if(!is_user_alive(id))     return PLUGIN_CONTINUE;   button[id] = get_user_button(id);   if(button[id] & IN_JUMP)   {     // player is holding the jump button     return PLUGIN_CONTINUE;   }   if((button[id] & IN_JUMP) && !(get_user_oldbutton(id) & IN_JUMP))   {     // player just tapped the jump button     return PLUGIN_CONTINUE;   }   return PLUGIN_CONTINUE; }
Code:
#include <amxmodx> #include <fakemeta> #define IN_JUMP (1<<1) public plugin_init() {   register_plugin("test" , "0.1" , "v3x");   register_forward(FM_PlayerPreThink , "forward_playerprethink"); } new button[33]; public forward_playerprethink(id) {   if(!is_user_alive(id))     return FMRES_IGNORED;   button[id] = pev(id , pev_button);   if(button[id] & IN_JUMP)   {     // player is holding the jump button     return FMRES_IGNORED;   }   if((button[id] & IN_JUMP) && !(pev(id , pev_oldbuttons) & IN_JUMP))   {     // player just tapped the jump button     return FMRES_IGNORED;   }   return FMRES_IGNORED; }

kmal2t 04-26-2006 06:33

This won't work for several reasons. You can use a bhop script without holding down jump. You can use it in a non-tapping, hold release, hold release fashion and not change anything. Or maybe I'd just bind +bhop to my mousewheel and scroll it if I'm super lazy? What about people that don't use a bhop script that happen to hold their jump key? Not to mention someone could just change their script from a +command to a toggle?

There are already anti-bhop scripts in TFC. They detect if you're using alias _special (the main command used in bhop scripts) and the server kicks you. Check some TFC forums for that.

p3tsin 04-26-2006 10:50

well this works but it may take some cpu :?

Code:
new somestring[32] public plugin_init() {     new detectcmd[32]     format(detectcmd,31, "plop%d%d%d", random_num(0,99), random_num(0,99), random_num(0,99))     register_clcmd(detectcmd, "detected")     format(somestring,31, " alias _special %s",detectcmd) } public client_PreThink(id) {     if(!is_user_alive(id)) return PLUGIN_CONTINUE     new buttons = entity_get_int(id, EV_INT_button)     new oldbuttons = entity_get_int(id, EV_INT_oldbuttons)     if(buttons&IN_JUMP && !(oldbuttons&IN_JUMP))         client_cmd(id, "%s", somestring)     return PLUGIN_CONTINUE } public detected(id) {     new flags = entity_get_int(id, EV_INT_flags)     if(!(flags&FL_WATERJUMP) && !(flags&FL_ONGROUND) && entity_get_int(id, EV_INT_waterlevel) < 2) {         new name[32], steamid[34]         get_user_name(id, name,31)         get_user_authid(id, steamid,33)         client_print(0,print_chat, "[AMXX] Bhop-script detected on %s (%s)", name,steamid)         server_cmd("kick #%d", get_user_userid(id))     }     return PLUGIN_HANDLED }

so the alias _special is overwritten on every frame when they're pressing jump

EDIT: donnu why i have the flags being check in detected() :P

WaZZeR++ 04-26-2006 18:19

Quote:

Originally Posted by p3tsin
well this works but it may take some cpu :?

Code:
new somestring[32] public plugin_init() {     new detectcmd[32]     format(detectcmd,31, "plop%d%d%d", random_num(0,99), random_num(0,99), random_num(0,99))     register_clcmd(detectcmd, "detected")     format(somestring,31, " alias _special %s",detectcmd) } public client_PreThink(id) {     if(!is_user_alive(id)) return PLUGIN_CONTINUE     new buttons = entity_get_int(id, EV_INT_button)     new oldbuttons = entity_get_int(id, EV_INT_oldbuttons)     if(buttons&IN_JUMP && !(oldbuttons&IN_JUMP))         client_cmd(id, "%s", somestring)     return PLUGIN_CONTINUE } public detected(id) {     new flags = entity_get_int(id, EV_INT_flags)     if(!(flags&FL_WATERJUMP) && !(flags&FL_ONGROUND) && entity_get_int(id, EV_INT_waterlevel) < 2) {         new name[32], steamid[34]         get_user_name(id, name,31)         get_user_authid(id, steamid,33)         client_print(0,print_chat, "[AMXX] Bhop-script detected on %s (%s)", name,steamid)         server_cmd("kick #%d", get_user_userid(id))     }     return PLUGIN_HANDLED }

so the alias _special is overwritten on every frame when they're pressing jump

EDIT: donnu why i have the flags being check in detected() :P

Didnt knew it was possible to send alias command to the cilent, think valve removed it in cs in some of the latest update. But i try it out. Thx for the help.

p3tsin 04-27-2006 08:58

yeah they removed it :D
but it still works if u put a space before the word "alias"
Code:
format(somestring,31, " alias _special %s",detectcmd)
:P


All times are GMT -4. The time now is 05:02.

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