[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 »

My mistake!

Try

Code: Select all

sleep(50);
OR

Code: Select all

wait(ScoreMgr != Null);
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [Help] SkillPoints number in Manialink

Post by adamkooo2 »

I've written this:

Code: Select all

wait(ScoreMgr != Null);
(Page.GetFirstChild("SP") as CMlLabel).SetText(""^ ScoreMgr.Campaign_GetSkillPoints(LocalUser.Id, DataFileMgr.Campaigns[0].CampaignId));
No error shows up, but the label with id "SP" has not written the skillpoints number
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

Alright, I think it's time to do it from a different context. Here's what I propose :

You should find the number of skillpoints from the main menu, then give it to the page using a variable for Page, and then the layer should get that variable and display it.

Can I find your code somewhere so I can see what's best to suggest?
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: 11 Sep 2017, 13:23 Alright, I think it's time to do it from a different context. Here's what I propose :

You should find the number of skillpoints from the main menu, then give it to the page using a variable for Page, and then the layer should get that variable and display it.

Can I find your code somewhere so I can see what's best to suggest?
Here's my code:
solo.xml
https://www.dropbox.com/s/w1ohs1xodzhjupd/Solo.xml?dl=0

TM2UF Menu.Script.txt
https://www.dropbox.com/s/zzlm6bix5jm68 ... t.txt?dl=0

Media/images folder:
https://www.dropbox.com/sh/9y3omqesbrcm ... wm8ra?dl=0

I will try to do something, but I think that I won't be successful as poor as my maniascripting skill is :mrgreen:
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

First things first : replace every

Code: Select all

//--------------------------------------Race-->WH
into

Code: Select all

//--------------------------------------Race==>WH
I am afraid that this might change the behavior of the layer, since --> is only used to close a script tag.

Also, put all the lines of code at the beginning of the main().

Code: Select all

wait(ScoreMgr != Null);
    (Page.GetFirstChild("SP") as CMlLabel).SetText(""^ ScoreMgr.Campaign_GetSkillPoints(LocalUser.Id, DataFileMgr.Campaigns[0].CampaignId));
    //(Page.GetFirstChild("Rank") as CMlLabel).SetText(""^ ScoreMgr.CampaignLeaderBoard_GetPlayerRanking(LocalUser.Id, DataFileMgr.Campaigns[0].CampaignId, LocalUser.ZonePath, False));
    (Page.GetFirstChild("zone") as CMlLabel).SetText(LocalUser.ZonePath);
    (Page.GetFirstChild("country") as CMlQuad).ImageUrl = LocalUser.ZoneFlagUrl;
        log("Successfully opened TM2UF campaign manialink");
        while(True)
        {...
This way we can make sure that those lines of code are being called :)
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [Help] SkillPoints number in Manialink

Post by adamkooo2 »

I've tried to put the code at the beginning and now I am not able to show/hide frames with script, I've deleted the --> symbols, nothing helped
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

When pressing Ctrl + G, do you see the log "Successfully opened TM2UF campaign manialink" ?
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: 12 Sep 2017, 09:12 When pressing Ctrl + G, do you see the log "Successfully opened TM2UF campaign manialink" ?
I have an solution to the whole problem. I will include the first frame of solo.xml to main menu script with charts, so game will be able to load the datas, so no error will be thrown. I will write here if a problem wll occur :)
/\rkady
Image
User avatar
Qlex
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: [Help] SkillPoints number in Manialink

Post by Qlex »

That seems good!

A way of doing it could be that solo.xml demands the amount of SP whenever it is shown :

Code: Select all

SendCustomEvent("solo", ["ask_skillpoints"]);
Then the Menu.Script.txt catches that event and sends back the amount of SP :

Code: Select all

if (Event.CustomEventType == "solo") {
		switch (Event.CustomEventData[0]) {
			case "ask_skillpoints" : {
				declare CUILayer SoloLayer = Event.CustomEventLayer;
				declare Integer Page_SoloSP for SoloLayer.LocalPage;
				Page_SoloSP = ScoreMgr.Campaign_GetSkillPoints(UserMgr.MainUser.Id, DataFileMgr.Campaigns[0].CampaignId);
				LayerCustomEvent(SoloLayer , "skillpoints_sent", Text[]);
			}
THEN, solo.xml catches the event in a similar way to the Menu. Put this in the loop :

Code: Select all

		foreach(Event in PendingEvents) {
			switch (Event.Type) {
				case CMlScriptEvent::Type::PluginCustomEvent: {
					switch (Event.CustomEventType) {
						case "skillpoints_sent" : {
							declare Integer Page_SoloSP for Page;
							(Page.GetFirstChild("SP") as CMlLabel).SetText(""^ Page_SoloSP);
						}
					}
				}
			}
		}
And it should work.

The reason why none of the other solutions worked was because I tried to limit the amount of work you had to do by restricting it to the layer, but it turns out the menu has to do it : ScoreMgr doesn't get instantiated in the layer. LocalUser.Id doesn't work either, it needs to be UserMgr.MainUser.Id or else the SP might behave erratically.

Sorry for the inconvenience! This should be good now. Tell me if you encounter any errors :)
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 a problem (again :? )
The datas showning seems wrong.
Image
If I go to default solo, I see that I am fisrt on the world, but here's displayed that I am second. Also the number of skillpoints is 0.
Image
/\rkady
Image
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: Google [Bot] and 1 guest