attribute in a CTmPlayer class

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
TheBigMiike
Posts: 1256
Joined: 06 Mar 2013, 16:12
Location: Vendée | France
Contact:

attribute in a CTmPlayer class

Post by TheBigMiike »

:)

I want your help again because I want to create an attribute in a CTmPlayer class in order to store the amount of times a player pressed the 'Restart' button but I read somewhere in the ManiaPlanet documentation (I'm not sure) that it was not possible.

So my decision was to create an array with the Player object as index and the count as value but I think there is a better solution for that so i'm wondering the following question :

My Question :
Is there an easier way to attach this data (The amount of restart times) to a player ?
Do you use this kind of array for these datas ? Else, which solution you use ?
Image Image
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: attribute in a CTmPlayer class

Post by Dommy »

http://maniascript.team-devota.com/stru ... esult.html

Player.CurRace / Player.CurLap
Score.BestRace / Score.PrevRace / Score.BestLap
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
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: attribute in a CTmPlayer class

Post by TGYoshi »

You can basically dynamically extend existing structures like CTmPlayer using

Code: Select all

declare Type blabla for playerinstance = default;
Then the "blabla" variable in that scope will belong to the playerinstance.
These values do not cross the server-client boundary, though.

You can add some "as alias" construct too to locally "rename" it, in case you have potentially conflicting variable names (e.g. when having two players in the same scope).
=3
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: attribute in a CTmPlayer class

Post by Dommy »

@Tiggs
For netwrite/netread it's good to send data arrays via Teams[0] with logins as keys. Then instead sharing custom data for player only (UI), you can also display custom data of spectated player.
Example:

Code: Select all

Net_PlayerHighestJump[Player.User.Login] = Player.Position.Y;
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
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest