Cmap Maniascript Problem

Talk here if you need help about Maniaplanet or its games

Moderator: English Moderator

Post Reply
Sheiken
Posts: 12
Joined: 23 Apr 2016, 01:38

Cmap Maniascript Problem

Post by Sheiken »

Hi, I trying to get the Autor Time in my UI when I play a Local Network on Stadium, but i dont know the sintaxis in the script, so i try to modified the module Lib_UI:PrevBestTime in UI.Script.txt(i made the copy to moding) to start. Looking for groping in the documentation I found this class called Cmap http://maniascript.team-devota.com/struct_c_map.html and the atribute call TMObjective.

So i think put in the Module Lib_UI:PrevBestTime in UI.Script.txt a script that shows me the time author in a label when I start map (the label has a id="Label_AuthorTime").

The problema is:
What I've been able to learn looking at the script of the game itself sometimes have to declare certain things and when I see the documentation I have no clear when declare certain things depending on circumstances.

Then what I ask is that someone explain to me how to use the CMap class within the UI file.Script.txt or better still, to correctly read the documentation.

A image https://www.dropbox.com/s/cvvmenjsi8oobdl/Help.png?dl=0

Thx for read this! :oops: :?
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: Cmap Maniascript Problem

Post by Dommy »

All scripts run in their own context. A context is basically an instance of class (object), which attributes are globally available in the script.

The context you are looking for is CTmMlScriptIngame - it's set of attributes available for TrackMania ingame manialinks. You can use things like Players array to loop through all player objects on the server. Please also note, this class extends CMlScriptIngame, which contains attributes common between ShootMania and TrackMania (like Map in your case). CMlScriptIngame is also extending another class, CMlScript, which is essentially set of all attributes and methods (functions) available for manialinks used anywhere (both ingame and in the browser). It also extends CNod, but it's just adding ID to the class, so don't mind that.

For the author time, you will have to use

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
which will convert author time milliseconds to a Text and apply it to the label. You could also try using Map.ObjectiveTextAuthor to have the author time directly as Text, but I'm unsure if it's working correctly.

Hope i helped. :thumbsup:
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
Sheiken
Posts: 12
Joined: 23 Apr 2016, 01:38

Re: Cmap Maniascript Problem

Post by Sheiken »

domino54 wrote: 19 Apr 2017, 11:42 All scripts run in their own context. A context is basically an instance of class (object), which attributes are globally available in the script.

The context you are looking for is CTmMlScriptIngame - it's set of attributes available for TrackMania ingame manialinks. You can use things like Players array to loop through all player objects on the server. Please also note, this class extends CMlScriptIngame, which contains attributes common between ShootMania and TrackMania (like Map in your case). CMlScriptIngame is also extending another class, CMlScript, which is essentially set of all attributes and methods (functions) available for manialinks used anywhere (both ingame and in the browser). It also extends CNod, but it's just adding ID to the class, so don't mind that.

For the author time, you will have to use

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
which will convert author time milliseconds to a Text and apply it to the label. You could also try using Map.ObjectiveTextAuthor to have the author time directly as Text, but I'm unsure if it's working correctly.

Hope i helped. :thumbsup:
Thanks Dommy, Let me see if I understand:

-It is not necessary to use#Include and #RequireContext because CMlScript, CMlScriptIngame and CTmMlScriptIngame are always available.

-The Code :

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
When Label=Id of the label declared in the manialink.

And , it Works, Thanks for the prompt response. :1010
Post Reply

Return to “Support & Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest