ADS and how to use currencies
Posted: 08 Sep 2020 10:24
by ShimaHyou
Hello :D ,
So I have 2 currencies "tickets" to read chapters and "diamonds" to select premium choices and I have an ADS script, so I want to trigger the ADS and subtract one ticket at the start of each naninovel script.
And know how to add premium choices with diamonds currencies?
I get this answer on unity store:
"For premium choices you can make use of a custom choice handler; see the guide for more info: https://naninovel.com/guide/choices.htm ... e-handlers Alternatively, you can use conditional script execution (https://naninovel.com/guide/naninovel-s ... execution) to show the premium choices only in case they're available. To check the availability of choices, a custom script expression function (https://naninovel.com/guide/script-expr ... -functions) can be used. There are multiple ways to show an ad at the end of a script; the easiest would probably be via a custom command: https://naninovel.com/guide/custom-commands or with @showUI
built-in command and a custom UI (https://naninovel.com/guide/user-interf ... tomization)."
I tried but I can't seem to understand how to use UI custom or custom choice :? , English is not my language so trying to understand the doc it's not easy.
Re: ADS and how to use currencies
Posted: 08 Sep 2020 11:56
by Elringus
Hey, Please clarify what exactly you have issues with by describing what you're doing step by step, what you expect to happen and what is actually happening.
Re: ADS and how to use currencies
Posted: 12 Sep 2020 20:36
by ShimaHyou
hello, so for what I already do I seriously don't remember, so for premium choices https://ibb.co/HVPt78S, yesterday I test something new which work, even though I'm sure they're a more easy solution do to this, I create a "choice handler" with this method
Code: Select all
public void Pegi18Choice()
{
if (playFabManager.Player_Rubis >= 64)
{
playFabManager.Player_Rubis -= 64;
txtRubis.text = playFabManager.Player_Rubis.ToString();
}
else
{
playFabManager.LoadingMessage("not enough diamonds");
playFabManager.LoadingHide();
}
}
in inspector button "on click" https://ibb.co/0qKyMVy so I will have to create a "choice handler" per choice, but now I need to add a condition, if player click on the premium choice and don't have enough diamonds make the player impossible to continue until he has enough diamonds to select premium choice or choose the free choice.
as for the tickets and ADS, one ticket it's to read one chapter(NaniNovel Script) so when you get to 0 ticket I need to make it impossible to start the next chapter, but I don't know how to run these scripts at the start of each NaniNovel script:
ADS Script:
Code: Select all
public class ADS : MonoBehaviour
{
string gameId = "000000";
//bool testMode = true;
void Start()
{
// Initialize the Ads service:
Advertisement.Initialize(gameId);
ShowInterstitialAd();
}
public void ShowInterstitialAd()
{
// Check if UnityAds ready before calling Show method:
if (Advertisement.IsReady())
{
Advertisement.Show();
}
else
{
Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
}
}
}
Tickets Script:
Code: Select all
public void DownTickets()
{
tickets -= 1;
Debug.Log(tickets);
}
Re: ADS and how to use currencies
Posted: 12 Sep 2020 20:44
by Elringus
Just use a custom command to run a C# script at any point inside a naninovel script: https://naninovel.com/guide/custom-commands
It's also possible to subscribe for OnPlay
event of IScriptPlayer
engine service.
Re: ADS and how to use currencies
Posted: 20 Sep 2020 10:03
by ShimaHyou
Hello and thank you, I finally understand how to use custom command.
Do you know what I need to use to prevent the player to go to the next NaniNovel script if he has zero ticket?
Code: Select all
public class TicketStory : Command
{
PlayFabManager playFabManager;
int ticketAmmount;
public override UniTask ExecuteAsync(CancellationToken cancellationToken = default)
{
playFabManager = GameObject.Find("PlayFabManager").GetComponent<PlayFabManager>();
DownTicket();
return UniTask.CompletedTask;
}
public void DownTicket()
{
if (playFabManager.Player_Tickets >= 1)
{
playFabManager.Player_Tickets -= 1;
ticketAmmount = 1;
SubstractTK(ticketAmmount);
}
else
{
playFabManager.LoadingMessage("not enough ticket");
playFabManager.LoadingHide();
}
}
void SubstractTK(int ammount)
{
var request = new SubtractUserVirtualCurrencyRequest()
{
VirtualCurrency = "TK",
Amount = ammount
};
PlayFabClientAPI.SubtractUserVirtualCurrency(request, SubSuccess, SubFailed);
}
private void SubFailed(PlayFabError err)
{
//
}
private void SubSuccess(ModifyUserVirtualCurrencyResult result)
{
//
}
}
and how to force the game to stay on the choices until the player have enough diamonds to choose a premium choice or the free choice? I have a normal script:
Code: Select all
public class PegiChoices : MonoBehaviour
{
[SerializeField] Text txtRubis;
PlayFabManager playFabManager;
private int pegiChoiceAmmount;
private void Awake()
{
playFabManager = GameObject.Find("PlayFabManager").GetComponent<PlayFabManager>();
txtRubis.text = playFabManager.Player_Rubis.ToString();
}
public void Choice1()
{
if (playFabManager.Player_Rubis >= 30)
{
playFabManager.Player_Rubis -= 30;
//PlayFab Sync Data
pegiChoiceAmmount = 30;
SubstractRB(pegiChoiceAmmount);
}
else
{
playFabManager.LoadingMessage("not enough rubis");
playFabManager.LoadingHide();
}
}
}
Re: ADS and how to use currencies
Posted: 21 Sep 2020 13:30
by Elringus
You can add custom expression functions and use them in the "if" statements of scenario scripts: https://naninovel.com/guide/script-expr ... -functions
Re: ADS and how to use currencies
Posted: 03 Oct 2020 08:32
by ShimaHyou
Hello,
I take a look but I don't understand how to use it for my case, I'm going to see if someone on discord can explain.
thank you for the direction :D.