Unity3D Google admob:用户奖励两次(或更多)hack
Unity3D Google admob: User is reward twice (or more) hack
我创建了一个每日奖励系统,玩家每天可以获得大约三个 500 硬币,例如1/3金币。我使用Admob Unity Plugin显示玩家点击按钮获得500金币时的奖励视频,按钮可以点击3次,玩家每观看一次奖励视频,他们将获得500金币。
我的问题:
1:如果用户第一次点击奖励按钮并完整观看奖励视频,我的智力将增加到1,并奖励玩家500个硬币-(原来是500个硬币的1/3 )
2:如果用户第二次点击打赏按钮,然后决定关闭打赏视频,则int将不会增加,玩家not打赏500币-(依旧,500币1/3)
3:但是如果用户决定点击奖励按钮,然后决定完整观看新的奖励视频,则int将增加2(而不是1)玩家现在获得 1,000 金币(而不是 500)-(现在是 3/3 1,500 金币)
注意:此顺序不特定,用户可以从一开始或在 int 达到 3/3 之前执行此方法,并根据用户需要执行多次,只需关闭奖励视频很多时间(不完成视频)直到满意,然后将奖励视频完整观看 3 次。
我不会包含我的每日奖励脚本,因为我认为它不会导致我的问题。
请问哪位大侠能帮帮我,谢谢!!!!
这是我的奖励脚本:
{
public Admob ad;
public int clickInt = 0;
public Text clickText;
public Image coinImage;
public Button rewardButton;
void Awake()
{
if (PlayerPrefs.HasKey("amount"))
{
clickInt = PlayerPrefs.GetInt("amount");
}
}
void Start ()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#endif
}
// Update is called once per frame
void Update()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
ad = Admob.Instance ();
if (ad.isRewardedVideoReady ()) {
coinImage.enabled = true;
} else {
ad.loadRewardedVideo ("ca-app-pub-…………………/……………");
coinImage.enabled = false;
}
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
rewardButton.interactable = false;
}
#endif
}
public void Free_500_Coins()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
clickInt += 1;
ShopManager.Playercurrency += 500;
#elif UNITY_ANDROID
if (ad.isRewardedVideoReady ()) {
Admob.Instance().interstitalRewardHandler += onInterstitalRewardVideoEvent;
coinImage.enabled = true;
ad.showRewardedVideo ();
} else {
ad.loadRewardedVideo ("ca-app-pub-............/...........");
coinImage.enabled = false;
}
#endif
}
void onInterstitalRewardVideoEvent(string eventNames, string msgs)
{
if (eventNames == "onRewarded")
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
Debug.Log("Well Done! You got 500 coins");
clickInt += 1;
ShopManager.Playercurrency += 500;
Debug.Log("handler AdmobEventsHandler---" + eventNames + " " + msgs);
}
}
public void OnDestroy()
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
}
}```
只需将 if (ad.isRewardedVideoReady ()) {
更改为 if (ad.isRewardedVideoReady () && !coinImage.enabled) {
。
向调用 Free_500_Coins
的按钮发送垃圾邮件将导致两次调用添加处理程序。
您必须使用 + & - 从所有作业中删除 "onInterstitalRewardVideoEvent" 并在这些行下方添加。
void OnEnable() {
Admob.Instance().interstitalRewardHandler += onInterstitalRewardVideoEvent;
}
void OnDisable() {
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
}
我创建了一个每日奖励系统,玩家每天可以获得大约三个 500 硬币,例如1/3金币。我使用Admob Unity Plugin显示玩家点击按钮获得500金币时的奖励视频,按钮可以点击3次,玩家每观看一次奖励视频,他们将获得500金币。
我的问题:
1:如果用户第一次点击奖励按钮并完整观看奖励视频,我的智力将增加到1,并奖励玩家500个硬币-(原来是500个硬币的1/3 )
2:如果用户第二次点击打赏按钮,然后决定关闭打赏视频,则int将不会增加,玩家not打赏500币-(依旧,500币1/3)
3:但是如果用户决定点击奖励按钮,然后决定完整观看新的奖励视频,则int将增加2(而不是1)玩家现在获得 1,000 金币(而不是 500)-(现在是 3/3 1,500 金币)
注意:此顺序不特定,用户可以从一开始或在 int 达到 3/3 之前执行此方法,并根据用户需要执行多次,只需关闭奖励视频很多时间(不完成视频)直到满意,然后将奖励视频完整观看 3 次。
我不会包含我的每日奖励脚本,因为我认为它不会导致我的问题。 请问哪位大侠能帮帮我,谢谢!!!!
这是我的奖励脚本:
{
public Admob ad;
public int clickInt = 0;
public Text clickText;
public Image coinImage;
public Button rewardButton;
void Awake()
{
if (PlayerPrefs.HasKey("amount"))
{
clickInt = PlayerPrefs.GetInt("amount");
}
}
void Start ()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#endif
}
// Update is called once per frame
void Update()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
ad = Admob.Instance ();
if (ad.isRewardedVideoReady ()) {
coinImage.enabled = true;
} else {
ad.loadRewardedVideo ("ca-app-pub-…………………/……………");
coinImage.enabled = false;
}
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
rewardButton.interactable = false;
}
#endif
}
public void Free_500_Coins()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
clickInt += 1;
ShopManager.Playercurrency += 500;
#elif UNITY_ANDROID
if (ad.isRewardedVideoReady ()) {
Admob.Instance().interstitalRewardHandler += onInterstitalRewardVideoEvent;
coinImage.enabled = true;
ad.showRewardedVideo ();
} else {
ad.loadRewardedVideo ("ca-app-pub-............/...........");
coinImage.enabled = false;
}
#endif
}
void onInterstitalRewardVideoEvent(string eventNames, string msgs)
{
if (eventNames == "onRewarded")
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
Debug.Log("Well Done! You got 500 coins");
clickInt += 1;
ShopManager.Playercurrency += 500;
Debug.Log("handler AdmobEventsHandler---" + eventNames + " " + msgs);
}
}
public void OnDestroy()
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
}
}```
只需将 if (ad.isRewardedVideoReady ()) {
更改为 if (ad.isRewardedVideoReady () && !coinImage.enabled) {
。
向调用 Free_500_Coins
的按钮发送垃圾邮件将导致两次调用添加处理程序。
您必须使用 + & - 从所有作业中删除 "onInterstitalRewardVideoEvent" 并在这些行下方添加。
void OnEnable() {
Admob.Instance().interstitalRewardHandler += onInterstitalRewardVideoEvent;
}
void OnDisable() {
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
}