Disconnect script [HELP] (SOLVED)

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Disconnect script [HELP] (SOLVED)

Re: Disconnect script [HELP]

by Barny-kun » Mon Dec 18, 2017 3:28 pm

Thank you guys, and also, thank you, Arctangent! The last comment made by you enlightened me :idea: Personally the variable thing is complexy to me, then i used something based on the other way you showed, that is checking if something stills exist on the map, and that is where the custom weapon used by the Seeker takes place (And also removing the custom weapon when the seeker dies, reseting everyones tid again and putting a little delay before the check)

Code: Select all

script 4 DEATH
{
    delay(10);
	if (ActivatorTID() == 1)
	{
         ACS_Execute(1, 0);
		 delay(1);
		 ACS_Terminate(8, 0);
		 delay(1);
		 ACS_Terminate(9, 0);
		 delay(1);
		 HudMessageBold(s:""; HUDMSG_PLAIN, 2, 0, 0, 0, 0);
		 delay(1);
		 SetFont("BIGFONT");
		 HudMessageBold(s:"\cr<\cf!\cr> \cfSeeker died! Choosing new one! \cr<\cf!\cr>"; HUDMSG_FADEOUT, 3, 0, 1.5, 0.4, 3.5); 
         delay(35);
		 ACS_Execute(3,0,0,0,0); //Choosing new Seeker
    }
}

script 5 (int playernum) DISCONNECT
{
	delay(10);
	if (CheckActorInventory(1, "SeekerEyes"))
	    {
        //
        }
        else
		{
		ACS_Execute(1, 0);
		delay(1);
	    ACS_Terminate(8, 0);
		delay(1);
		ACS_Terminate(9, 0);
		delay(1);
		HudMessageBold(s:""; HUDMSG_PLAIN, 2, 0, 0, 0, 0);
		delay(1);
		SetFont("BIGFONT");
		HudMessageBold(s:"\ciSeeker left the game! Choosing new one!"; HUDMSG_FADEOUT, 3, 0, 1.5, 0.4, 3.5); 
        delay(35);
		ACS_Execute(3,0,0,0,0); //Choosing new Seeker
		}
}
Well, it's working now. I hope that there isn't something more disastrous waiting its time to appear :)

Re: Disconnect script [HELP]

by Arctangent » Mon Dec 18, 2017 1:57 pm

You could store the player number of the seeker ( obtained through [wiki]PlayerNumber[/wiki] ) in a variable when the seeker is chosen, then compare the player number passed through the DISCONNECT script with that rather than using TIDs.

Alternatively, if the player object is gone by the time the DISCONNECT script runs ( which is something you'll have to test ), you could use [wiki]ThingCount[/wiki] to check if an actor with the TID exists, and if not, pick out a new seeker. Though in this case, you'd definitely want to use a much higher TID than 1 - that's a number incredibly likely to be used by maps, so stuff could easily go awry.

Re: Disconnect script [HELP]

by Barny-kun » Mon Dec 18, 2017 1:11 pm

This seems complexy :x I'm curious on how mods like AOW, Zombie Horde, Deathrun, WhoDunIt and the likes do to select a new pursuer when the actual one leaves while the match is running.. :o Here is the full script, just to complement, also in the hope that someone find the issue:
Spoiler:
If someone know another way to prevent the game from breaking when the a seeker leaves while the match is running by choosing another seeker among the remaining players, please tell me.

Re: Disconnect script [HELP]

by phantombeta » Mon Dec 18, 2017 12:16 pm

DISCONNECT scripts have the world as the activator, so that won't work. That's what the "playernum" variable is there for.
The player's actor is already gone by the time DISCONNECT scripts run, I believe.

Edit:
The wiki wrote:[wiki=Script_types#DISCONNECT]A DISCONNECT script must be declared with a single argument. ZDoom will pass the number of the disconnecting player into this variable. Because the player has already left the game by the time this script is called, no actions can be taken on that player. The script is executed by the world itself.

Disconnect scripts activate immediately before the player actor is destroyed, setting the leaving player as the activator instead of the world. Note that any delays or waiting will cause the script to reset the activator back to the world.[/wiki]
The wiki is contradicting itself on this one. From my experience with DISCONNECT, though, I'd say the former is the correct one.

Re: Disconnect script [HELP]

by wildweasel » Mon Dec 18, 2017 12:12 pm

This script doesn't outwardly have anything wrong with it; I'd imagine the problem lies in whatever mechanism is setting the tid on players (script 3, I'd imagine, since that's the one being ACS_Executed at the end of this one).

Disconnect script [HELP] (SOLVED)

by Barny-kun » Mon Dec 18, 2017 11:22 am

Can someone help me? Why isn't this script working:

Code: Select all

script 5 (int playernum) DISCONNECT   //I didn't get this part.. How to identify if the one leaving is the seeker, only executing the other script if it is him? :x 

{
    if (ActivatorTID() == 1)   //The tid of the seeker is 1
    {    
         SetFont("BIGFONT");
         HudMessageBold(s:"\ciSeeker left the game! Choosing new one!"; HUDMSG_FADEOUT, 3, 0, 1.5, 0.4, 3.5);
         delay(35);
         ACS_Execute(3,0,0,0,0);   //here i choose a new seeker
    }
}
I suck at scripting, i tried reading the wiki, but i didn't get how to make it.. I wanted the script to activates another script only if a certain player (the seeker) leaves the game, so i could choose a new player to be the seeker, but it isn't working.. How to identify if the one leaveing has the tid required, the seeker tid, and if the one who left isn't the seeker, nothing happens? :(

Top