Raised This Month: $51 Target: $400
 12% 

set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in TFC


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DynamicBits
Senior Member
Join Date: Sep 2007
Location: US
Old 01-02-2014 , 19:21   set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in TFC
Reply With Quote #1

In TFC, I am unable to set a player's frags ("score" on scoreboard) and have it stick. The below code sets every player in the server to 100 frags. The scoreboard updates and shows a score of 100 for every player. However, as soon as any player gets a new kill or suicide, the score is updated to what it would have been had I never set it to 100.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <fakemeta_util> public plugin_init() {         register_plugin("TestFrag", "0.0", "x");         register_clcmd("say frag", "test_frag"); } public test_frag(id) {         new Clients[32], iNum;         get_players(Clients, iNum, "h");         for (new i = 0; i < iNum; i++) {                 set_user_frags(Clients[i], 100)                 //fm_set_user_frags(Clients[i], 100);                 //set_pev(Clients[i], pev_frags, float(100));         } }

I've tried each of the three methods for to be thorough and they all behave the same. This code works fine for other mods. What am I doing wrong?


--
Andy

Last edited by DynamicBits; 01-03-2014 at 17:26. Reason: code tag replaced with pawn tag
DynamicBits is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-02-2014 , 20:33   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #2

You tried Ham_AddPoints ?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-03-2014 , 01:32   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #3

May be TFC uses private datas, have you searched if a list of them is avalaible somewhere ?

Or may be it is working but score is not updated, as in cs...
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-03-2014 at 01:33.
ConnorMcLeod is offline
DynamicBits
Senior Member
Join Date: Sep 2007
Location: US
Old 01-03-2014 , 11:27   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #4

Quote:
Originally Posted by meTaLiCroSS View Post
You tried Ham_AddPoints ?
I tried Ham_AddPoints and Ham_AddPointsToTeam and neither seems to have any effect.



Quote:
Originally Posted by ConnorMcLeod View Post
May be TFC uses private datas, have you searched if a list of them is avalaible somewhere ?
Hmm... Once you mentioned it, I searched, but I haven't been able to find a list anywhere. Via Google, I found a couple references to using set_pdata_int() in TFC, but the examples had actual integers for the offset with no explanation (and seem to be outdated). There are also a handful in the TFCX module source, but they are mostly related to ammo (used for tfc_setbammo()).



Quote:
Originally Posted by ConnorMcLeod View Post
Or may be it is working but score is not updated, as in cs... :)
Do you mean the scoreboard isn't updated (no ScoreInfo is sent)?


--
Andy
DynamicBits is offline
DynamicBits
Senior Member
Join Date: Sep 2007
Location: US
Old 01-03-2014 , 18:15   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #5

Thanks to joropito, I made some progress with regards to the private data:
$ pahole tfc/dlls/tfc.so -C CBasePlayer


Take the first number in the comment and divide it by 4 to get the offset in Linux (e.g. m_iClientFrags = 2592 / 4 = 648). Dumping the pvPrivateData while in-game shows 643 as the offset that holds frags, so I think I'm on the right track.

Edit: I tried setting it with set_pdata_int(), but it appears that something else is overwriting it. I am able to set other values and they stick, but not that one.


--
Andy

Last edited by DynamicBits; 01-05-2014 at 00:02.
DynamicBits is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2014 , 06:37   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #6

m_iClientFrags is a copy of pev->frags

At UpdateClientDatas, if m_iClientFrags is different from pev->frags, m_iClientFrags is set to pev->frags value and ScoreInfo message is sent, i think it is how it is working for that game

But in that case your previous tests should have been working, so i don't really understand.

Anyway, change pdata won't have any effect, the only thing you should do is change pev->frags using set_user_frags or pev_frags or whatever.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
DynamicBits
Senior Member
Join Date: Sep 2007
Location: US
Old 01-04-2014 , 14:57   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #7

I started looking at other classes to see if there was something I was missing. Apparently m_iClientFrags is just pretend frags because "real_frags" exists in CBaseEntity. It looks like m_iClientFrags gets updated based on the value in real_frags and shouldn't (can't?) be written to.

$ pahole tfc/dlls/tfc.so -C CBaseEntity


Using this new real_frags offset, I am able to set the frags and they don't get overwritten. I'm going to do some more testing, but I'm pretty sure this problem is mostly solved.

Once fully tested, I guess I'll start working on some new TFC natives. I see DOD had similar issues (solved with dod_set_pl_deaths, dod_set_user_kills, dod_set_user_score, etc.).


--
Andy

Last edited by DynamicBits; 01-04-2014 at 14:58. Reason: grammar
DynamicBits is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-05-2014 , 05:02   Re: set_user_frags/fm_set_user_frags/set_pev(..pev_frags..) Doesn't Work Properly in
Reply With Quote #8

You don't need a native, just do set_pdata_int(id, real_frags, 1337) ;)

or if you really want something make a private function or a define.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-05-2014 at 05:02.
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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