diff --git a/baystation12.dme b/baystation12.dme index bd8b2f0d125..46070a71dde 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -30,6 +30,7 @@ #include "code\__HELPERS\sanitize_values.dm" #include "code\__HELPERS\text.dm" #include "code\__HELPERS\time.dm" +#include "code\__HELPERS\timed_alerts.dm" #include "code\__HELPERS\type2type.dm" #include "code\__HELPERS\unsorted.dm" #include "code\_hooks\area.dm" diff --git a/code/__HELPERS/timed_alerts.dm b/code/__HELPERS/timed_alerts.dm new file mode 100644 index 00000000000..c7293762dd3 --- /dev/null +++ b/code/__HELPERS/timed_alerts.dm @@ -0,0 +1,37 @@ +/client/var/timed_alert/timed_alert + +/client/proc/timed_alert(question as text, title as text, default as text, time = 300, \ + choice1 as text, choice2 as text, choice3 as text) + + if(timed_alert) del(timed_alert) + var/timed_alert/ref_alert = new + timed_alert = ref_alert + + var/ref_result + + ref_result = ref_alert.timed_alert(src, question, title, time, choice1, choice2, choice3) + if (!ref_result) ref_result = default + + if (ref_alert) del(ref_alert) + + return ref_result + + +/mob/proc/timed_alert(question as text, title as text, default as text, time as num, \ + choice1 as text, choice2 as text, choice3 as text) + + if (client) client.timed_alert(question, title, default, time, choice1, choice2, choice3) + return + + + +/timed_alert/proc/timed_alert(client/ref_client, question, title, time, choice1, choice2, choice3) + if (!ref_client) return + spawn (time) del src // When src is deleted, the proc ends immediately. The alert itself closes. + + var/ref_answer + ref_answer = alert(ref_client, question, title, choice1, choice2, choice3) + + if(!ref_client || !ref_answer) return + else return ref_answer + diff --git a/code/modules/admin/verbs/one_click_antag.dm b/code/modules/admin/verbs/one_click_antag.dm index 20db8a06135..eac93685bc1 100644 --- a/code/modules/admin/verbs/one_click_antag.dm +++ b/code/modules/admin/verbs/one_click_antag.dm @@ -155,7 +155,7 @@ client/proc/one_click_antag() for(var/mob/G in respawnable_list) if(!jobban_isbanned(G, "wizard") && !jobban_isbanned(G, "Syndicate")) spawn(0) - switch(alert(G, "Do you wish to be considered for the position of Space Wizard Foundation 'diplomat'?","Please answer in 30 seconds!","Yes","No")) + switch(G.timed_alert("Do you wish to be considered for the position of Space Wizard Foundation 'diplomat'?","Please answer in 30 seconds!","No",300,"Yes","No"))//alert(G, "Do you wish to be considered for the position of Space Wizard Foundation 'diplomat'?","Please answer in 30 seconds!","Yes","No")) if("Yes") if((world.time-time_passed)>300)//If more than 30 game seconds passed. return