[Help] [Solved] SkillPoints number in Manialink

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

Check if the affectation worked :

Code: Select all

		foreach(Event in PendingEvents) {
				log(Now ^ ") Event received. Event.Type : " ^ Event.Type ^ ", Event.CustomEventType : " ^ Event.CustomEventType);
			switch (Event.Type) {
				case CMlScriptEvent::Type::PluginCustomEvent: {
					switch (Event.CustomEventType) {
						case "skillpoints_sent" : {
							declare Integer Page_SoloSP for Page;
							log(Now ^ ") Skillpoints received by layer : " ^ Page_SoloSP);
							(Page.GetFirstChild("SP") as CMlLabel).SetText(""^ Page_SoloSP);
						}
					}
				}
			}
		}
If you don't see the line "Skillpoints received by layer" when in the TM2UF menu (Ctrl + G), that means the solo.xml does not receive the correct Event
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [Help] SkillPoints number in Manialink

Post by adamkooo2 »

I have included the main frame of solo.xml to TM2UF menu.script.txt, so values are loaded (but wrong numbers, it looks skillpoints label displays leaderpoints, and rank label displays amount of players in country of player login).
I will try to send the evnt to solo.xml or do you think it will be possible to include the manialink and hide frames of the included ML?
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

If you have values that are not zero then I think your method is good.

Check if you're using this line :

Code: Select all

ScoreMgr.Campaign_GetSkillPoints(UserMgr.MainUser.Id, DataFileMgr.Campaigns[0].CampaignId)
some other methods of the class CScoreMgr might be used on accident, like MapLeaderBoard_GetPlayerCount or CampaignLeaderBoard_GetPlayerCount.
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [Help] SkillPoints number in Manialink

Post by adamkooo2 »

Thx, but it it does not work. An error ocurred:

Code: Select all

ERROR [58, 48] The member or variable UserMgr does not exist.
ERROR [58, 48] The dot operator '.' must be applied to a class or a vector
ERROR [58, 57] The dot operator '.' must be applied to a class or a vector
ERROR [58, 16] Incorrect arguments to call the function Campaign_GetSkillPoints
I had to replace UserMgr.MainUser.Id with LocalUser.Id to make it work
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

Is LocalUser.Id giving you the correct results? If not, try calling this function with UserMgr.MainUser.Id, but in the Menu.Script.txt, not in solo.xml
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [Help] SkillPoints number in Manialink

Post by adamkooo2 »

Qlex wrote: 20 Sep 2017, 08:29 Is LocalUser.Id giving you the correct results?
No, it shows wrong number (2 instead of 1; yes I was 2nd in past but now I am first)
Qlex wrote: 20 Sep 2017, 08:29 try calling this function with UserMgr.MainUser.Id
It causes errors:
adamkooo2 wrote: 19 Sep 2017, 18:18

Code: Select all

ERROR [58, 48] The member or variable UserMgr does not exist.
ERROR [58, 48] The dot operator '.' must be applied to a class or a vector
ERROR [58, 57] The dot operator '.' must be applied to a class or a vector
ERROR [58, 16] Incorrect arguments to call the function Campaign_GetSkillPoints
/\rkady
Image
zocka
Posts: 205
Joined: 15 Jun 2010, 17:56

Re: [Help] SkillPoints number in Manialink

Post by zocka »

UserMgr is available in your CManiaApp (or CManiaAppTitle). Everytime you are in your UI-Manialink-script (UILayer.ManialinkPage = """...<script>{{{here}}}</script>...""") you have the context CMlScript (or CManiaAppTitleLayer). You can always check with log(This); which should give you something like (CManiaAppTitle*)???. Then you can look at the documentation and see what is available and what isn't.

For you this means you would have your call to ScoreMgr.Campaign_GetSkillPoints(UserMgr.MainUser.Id, SomeCampaign.CampaignId)); (SomeCampaign being e.g. DataFileMgr.Camapaings[0] if this is your campaign) in your TM2UF Menu.Script.txt and then you would pass the result to the UILayer.ManialinkPage. Either into the string, e.g.

Code: Select all

SPLayer.ManialinkPage = """<manialink version="3">
<label textprefix="Skillpoints: " text="{{{SkillPoints}}}" />
</manialink>
or as variable for you Page like Qlex explained: viewtopic.php?f=279&t=42482&start=10#p291221

Unfortunately I can't give you a minimal working example as it seems that I somehow failed to make a valid campaign configuration xD

On a more general note:
I would suggest using different layers for your different views and hide and show them according to scriptactions you pass from your UI-Manialink to your CManiaAppTitle-script (e.g. <label text="Solo" scriptaction="showview'solo" />, then catch it like you do with the CustomEventType "editors" and hide your UI-Layers accordingly). Splitting your views into multiple manialinks makes it a lot more readable and maintainable. (And you can set a "name" attribute on the manialink-tags which will be displayed in the debugger; sometimes it helps having a look at how Nadeo does things ;) )
manialink minigame shatter
my manialink: zockaml
my maniaflash: maniaflash?zocka
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest