void MCAdExecCreateAd(MCExecContext& ctxt, const char *p_name, MCAdType p_type, MCAdTopLeft p_top_left, MCVariableValue *p_meta_data) { bool t_success; t_success = true; if (s_inneractive_ad_key == nil || MCCStringLength(s_inneractive_ad_key) == 0) { ctxt.SetTheResultToStaticCString("not registered with ad service"); t_success = false;; } MCAd *t_ad; t_ad = nil; if (t_success) if (MCAd::FindByNameOrId(p_name, t_ad)) { ctxt.SetTheResultToStaticCString("ad already exists"); t_success = false; } if (t_success) { uint32_t t_timeout; if (t_success) { t_timeout = 0; if (p_meta_data != nil && p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "refresh", false)) t_timeout = ctxt.GetEP().getint4(); if (p_type == kMCAdTypeFullscreen) t_timeout = 0; else if (t_timeout < 30 || t_timeout > 500) t_timeout = 120; } if (t_success) t_success = MCSystemInneractiveAdCreate(ctxt, t_ad, p_type, p_top_left, t_timeout, p_meta_data); if (t_success) t_success = t_ad->Create(); if (t_success) { t_ad->SetNext(s_ads); t_ad->SetName(p_name); t_ad->SetOwner(ctxt.GetObjectHandle()); s_ads = t_ad; } else if (t_ad != nil) t_ad->Release(); } if (!t_success) ctxt.SetTheResultToStaticCString("could not create ad"); }