Disconnect script [HELP] (SOLVED)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

Disconnect script [HELP] (SOLVED)

Postby Barny-kun » Mon Dec 18, 2017 12:22 pm

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

Code: Select allExpand view
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? :(
Last edited by Barny-kun on Mon Dec 18, 2017 4:36 pm, edited 1 time in total.
User avatar
Barny-kun
 
Joined: 03 May 2017
Location: Inside your mind
Discord: Thank you all for existing!

Re: Disconnect script [HELP]

Postby wildweasel » Mon Dec 18, 2017 1: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).
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: Disconnect script [HELP]

Postby phantombeta » Mon Dec 18, 2017 1:16 pm

User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Disconnect script [HELP]

Postby Barny-kun » Mon Dec 18, 2017 2: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.
User avatar
Barny-kun
 
Joined: 03 May 2017
Location: Inside your mind
Discord: Thank you all for existing!

Re: Disconnect script [HELP]

Postby Arctangent » Mon Dec 18, 2017 2:57 pm

You could store the player number of the seeker ( obtained through PlayerNumber ) 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 ThingCount 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.
User avatar
Arctangent
squawky
 
Joined: 06 Nov 2014
Discord: SquawkyAtan#2371

Re: Disconnect script [HELP]

Postby Barny-kun » Mon Dec 18, 2017 4: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 allExpand view
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 :)
User avatar
Barny-kun
 
Joined: 03 May 2017
Location: Inside your mind
Discord: Thank you all for existing!


Return to Scripting

Who is online

Users browsing this forum: No registered users and 3 guests