AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   blocking jump and duck in prethink (https://forums.alliedmods.net/showthread.php?t=24565)

ng1200 02-26-2006 07:37

blocking jump and duck in prethink
 
hi,
this is my prethink code:
Code:
public client_PreThink(id)     {     if(incar[id] != 0)         {         new bufferstop = entity_get_int(id,EV_INT_button)                 if(bufferstop != 0) {             entity_set_int(id,EV_INT_button,bufferstop & ~IN_ATTACK & ~IN_ATTACK2 & ~IN_ALT1 & ~IN_USE)         }                 if((bufferstop & IN_JUMP) && (entity_get_int(id,EV_INT_flags) & ~FL_ONGROUND & ~FL_DUCKING)) {             entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_JUMP)         }             }     return PLUGIN_CONTINUE }
now, how do i block jump and duck?

Hawk552 02-26-2006 12:45

Looks like you answered your own question.

If that doesn't solve it, try setting the entity's button to IN_CANCEL, like this:

Code:
entity_set_int(id,EV_INT_button,IN_CANCEL)

ng1200 02-27-2006 03:08

thanks!
but i tryed that:
Code:
public client_PreThink(id)     {     if(incar[id] != 0)         {         new bufferstop = entity_get_int(id,EV_INT_button)                 if(bufferstop != 0) {             entity_set_int(id,EV_INT_button,bufferstop & ~IN_ATTACK & ~IN_ATTACK2 & ~IN_ALT1 & ~IN_USE)         }         if(bufferstop & IN_DUCK)         {             entity_set_int(id,EV_INT_button,IN_CANCEL)         }         if(bufferstop & IN_JUMP)         {             entity_set_int(id,EV_INT_button,IN_CANCEL)         }         if((bufferstop & IN_JUMP) && (entity_get_int(id,EV_INT_flags) & ~FL_ONGROUND & ~FL_DUCKING)) {             entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_JUMP)         }                 return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }
and it didnt work

VEN 02-27-2006 03:51

The best antijump way for me is set player gravity to something high.
It's better than prethink velocity method.
Compare and you'll see what i'm talking about.
But be careful such gravity could kill player on non-plain surface (stairs, etc).
So you can use any method. It's depen on the purpose.

About jump block. I do not think there are a good way.
You can send "-duck" command to the client but it wouldn't affect instantly.

Hawk552 02-27-2006 09:36

Although I've never tried it before, you could also try setting their z velocity (cell 2 I believe) to the negative abs of itself.

v3x 02-27-2006 14:44

Make sure that the incar variable is getting set to something other than 0 for that player's index.

Charr 02-27-2006 15:49

You would probably want something like this:
Code:
public client_PreThink(id) {     new buttons = entity_get_int(id,EV_INT_button);     if(incar[id])     {         entity_set_int(id,EV_INT_button,buttons & ~IN_JUMP & ~IN_DUCK & ~IN_MOVELEFT & ~IN_MOVERIGHT & ~IN_USE & ~IN_ATTACK & ~IN_ATTACK2);     } }

That will block jump, duck, use, attack, attack2, strafe left, and strafe right when someone is in a car.

ng1200 02-28-2006 04:01

didnt work charr,
and the other jump code blocked me from wall-jumping too, ur code doesnt

Hawk552 02-28-2006 09:24

Try this, I have no time nor do I have a compiler, online one is slow (announcements are on, I'm at school)

Code:
public client_PreThink(id) {     if(entity_get_int(id,EV_INT_button) & IN_JUMP))     {         new Float:vVelocity[3]         entity_get_vector(id,EV_VEC_velocity,vVelocity)         vVelocity[2] = float(-abs(round(vVelocity[2])))         entity_set_vector(id,EV_VEC_velocity,vVelocity)         entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_JUMP)     } }

ng1200 03-01-2006 07:17

thanks hawk,
but what include is needed for round()?
im using amxmisc,amxmodx,engine and fun


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

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