Prevent Double Jump

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Prevent Double Jump

Postby decompile » Fri Mar 11, 2016 7:41 pm

User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sat Mar 12, 2016 2:27 am

There is a better way than a Tick listener. You save the current timestamp of the first jump and compare it when the player tries to jump again. If there is enough time elapsed between both jumps (or attemps to), you allow the jump otherwise you block it.
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Sat Mar 12, 2016 12:23 pm

Sounds good, gonna try it with 2.0 seconds
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Postby iPlayer » Sat Mar 12, 2016 4:52 pm

What if somebody's falling for a while and double jumps right before they hit the ground? It might be longer than just X seconds.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Sat Mar 12, 2016 4:55 pm

If I recall correctly from my SourcePawn days, there's an event for when a player's ground ent changes (e.g. they hit the ground), you could just have a boolean set when a player jumps and unset when their ground ent changes to 0 (or any value other than -1)
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Sat Mar 12, 2016 9:22 pm

that would be awesome if that exists
that would probably be the best solution for this
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sat Mar 12, 2016 9:55 pm

Something like this?

Syntax: Select all

import memory

from memory import Convention
from memory import DataType

from memory.hooks import PreHook

from players.entity import Player

server = memory.find_binary('server')

CreateInterface = server['CreateInterface'].make_function(
Convention.CDECL,
[DataType.STRING, DataType.POINTER],
DataType.POINTER
)

g_pGameMovement = CreateInterface('GameMovement001', None)

# CCSGameMovement::OnLand(float)
OnLand = g_pGameMovement.make_virtual_function(
26,
Convention.THISCALL,
[DataType.POINTER, DataType.FLOAT],
DataType.VOID
)

@PreHook(OnLand)
def pre_on_land(args):
player = memory.make_object(Player, args[0].get_pointer(3744))
print('%s landed!'% player.name, args[1])
Works with CS:S (Windows).
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Sat Mar 12, 2016 10:32 pm

Thanks, perfect replace for the ticklistener onGround check
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Mon Apr 11, 2016 11:28 pm

Just tested this abit and found out that this is not the best way or pretty useless.

so lets say the pre_on_land fires this function

Syntax: Select all

def onGround(self):
self.stagejumps = 0
self.totaljumps = 0


And we have this for jumps (fired by player_jump event)

Syntax: Select all

def jumpEvent(self):
self.jumps+= 1


But in the end it always show

self.jumps = 1


Mhm
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Re:

Postby Doldol » Thu Feb 01, 2018 11:56 am

Ayuto wrote:Something like this?

Syntax: Select all

import memory

from memory import Convention
from memory import DataType

from memory.hooks import PreHook

from players.entity import Player

server = memory.find_binary('server')

CreateInterface = server['CreateInterface'].make_function(
Convention.CDECL,
[DataType.STRING, DataType.POINTER],
DataType.POINTER
)

g_pGameMovement = CreateInterface('GameMovement001', None)

# CCSGameMovement::OnLand(float)
OnLand = g_pGameMovement.make_virtual_function(
26,
Convention.THISCALL,
[DataType.POINTER, DataType.FLOAT],
DataType.VOID
)

@PreHook(OnLand)
def pre_on_land(args):
player = memory.make_object(Player, args[0].get_pointer(3744))
print('%s landed!'% player.name, args[1])
Works with CS:S (Windows).


Sorry to dig up an old topic, but could you please explain how you found 3744 as the offset for the player pointer?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Prevent Double Jump

Postby Ayuto » Thu Feb 01, 2018 6:51 pm

CCSGameMovement::OnLand() is quite simple. All it does is calling CCSPlayer::OnLand(). To do that it needs the player instance (CCSPlayer). It's retrieved by accessing this+0x0EA0 (3744).

Syntax: Select all

.text:002E7410                                                 ; CCSGameMovement::OnLand(float)
.text:002E7410 _ZN15CCSGameMovement6OnLandEf proc near ; DATA XREF: .rodata:`vtable for'CCSGameMovemento
.text:002E7410
.text:002E7410 arg_0 = dword ptr 8
.text:002E7410
.text:002E7410 55 push ebp
.text:002E7411 89 E5 mov ebp, esp
.text:002E7413 8B 45 08 mov eax, [ebp+arg_0]
.text:002E7416 8B 80 A0 0E 00 00 mov eax, [eax+0EA0h]
.text:002E741C 89 45 08 mov [ebp+arg_0], eax
.text:002E741F 5D pop ebp
.text:002E7420 E9 1B 53 01 00 jmp _ZN9CCSPlayer6OnLandEf ; CCSPlayer::OnLand(float)
.text:002E7420 _ZN15CCSGameMovement6OnLandEf endp

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 9 guests