[Solved]something like onPlayerDisconnect()?

Posts 1–11 of 11 · Page 1 of 1
[Solved]something like onPlayerDisconnect()?
Hey there,
so i want to set the same killstreaks for each player. I've done that with setPlayerData().
Of course i saved the original values for each player before changing it, so i could restore them. The problem is, i don't know when to call the restore function. When i "force" it manually, the code works, but i want it to automatically get called when a player leaves the game, or the game ends (not sure if this counts as the same, since the player leaves the game when it ends).
So i tried something like:
Code:
restore()
{
    for(;;)
    {
        level waittill( "disconnected", player);
        player restoreKillstreaks();
    }
}
where restore() gets called as a level thread on host connect (it works if i set it to waittill onplayercommand(blabla) ).
This is also how the onPlayerDisconnect function is written (forgot in what gsc, but i think it is in skill.gsc for example)
I also tried
Code:
level waittill_any("disconnected","disconnect","leaving","game_ended");
But that does not work either.
The only that is working, is when the game ends (it ends under special circumstances), with
Code:
level thread maps\mp\gametypes\_gamelogic::forceEnd();
foreach(player in level.players)
	player restoreKillstreaks();
Anyone got ideas on how to accomplish this?

thx
greetz
When a player disconnects (waittill("disconnect");), you can't do anything to him, he is not connected, how can you change something for someone that is not connected.
That is the reason why it doesn't work, for how to make it work, sorry can't answer, dunno.
Code:
level waittill( "game_ended" );
@master131
that does not work when the player leaves before the game is over, so he hast to rest his killstreaks manually.
But there has to be some kind of notification for the game when the player leaves, since a player is erased from the scoreboard when he leaves.
level waittill("leaving") or level waittill("leaving", player) does not work either, althoug the neccessaray notifactions exists(found it in
waittill_any( "crashing", "leaving" ) in file: _airdrop.gsc )

there has to be a method for this

ty


edit: i thought a bit, and my "gets erased from scoreboard" was no argument since the game will just wait for a disconnect notification and then look for who is still in the game (level.players) and erase every other entry.
So the only solution might be to catch a menuresponse and look if it was disconnect.
But thats not satisfying, since if the server crashes or i force ending the game, or the player disconnects via console, he will remain with "hacked" killstreaks....hmmm
Well the game has no way of predicting when a player leaves. The time period between leaving and disconnecting is too small so it's not possible.
ok then..
so is there a way to set all killstreaks the same for each player, without using setPlayerData, so that they are normal for the player when he connects to another server?

Thanks guys
Well I'm not sure because I've personally haven't changed killstreaks before. Maybe ask AZUMIKKEL?
yes there is
Code:
self maps\mp\gametypes\_class::setKillstreaks( ks1,ks2,ks3 )
Code:
for(;;)
{
level waittill("disconnect", player);//disconnect or disconnected (forgot)

player doStuff();
}
@bomb21
read my first post, already tried that
does not work.
Anyways found a workaround with the
Code:
self maps\mp\gametypes\_class::setKillstreaks( ks1,ks2,ks3 )
method, so this is solved.

thx
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us