s1lentq / ReGameDLL_CS

:hammer: Reverse-engineered gamedll (CS 1.6 / CZero)
GNU General Public License v3.0
578 stars 198 forks source link

jointeam SPEC bug #277

Open ghost opened 6 years ago

ghost commented 6 years ago

If a player joins the server and chooses to join SPECTATOR team or is forced to by means of humans_join_team cvar, if the player then gets switched to TERROR or CT during the same round he joined the SPECTATOR team, the player is not initialized correctly. His HUD is not displayed correctly and also he is not spawned with a knife and slot commands do not work.

If the round ends between him joining SPECTATOR and being transferred to another team this bug does not occur. The bug does occur if the round is restarted without ending (sv_restart 1).

I have been able to replicate this every time using ReHLDS 3.4.0.639-dev, ReGameDLL 5.7.0.295-dev and latest AmxModX (used to switch players teams). No third party plugins running.

In-line commented 6 years ago

I guess this happens, because cstrike module doesn't change player team correctly. It should be related to #111 . Additional debugging is required. Does this issue happen with stock gamedll?

In-line commented 6 years ago

Btw correct team change implementation can be found in reapi

ghost commented 6 years ago

Just tested with original HLDS and mp dlls and the bug still occurs under the same circumstances. CStrike module uses set_pdata and sends TeamInfo message for changing a players team, I am not sure what else would need to be sent in order to prevent this bug. I will look for the solution in reapi.

In-line commented 6 years ago

Did you switch player using amx_teammenu? (I wasn't able to do this, because only 1 team change is allowed)

ghost commented 6 years ago

I did use amx_teammenu, however I realized I had made a modification to plmenu.sma. Under function actionTeamMenu I had removed this check:

if (g_CSPlayerCanSwitchFromSpec[player] && g_cstrike && (CS_TEAM_T <= cs_get_user_team(player) <= CS_TEAM_CT))

If this check is true it uses cs_set_user_team, otherwise it attempts to send jointeam and joinclass commands to players, hence why you got the "only 1 team change" message. Upon further investigation in the same file, g_CSPlayerCanSwitchFromSpec is set to false at ClientPutInServer, and set to true only when a TeamInfo message is sent with the argument being TERRORIST or CT.

It seems someone had encountered this issue in the past and overcame it by adding these conditions. I would say this is a bug in the original DLL (as well as ReGameDLL). It does not influence the standard gameplay, however it can become an issue when creating mods.

Edit: To prevent this bug, instead of using cs_set_user_team native from cstrike module, one should instead set pdata offset m_bHasChangeTeamThisRound (125) to zero, and send a jointeam command to player.

For metamod:
set_pdata_int(pEdict, 125, (get_pdata_int(pEdict, 125) & ~(1 << 8)))
CLIENT_COMMAND(pEdict, "jointeam %d\n", iTeam)
OsweRRR commented 6 years ago

Hello in the next video you can detail maybe what is the bug and the code I use is in the description of the video.

https://www.youtube.com/watch?v=z_wPRGNwQKw

OsweRRR commented 6 years ago

bug spectator from cvar mp_auto_join_team.. edit: my ip is dynamic xd

https://www.youtube.com/watch?v=EXIzeq-ichk

ghost commented 6 years ago

Your problem has nothing to do with this issue. You have to add more spawn points in order for players to enter the team. Google "Map Spawns Editor".

OsweRRR commented 6 years ago

Spawns are not the problem because they are already added. the first video has only 5 players ..

ghost commented 6 years ago

Try setting mp_limitteams 0

OsweRRR commented 6 years ago

The result is the same..