Guest User

Untitled

a guest
Jun 16th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. oCtrlAdd.Create Event
  2.  
  3. globalvar money;
  4. money = 0;
  5. rewarded_viewed = "";
  6. //Check what OS the client is running - Set ID's from ADmob.
  7. if os_type == os_android
  8. {
  9. app_id = "ca-app-pub-4337965814269841~8766033236";
  10. interstitial_id = "ca-app-pub-3940256099942544/8691691433";
  11. banner_id = "ca-app-pub-3202039677277756/8024372905";
  12. rewarded_id = "ca-app-pub-3202039677277756/9445567106";
  13. }
  14. //Initialize googlemobileads
  15. GoogleMobileAds_Init(interstitial_id, app_id);
  16. GoogleMobileAds_LoadInterstitial();
  17. interstitial_loaded = false;
  18.  
  19. //get the video & load it
  20. GoogleMobileAds_LoadRewardedVideo(rewarded_id);
  21.  
  22. //use test ads as to not get banned by admob
  23. GoogleMobileAds_UseTestAds(true, "E3DAE5ACB5072BA36197B94E287927C9");
  24.  
  25.  
  26. //add banner
  27. GoogleMobileAds_AddBanner(banner_id,GoogleMobileAds_Banner);
  28.  
  29. //add banner @ location
  30. /*
  31. GoogleMobileAds_AddBannerAt(banner_id,GoogleMobileAds_Banner,x,y);
  32. */
  33.  
  34. oCtrlAdd.Step Event
  35.  
  36. //Check if interstitial is loaded, if it is, show the interstitial ad
  37. if interstitial_loaded == true
  38. {
  39. interstitial_loaded = false;
  40. GoogleMobileAds_ShowInterstitial();
  41. }
  42.  
  43. oCtrlAdd.Draw GUI Event
  44.  
  45. /// @description Insert description here
  46. // You can write your code in this editor
  47. draw_set_halign(fa_center);
  48. draw_set_valign(fa_center);
  49. draw_set_color(c_white);
  50. draw_set_font(font0);
  51. draw_text(room_width / 2, room_height / 2, money);
  52.  
  53. oCtrlAdd.Async-Social Event
  54.  
  55. /// @description Insert description here
  56. // You can write your code in this editor
  57.  
  58. //handle rezising of the Banner by grabbing the height & width from both GoogleMobileAds & client-side
  59. var _id = async_load[? "type"];
  60. if _id == GoogleMobileAds_ASyncEvent
  61. {
  62. var ident = async_load[? "type"] == 1
  63. switch (ident)
  64. {
  65. case "banner_load":
  66. if async_load[? "loaded"] == 1
  67. {
  68. var _bw = GoogleMobileAds_BannerGetWidth();
  69. var _bh = GoogleMobileAds_BannerGetHeight();
  70. var _hh = display_get_height();
  71. var _ww = display_get_width();
  72. GoogleMobileAds_MoveBanner((_ww / 2) - (_bw / 2), _hh - _bh);
  73. }
  74. break;
  75. }
  76. }
  77.  
  78. //rewarded ads
  79. var ident2 = async_load[? "type"];
  80. switch (ident2)
  81. {
  82. case "rewardedvideo_adopened":
  83. show_debug_message("Rewards Video Opened");
  84. break;
  85. case "rewardedvideo_videostarted":
  86. show_debug_message("Rewards Video Started");
  87. break;
  88. case "rewardedvideo_watched":
  89. show_debug_message("Rewards Video Watched");
  90. rewarded_viewed = true;
  91. money += async_load[? "amount"];
  92. break;
  93. case "rewardedvideo_adclosed":
  94. show_debug_message("Rewards Video Closed");
  95. if rewarded_viewed = false
  96. {
  97. //Video was closed before the end
  98. }
  99. else
  100. {
  101. rewarded_viewed = false;
  102. }
  103. GoogleMobileAds_LoadRewardedVideo("rewarded_id");
  104. break;
  105. }
  106.  
  107. oInterstitial.Draw GUI Event
  108.  
  109. /// @description Insert description here
  110. // You can write your code in this editor
  111. draw_set_font(font0);
  112. draw_set_valign(fa_center);
  113. draw_set_halign(fa_center);
  114. draw_set_color(c_black);
  115. draw_text(x,y,"Interstitial");
  116.  
  117. oInterstitial.Left Pressed Event
  118.  
  119. /// @description Insert description here
  120. // You can write your code in this editor
  121. if GoogleMobileAds_InterstitialStatus() == "Ready"
  122. {
  123. if oCtrlAdd.interstitial_loaded != true
  124. {
  125. oCtrlAdd.interstitial_loaded = true;
  126. }
  127. }
  128. else
  129. {
  130. room_goto(room0);
  131. }
  132.  
  133. oRewardedAdd.Draw GUI Event
  134.  
  135. /// @description Insert description here
  136. // You can write your code in this editor
  137. draw_set_font(font0);
  138. draw_set_valign(fa_center);
  139. draw_set_halign(fa_center);
  140. draw_set_color(c_black);
  141. draw_text(x,y,"Rewarded");
  142.  
  143. oRewardedAdd.Left Pressed Event
  144.  
  145. /// @description Insert description here
  146. // You can write your code in this editor
  147. if GoogleMobileAds_RewardedVideoStatus() == "Ready"
  148. {
  149. GoogleMobileAds_ShowRewardedVideo();
  150. }
Add Comment
Please, Sign In to add comment