Skip to content

Fix client/server ped dead-state inconsistency #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2019

Conversation

Necktrox
Copy link

@Necktrox Necktrox commented May 23, 2017

Description

Fixes #487

This tiny pull request fixes the inconsistency between client and server code to match the current 'dead' state of a ped.

Issue: #9496: Client 'isPedDead' returns 'false' when not yet spawned
Client: mods/deathmatch/logic/CClientPed.cpp

Notes

Your player ped is spawned and not dead after the initial connect, but the server code doesn't represent this state pre-PR. (see here)

@qaisjp
Copy link
Contributor

qaisjp commented May 23, 2017

Your player ped is spawned and not dead after the initial connect

Isn't the player ped actually not spawned on connect, and hence should be classed as dead?

@Necktrox
Copy link
Author

On connect, the player manager creates the CPlayer instance and waits until the player finishes starting his game. In this state, the player element shouldn't be accessable in any script, because the element is not attached to the root element, thus not visible to the element tree (getPlayerFromName needs a patch, because it doesn't account for ->IsJoined() - not sure if that's intended, feedback please).

The client creates the local player in CClientGame::Event_OnIngame, which happens after the game started and the player ped is not dead at this point.

@Necktrox Necktrox added the bug Something isn't working label May 26, 2017
@qaisjp
Copy link
Contributor

qaisjp commented Jun 23, 2017

Should we perhaps "prekill" the player in Event_OnIngame then?

In my mind the player should be considered dead until the first spawnPlayer. I'm not sure though...

@Necktrox
Copy link
Author

Necktrox commented Jul 3, 2017

Killing the player after the game started might cause unforeseen side-effects.

@Necktrox Necktrox added the feedback Further information is requested label Dec 15, 2017
@patrikjuvonen
Copy link
Contributor

Seems fine in my opinion.

@Citizen01
Copy link
Member

Citizen01 commented Jul 9, 2018

(getPlayerFromName needs a patch, because it doesn't account for ->IsJoined() - not sure if that's intended, feedback please)

So calling getPlayerFromName in onPlayerConnect should return false you say ?

addEventHandler( "onPlayerConnect", root, function ( playerNick )
    local p1 = getPlayerFromName( playerNick )
    -- p1 should equal false here ?
end)

I'm 50/50 about that, I would expect to get a valid player element, but also, I can't see a scenario where one would want a player element in onPlayerConnect and can not wait for onPlayerJoin.

@botder
Copy link
Member

botder commented Jul 9, 2018

The getPlayerFromName issue has been resolved by allowing it. Using any "player-data modifying" function (e.g. setElementData) will show a warning, if used with a non-joined player.

@patrikjuvonen
Copy link
Contributor

@Citizen01 There is an issue open which to me sounds fair enough. I think adding the ability to have soft "reserved slots" would be nice.

https://bugs.mtasa.com/view.php?id=6473

@Citizen01
Copy link
Member

@patrikjuvonen This PR won't resolve the issue you linked. Or am I missing something ?

@patrikjuvonen
Copy link
Contributor

patrikjuvonen commented Jul 9, 2018

@Citizen01 Yes, it won't, but that was related to your comment:

I can't see a scenario where one would want a player element in onPlayerConnect and can not wait for onPlayerJoin.

Sorry for being unclear.

@Citizen01
Copy link
Member

Ah yeah ok I see, but even that scenario doesn't require the player element connecting as you already can use its nickname and/or serial.

@patrikjuvonen
Copy link
Contributor

Ah, you're right! Completely forgot that. That issue should probably be closed then.

@Citizen01
Copy link
Member

Hmmm no ? The issue is for the even onClientConnect not being triggerd at all if the server is full.
We won't discuss about it in here anyway.

@qaisjp
Copy link
Contributor

qaisjp commented Aug 23, 2018

My argument is that after a player dies you need to use spawnPlayer, and so when you join you should be classed as "dead" because you have to use spawnPlayer.

@botder
Copy link
Member

botder commented Mar 6, 2019

// The player is spawned when he's connected, just the Camera is not faded in/not targetting
pPlayer->SetSpawned(true);

@qaisjp
Copy link
Contributor

qaisjp commented Mar 6, 2019

If that comment is correct and the player is already spawned when connected, there shouldn't be a requirement to use spawnPlayer

@botder
Copy link
Member

botder commented Mar 6, 2019

You don't have to use spawnPlayer.
grafik

@botder botder removed the feedback Further information is requested label Mar 6, 2019
@qaisjp
Copy link
Contributor

qaisjp commented Mar 7, 2019

Hmm, I thought spawnPlayer's documentation said you do need to. But setElementPosition seems to imply you only need spawnPlayer after the player is killed

@qaisjp
Copy link
Contributor

qaisjp commented Mar 7, 2019

btw if that is the case (you don't need spawnPlayer when you first join) then all my comments here are wrong, and this PR can be merged

@botder botder merged commit 5b257f9 into multitheftauto:master Mar 7, 2019
@botder botder modified the milestones: Backlog, 1.5.7 Mar 7, 2019
@qaisjp
Copy link
Contributor

qaisjp commented Mar 7, 2019

(an excellent 2 year misunderstanding, lol)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client 'isPedDead' returns 'false' when not yet spawned
5 participants