alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
987 stars 422 forks source link

First index of int mouse[2] argument in OnPlayerRunCmd always shows 0 #1139

Closed The-Doggy closed 3 years ago

The-Doggy commented 4 years ago

Help us help you

Environment

Description

Printing out the values of the mouse array during an OnPlayerRunCmd forward in Half-Life 2: Deathmatch (haven't tested any other games) will always show 0 for the first index however the second index seems to work as intended.

Problematic Code (or Steps to Reproduce)

  #include <sdktools>

public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
{
    PrintToChat(client, "CURRENT MOUSE = %i %i", mouse[0], mouse[1]);
    return Plugin_Continue;
}

Move mouse around while in game and the first value will never change from 0.

Logs

sm9cc commented 4 years ago

This is probably due to the game initializing mouse values during frame instead of tick.

As quoted by NCZ4 (NoCheatz) dev:

This detection is not safe at all because the client game process mouse on frame rather than on tick. A client with higher FPS than tickrate will send legitimate 0 mouse values because mouse accum are processed and 0ed between ticks in this case.

https://github.com/moxskull/NoCheatZ-4/commit/3c789a985675196b08564f3f59f2e99bda70648d#diff-d3530a19d26f68b1cd08dd83306a845cL126

asherkin commented 4 years ago

This is probably due to the game initializing mouse values during frame instead of tick.

Pretty sure it is just the CUserCmd struct being outdated in the SDK - this happens quite regularly as the mouse values are near the end.

sm9cc commented 4 years ago

This is probably due to the game initializing mouse values during frame instead of tick.

Pretty sure it is just the CUserCmd struct being outdated in the SDK - this happens quite regularly as the mouse values are near the end.

Ah right, that makes sense.

asherkin commented 3 years ago

This seems to have been fixed at some point, the test plugin is working fine now.