Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewarded video function to get reward #103

Open
burakgulmez opened this issue Sep 2, 2019 · 7 comments
Open

Rewarded video function to get reward #103

burakgulmez opened this issue Sep 2, 2019 · 7 comments

Comments

@burakgulmez
Copy link

burakgulmez commented Sep 2, 2019

OS target: Android
Godot version: 3.1
In _on_rewarded(currency, amount) function, what is currency and amount? Are they variable name in game? For example my game character has a variable named health. Should i write "health" to currency? How can i code the player gets reward after watching video? How can I connect variable and the rewarded function?

@Shin-NiL
Copy link
Collaborator

Shin-NiL commented Sep 2, 2019

These values are defined in the Admob backend. When the _on_rewarded callback is called, you'll get these values as the currency and amount arguments. So if on the Admob backend (Admob site) you've defined the string coin for currency and 5 for value and you call:

_on_rewarded(currency, amount):
    print(currency) # will print "coin"
    print(value) # will print "5"

@burakgulmez
Copy link
Author

If I write the code:

admob.showRewardedVideo()
$Player.health = 100

I cannot be sure the person watched the reward video. The person will get 100 health.

I tried this:

if admob._on_rewarded("$Player/health", 100):
   $Player.health = 100

but it doesnt work. Because it doesnt return true or false, and the parameters are false i think.

@Shin-NiL
Copy link
Collaborator

Shin-NiL commented Sep 2, 2019

First, you shouldn't pass the current and amount arguments, they will be returned from the admob server.

Second, you must call func _on_rewarded(currency, amount) and not admob._on_rewarded

Third, if the _on_rewarded is called it means the person watched the video, no need for a Boolean return here.

Please check the example code and the readme file to see how it works.

@gumaciel
Copy link
Collaborator

gumaciel commented May 5, 2020

@burakgulmez issue still persists?

@nyelare
Copy link

nyelare commented Jan 19, 2021

Why my on_rewarded(currency, amount) show this error
Parser Error: The identifier "currency" isn't declared in the current scope.
`func _on_reward_pressed():

if Ads.is_rewarded_video_loaded():
	Ads.show_rewarded_video()
	Ads._on_rewarded(currency, amount)
	print(currency)
	print(amount)`

I define in Admob site. reward type is money and amount is 10000

I hope you will help me with this. Thank you

@gumaciel
Copy link
Collaborator

Hey @nyelare , this function is a "callback function" this mean when AdMob receives a rewarded he will call this function into your game project, like this:

https://github.com/kloder-games/godot-admob/blob/master/examples/godot-3/main.gd#L108-L110

Please use the example project to see how module works: https://github.com/kloder-games/godot-admob/blob/master/examples/godot-3/

@nyelare
Copy link

nyelare commented Jan 21, 2021

@gustavottc okay thank you! I already got it <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants