How to get who is spectating who?

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

How to get who is spectating who?

Post by undef.de »

I know this, but with that i can only display a note at the spectating player, but i want to do something like this:
Image

Is there a possible way to get a list who is spectating who?
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: How to get who is spectating who?

Post by Dommy »

Attach custom interface layer that send netwrite data with spectated player login. In mode read this data for all spectators and merge data in array Text [Text] SpectatedPlayer[SpectatorLogin]. Send to the same layer netwrite with all data merged. Then you can easily access array with data who is spectating who.
Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT

Contact me via GALAXY & PURSUIT DISCORD
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: How to get who is spectating who?

Post by undef.de »

Thanks, that i already know... but i wanted to know if there is a easier way. 8-)
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: How to get who is spectating who?

Post by undef.de »

I'm working on that splitted getting and viewing thingy, my code looks like (simplified):

Getter

Code: Select all

main () {
	declare netwrite Text[Text] Net_RecordsEyepiece_SpectatingPlayers for Teams[0];
	Net_RecordsEyepiece_SpectatingPlayers[""^InputPlayer.Login] = ""^GUIPlayer.Login;
}
Widget

Code: Select all

main () {
	declare netread Text[Text] Net_RecordsEyepiece_SpectatingPlayers for Teams[0];
	log(Now ^" : "^ Net_RecordsEyepiece_SpectatingPlayers);
}
With for Teams[0] i get the error:

Code: Select all

The objects of type CGameTeamProfile does not support declaration of attribute Net_RecordsEyepiece_SpectatingPlayers.
With for Players[0] i get the error:

Code: Select all

The objects of type CTrackManiaPlayer does not support declaration of attribute Net_RecordsEyepiece_SpectatingPlayers.
With for UI i get the result:

Code: Select all

[]
Btw.: This codes are running in one of my plugins for UASECO.
EDIT: Is the above then CTmMlScriptIngame?
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: How to get who is spectating who?

Post by Dommy »

In manialink script

Code: Select all

main() {
    // Sends to gamemode spectated player login
    declare netwrite Text Net_PlayerSpectatorTarget for UI;
    
    // Receives from gamemode combined targets list: TargetLogin[SpectatorLogin];
    declare netread Text[Text] Net_SpectatedPlayers for Teams[0];
    
    while (True) {
        yield;
        
        if (IsSpectatorMode && GUIPlayer != Null) {
            Net_PlayerSpectatorTarget = GUIPlayer.User.Login;
        } else {
            Net_PlayerSpectatorTarget = "";
        }
        
        foreach (SpectatorLogin => TargetLogin in Net_SpectatedPlayers) {
            // ...
        }
    }
}
In gamemode script

Code: Select all

***StartServer***
***
// Send combined information about spectators
declare netwrite Text[Text] Net_SpectatedPlayers for Teams[0];
***

***PlayLoop***
***
// Clear array (avoid sending disconnected spectators logins)
Net_SpectatedPlayers.clear();

foreach (Player in Spectators) {
    // Receive who is spectated by player
    declare UI for Player <=> UIManager.GetUI(Player);
    
    if (UI != Null) {
        declare netread Text Net_PlayerSpectatorTarget for UI;
        // Add logins to combined array
        Net_SpectatedPlayers[Player.User.Login] = Net_PlayerSpectatorTarget;
    }
}
***
Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT

Contact me via GALAXY & PURSUIT DISCORD
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: How to get who is spectating who?

Post by undef.de »

for UI doesn't exist in my case and i also didn't have a gamemode script where i can add this (it should be used in all existing gamemodes), it is just a plugin in UASECO which sends a Manialink to the clients.
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: How to get who is spectating who?

Post by Dommy »

Then it's not possible :P
Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT

Contact me via GALAXY & PURSUIT DISCORD
User avatar
spaii
Posts: 1075
Joined: 19 Jun 2010, 00:04
Location: Rémy - France
Contact:

Re: How to get who is spectating who?

Post by spaii »

undef.de wrote: Getter

Code: Select all

main () {
	declare netwrite Text[Text] Net_RecordsEyepiece_SpectatingPlayers for Teams[0];
	Net_RecordsEyepiece_SpectatingPlayers[""^InputPlayer.Login] = ""^GUIPlayer.Login;
}
Widget

Code: Select all

main () {
	declare netread Text[Text] Net_RecordsEyepiece_SpectatingPlayers for Teams[0];
	log(Now ^" : "^ Net_RecordsEyepiece_SpectatingPlayers);
}
Not tested inside a controller, but this works inside a title, datas declared with "This" are present on all layers/manialinks, then this could be :
Getter

Code: Select all

main () {
	declare  Net_RecordsEyepiece_SpectatingPlayers for This = Text[Text];
	Net_RecordsEyepiece_SpectatingPlayers[InputPlayer.Login] = GUIPlayer.Login;
}
Widget

Code: Select all

main () {
	declare Net_RecordsEyepiece_SpectatingPlayers for This = Text[Text];
	log(Now ^" : "^ Net_RecordsEyepiece_SpectatingPlayers);
}
Bon courage ;)
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: How to get who is spectating who?

Post by undef.de »

spaii wrote: Not tested inside a controller, but this works inside a title, datas declared with "This" are present on all layers/manialinks, then this could be :
Getter

Code: Select all

main () {
	declare  Net_RecordsEyepiece_SpectatingPlayers for This = Text[Text];
	Net_RecordsEyepiece_SpectatingPlayers[InputPlayer.Login] = GUIPlayer.Login;
}
Widget

Code: Select all

main () {
	declare Net_RecordsEyepiece_SpectatingPlayers for This = Text[Text];
	log(Now ^" : "^ Net_RecordsEyepiece_SpectatingPlayers);
}
Does not work, because the Getter has to be run at a remote player client (Player A) and the Widget is your client (Player B). Otherwise GUIPlayer is not the spectated Player from Player A (see here for details).
spaii wrote:"This" are present on all layers/manialinks
Thanks for that info... good to know! :thx:
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: How to get who is spectating who?

Post by undef.de »

Small update: The error messages mentioned in viewtopic.php?p=245342#p245342 are always only for netwrite, because this code works in the Widget:

Code: Select all

declare netread Net_LibUI_Settings for Teams[0];
log(Net_LibUI_Settings);

Code: Select all

[
	TimeGap_Mode=>BestRace,
	TimeGap_Display=>True,
	TimeGap_Position=>23. -90. 5.,
	Chrono_Display=>True,
	Chrono_Position=>110.3 -80.5 5.,
	CheckpointTime_Mode=>BestRace,
	CheckpointTime_DisplayTimeDiff=>True,
	CheckpointTime_Display=>True,
	CheckpointTime_Position=>-8. 31.8 -10.,
	PrevBestTime_Display=>False,
	PrevBestTime_Position=>158. -67. 5.,
	SpeedAndDistance_Display=>False,
	SpeedAndDistance_Position=>158. -79.5 5.,
	Countdown_Display=>True,
	Countdown_Position=>105. -76.5 5.,
	IndependantLaps=>True,
	Countdown_CutOffTimeLimit=>26544717
]
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 3 guests