Page 1 of 1
[ACS] retain a playernumber in a DISCONNECT script?
Posted: Fri Sep 11, 2020 10:23 pm
by FranckyFox2468
does anyone know how would you retain a playernumber in a DISCONNECT script? Cause im trying to make a script that destroy all of that player's summon upon switching team, class or leaving the game but only the last part doesnt seem to work and i dont want players to be harassed by a turret of a player that doesnt exist anymore.
If you can provide exemples it would really help cause the DISCONNECT section of the zdoom wiki isnt very clear on its function and INT.
If you wanna see my pathetic attempt without much knowledge:
script "Disconnectz" (int playernum) DISCONNECT
{
ACS_NamedExecuteWithResult("BreakShit", 0);
}
script "BreakShit" (void)
{
///This scripts destroy all active summons of the player when called.
///or well, atleast those that are meant to remain alive if their owner is dead.
int pnum = PlayerNumber();
SetActorState ((pnum + 1600), "Death", TRUE);
SetActorState ((pnum + 1700), "Death", TRUE);
SetActorState ((pnum + 1800), "Death", TRUE);
SetActorState ((pnum + 12000), "Death", TRUE);
SetActorState ((pnum + 12100), "Death", TRUE);
}
I also tried to directly make the "breakshit" script a disconnect script but it didnt change anything.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 12:37 am
by Kaminsky
The activator of any "Disconnect" script is always the world (except in (G)ZDoom where the activator is the player who left until after one tic), not the player who left. What you could do is pass the player ID as a parameter in "BreakShit" like so:
Code: Select all
Script "Disconnectz" (int playernum) Disconnect
{
ACS_NamedExecuteWithResult("BreakShit", playernum);
}
Script "BreakShit" (int pnum)
{
SetActorState((pnum + 1600), "Death", TRUE);
SetActorState((pnum + 1700), "Death", TRUE);
SetActorState((pnum + 1800), "Death", TRUE);
SetActorState((pnum + 12000), "Death", TRUE);
SetActorState((pnum + 12100), "Death", TRUE);
}
Alternatively, you could also paste the code from the "BreakShit" script into the disconnect script and keep only the first script.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 1:35 am
by FranckyFox2468
hm, thanks. Also i must ask, i assume i gotta establish playernum first or is this an automatic value of sort?
And i guess that with that in mind, i'm better off making a script that checks if the 64 players are active and those who arent has their stuff destroyed...
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 3:22 am
by Kaminsky
As with any disconnect-type script, the ID of the player who left (in this case it's "playernum") is automatically passed as a parameter, which you always need to define with the script. You can do whatever you want with this number except returning any information specific to the player actor that left (In Zandronum 3.0 the script is still executed after the player actor has already been destroyed, whereas (G)ZDoom changed it so that the script's executed before it happens).
I still recommend that you continue using your current script to remove the extra actors bound to the player(s), because it would be inefficient to have another script that needs to run every tic and check all 64 players to see which are active or not.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 4:44 am
by FranckyFox2468
Well not necessarily, cause if it is a world script only triggered if someone disconnects or goes spectator, then the script will only run when that happens.
Also going by your way i guess that means i have to define/assign it to a map parameter rather than inside a script then.
Also, i'm curious on your script, what would assinging playernum to arg1 do concidering it uses a different term "pnum" on the "breakshit" script?
Lastly, if i assign the ID to a parameter/int, will it be individual to all players? Because im worried it gets a bit fucky when it comes to having multiple people running the script.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 12:55 pm
by Kaminsky
FranckyFox2468 wrote:
Well not necessarily, cause if it is a world script only triggered if someone disconnects or goes spectator, then the script will only run when that happens.
I don't know what you mean by this. According to your OP, you want to remove the actors only when the player leaves/spectates, or if they switch teams (the latter requires a RESPAWN script to work by the way). You can learn more about the different types of scripts here:
https://zdoom.org/wiki/Script_types
FranckyFox2468 wrote:
Also going by your way i guess that means i have to define/assign it to a map parameter rather than inside a script then.
You must always declare a single argument in a DISCONNECT script, this represents the disconnecting player's ID. Otherwise, ACC will throw an error upon compilation.
FranckyFox2468 wrote:
Also, i'm curious on your script, what would assinging playernum to arg1 do concidering it uses a different term "pnum" on the "breakshit" script?
I was passing
playernum as a parameter into the "BreakShit" script, which was named as
pnum, just to be consistent with your code in the OP. As mentioned before, unless you plan on doing more with this "BreakShit" script, it's better to keep only the DISCONNECT script and use it like this:
Code: Select all
Script "Disconnectz" (int playernum) Disconnect
{
// Kills the actors connected to the player.
Thing_Destroy(playernum + 1600, 1, 0);
Thing_Destroy(playernum + 1700, 1, 0);
Thing_Destroy(playernum + 1800, 1, 0);
Thing_Destroy(playernum + 12000, 1, 0);
Thing_Destroy(playernum + 12100, 1, 0);
}
FranckyFox2468 wrote:
Lastly, if i assign the ID to a parameter/int, will it be individual to all players? Because im worried it gets a bit fucky when it comes to having multiple people running the script.
Multiple DISCONNECT scripts can be executed at the same time but the ID passed into them will be specific to each player(s) that leaves/spectates, so you don't need to worry about any conflicts between players.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sat Sep 12, 2020 4:35 pm
by FranckyFox2468
Ah so the int/parameter on a disconnect script is ALWAYS the player ID? Is it their TID or simply their playernumber?
Thanks a lot for the help. Will keep you updated on if it worked.
[ACS] Re: retain a playernumber in a DISCONNECT script?
Posted: Sun Sep 13, 2020 9:37 pm
by FranckyFox2468
Yeah it works pretty great, thanks. Main issue is that as you said, im gonna have to make a copy of the script to run in different circumstances and as i add new summons and such its gonna be a bit of a pain to work with lol.