alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
494 stars 197 forks source link

[DoD] Set score & set/get deaths natives broken #850

Closed diamond-optic closed 4 years ago

diamond-optic commented 4 years ago

Mod: Day of Defeat HLDS: 1.1.2.6 (Jul 24 2019 8308) [and also reHLDS 3.7.0.694 (Mar 22 2020 2171)] Metamod: 1.21p38 OS: Windows Server 2012

Issue:

dod_set_user_score >> Only changes the players score displayed on the scoreboard. It reverts back to the 'legit' score when dying or when gaining another score point (capping a flag etc)

dod_get_pl_deaths >> Returns the players score instead of deaths

dod_set_pl_deaths >> Really sets the players score, but it changes the displayed deaths on the scoreboard to the input value. It also sets the displayed score on the scoreboard to usually a really high or really low (negative value) number. The displayed values on the scoreboard are also once again reset to the 'legit' values when you die or cap a flag etc

also with the dod_set_pl_deaths is it possible to somehow make it not display the player as dead on the scoreboard? I know the include file makes note that the player will be labeled as dead, but maybe theres a workaround to this?

Plugin I tested with: https://pastebin.com/yQqLc1D4

diamond-optic commented 4 years ago

https://github.com/alliedmodders/amxmodx/blob/master/modules/dod/dodfun/CMisc.h

define STEAM_PDOFFSET_SCORE 475 + LINUXOFFSET // score

define STEAM_PDOFFSET_DEATHS 476 + LINUXOFFSET // deaths

in my testing im finding that the offsets are now 476 for score and 477 for deaths

edit

Through some more testing it appears the other offsets there all need to be increased by 1 as well. But I cant confirm if that will fix the teamname one, I dont understand whats going on there with it multiplying by zero on windows?

edit 2

Ended up downloading the code and building it myself and adding 1 to the offsets returns the natives to working order, except the teamname one still does not seem to work. Easy enough to work around it in plugins that I'm using it in, but it will still break other plugins that dont switch to another way to getting the team name.

diamond-optic commented 4 years ago

in regards to the teamname.. in the NPD.cpp, if i change line 209 from:

char szTeamName = MF_GetAmxString(amx, params[1], 0, &iLen); to: char szTeamName = MF_GetAmxString(amx, params[2], 0, &iLen);

I can set the team name (dod_set_pl_teamname), and then getting the team name returns that string.. but it doesnt get seem to get set to anything unless you manually set it to something first. Checking through some old logs from a couple years ago this was working correctly at some point. Maybe the game was, and no longer is, setting that value on its own anymore?

Arkshine commented 4 years ago

About the offset. I believe the gamedata are correct: https://github.com/alliedmodders/amxmodx/blob/master/gamedata/common.games/entities.games/dod/offsets-cbaseplayer.txt#L941-L957 ; m_iObjScore: 1924 / 4 (size int type) = 476 m_iDeaths: 1908 / 4 = 477 m_szTeamName: should be now 1400 (that's why native doesn't work)

If you can, feel free to create a Pull Request to fix those hardcoded values or any others offsets as well. Ideally, the code should rely on that gamedata file (like CStrike module) though.

diamond-optic commented 4 years ago

ahh yes 1400 works, thank you! I've been out of this amxx stuff for so long, wasnt even really aware of what the gamedata files were lol (and its pretty sweet knowing now haha)

and tbh, not a clue how to make a pull request.. I find myself lucky just that I managed to compile this thing after getting various errors for hours (though most of it I think was from having VS2019 and it works a lot better once I put 2013 back on)

edit

Ok I think I figured out the pull request stuff.. Apologies in advanced if I did it incorrectly.. And of course I made a typo in the commit message go figure lol