mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
- Added the ability to have multiple choice player polls.
- Added two new verbs to 'debug verbs'. The first outputs everything in the jobban records list to standard output, the 2nd applies a filter and only prints the things that contain the word. - Fixed an old jobban bug which only checked if someone's ckey ends with the bannee's ckey to jobban them from the job. So perrorage getting banned would result in errorage having the ban in effect too. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5338 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -24,7 +24,7 @@ var/jobban_keylist[0] //to store the keys & ranks
|
||||
return "Whitelisted Job"
|
||||
|
||||
for (var/s in jobban_keylist)
|
||||
if( findtext(s,"[M.ckey] - [rank]") )
|
||||
if( findtext(s,"[M.ckey] - [rank]") == 1 )
|
||||
var/startpos = findtext(s, "## ")+3
|
||||
if(startpos && startpos<length(s))
|
||||
var/text = copytext(s, startpos, 0)
|
||||
|
||||
@@ -178,3 +178,26 @@
|
||||
else
|
||||
usr << "Local airgroup is unsimulated!"
|
||||
feedback_add_details("admin_verb","KLAG") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
/client/proc/print_jobban_old()
|
||||
set name = "Print Jobban Log"
|
||||
set desc = "This spams all the active jobban entries for the current round to standard output."
|
||||
set category = "Debug"
|
||||
|
||||
usr << "<b>Jobbans active in this round.</b>"
|
||||
for(var/t in jobban_keylist)
|
||||
usr << "[t]"
|
||||
|
||||
/client/proc/print_jobban_old_filter()
|
||||
set name = "Search Jobban Log"
|
||||
set desc = "This searches all the active jobban entries for the current round and outputs the results to standard output."
|
||||
set category = "Debug"
|
||||
|
||||
var/filter = input("Contains what?","Filter") as text|null
|
||||
if(!filter)
|
||||
return
|
||||
|
||||
usr << "<b>Jobbans active in this round.</b>"
|
||||
for(var/t in jobban_keylist)
|
||||
if(findtext(t, filter))
|
||||
usr << "[t]"
|
||||
@@ -150,6 +150,8 @@ var/intercom_range_display_status = 0
|
||||
src.verbs += /client/proc/cmd_admin_areatest
|
||||
src.verbs += /client/proc/cmd_admin_rejuvenate
|
||||
src.verbs += /datum/admins/proc/show_traitor_panel
|
||||
src.verbs += /client/proc/print_jobban_old
|
||||
src.verbs += /client/proc/print_jobban_old_filter
|
||||
//src.verbs += /client/proc/cmd_admin_rejuvenate
|
||||
|
||||
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
usr << "The option ID difference is too big. Please contact administration or the database admin."
|
||||
return
|
||||
|
||||
for(var/optionid = id_min; optionid<= id_max; optionid++)
|
||||
for(var/optionid = id_min; optionid <= id_max; optionid++)
|
||||
if(!isnull(href_list["o[optionid]"])) //Test if this optionid was replied to
|
||||
var/rating
|
||||
if(href_list["o[optionid]"] == "abstain")
|
||||
@@ -222,6 +222,20 @@
|
||||
return
|
||||
|
||||
vote_on_numval_poll(pollid, optionid, rating)
|
||||
if("MULTICHOICE")
|
||||
var/id_min = text2num(href_list["minoptionid"])
|
||||
var/id_max = text2num(href_list["maxoptionid"])
|
||||
world << "MULTICHOICE"
|
||||
|
||||
if( (id_max - id_min) > 100 ) //Basic exploit prevention
|
||||
usr << "The option ID difference is too big. Please contact administration or the database admin."
|
||||
return
|
||||
|
||||
for(var/optionid = id_min; optionid <= id_max; optionid++)
|
||||
world << "checking [optionid]"
|
||||
if(!isnull(href_list["option_[optionid]"])) //Test if this optionid was selected
|
||||
world << "FOUND [optionid]"
|
||||
vote_on_poll(pollid, optionid, 1)
|
||||
|
||||
proc/IsJobAvailable(rank)
|
||||
var/datum/job/job = job_master.GetJob(rank)
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
establish_db_connection()
|
||||
if(dbcon.IsConnected())
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid]")
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid]")
|
||||
select_query.Execute()
|
||||
|
||||
var/pollstarttime = ""
|
||||
@@ -92,6 +92,7 @@
|
||||
var/pollquestion = ""
|
||||
var/polltype = ""
|
||||
var/found = 0
|
||||
var/multiplechoiceoptions = 0
|
||||
|
||||
while(select_query.NextRow())
|
||||
pollstarttime = select_query.item[1]
|
||||
@@ -271,9 +272,71 @@
|
||||
output += "</form>"
|
||||
|
||||
src << browse(output,"window=playerpoll;size=500x500")
|
||||
if("MULTICHOICE")
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'")
|
||||
voted_query.Execute()
|
||||
|
||||
var/list/votedfor = list()
|
||||
var/voted = 0
|
||||
while(voted_query.NextRow())
|
||||
votedfor.Add(text2num(voted_query.item[1]))
|
||||
voted = 1
|
||||
|
||||
var/list/datum/polloption/options = list()
|
||||
var/maxoptionid = 0
|
||||
var/minoptionid = 0
|
||||
|
||||
var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]")
|
||||
options_query.Execute()
|
||||
while(options_query.NextRow())
|
||||
var/datum/polloption/PO = new()
|
||||
PO.optionid = text2num(options_query.item[1])
|
||||
PO.optiontext = options_query.item[2]
|
||||
if(PO.optionid > maxoptionid)
|
||||
maxoptionid = PO.optionid
|
||||
if(PO.optionid < minoptionid || !minoptionid)
|
||||
minoptionid = PO.optionid
|
||||
options += PO
|
||||
|
||||
|
||||
if(select_query.item[5])
|
||||
multiplechoiceoptions = text2num(select_query.item[5])
|
||||
|
||||
var/output = "<div align='center'><B>Player poll</B>"
|
||||
output +="<hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>You can select up to [multiplechoiceoptions] options. If you select more, the first [multiplechoiceoptions] will be saved.<br>"
|
||||
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
|
||||
if(!voted) //Only make this a form if we have not voted yet
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value='MULTICHOICE'>"
|
||||
output += "<input type='hidden' name='maxoptionid' value='[maxoptionid]'>"
|
||||
output += "<input type='hidden' name='minoptionid' value='[minoptionid]'>"
|
||||
|
||||
output += "<table><tr><td>"
|
||||
for(var/datum/polloption/O in options)
|
||||
if(O.optionid && O.optiontext)
|
||||
if(voted)
|
||||
if(O.optionid in votedfor)
|
||||
output += "<b>[O.optiontext]</b><br>"
|
||||
else
|
||||
output += "[O.optiontext]<br>"
|
||||
else
|
||||
output += "<input type='checkbox' name='option_[O.optionid]' value='[O.optionid]'> [O.optiontext]<br>"
|
||||
output += "</td></tr></table>"
|
||||
|
||||
if(!voted) //Only make this a form if we have not voted yet
|
||||
output += "<p><input type='submit' value='Vote'>"
|
||||
output += "</form>"
|
||||
|
||||
output += "</div>"
|
||||
|
||||
src << browse(output,"window=playerpoll;size=500x250")
|
||||
return
|
||||
|
||||
/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1)
|
||||
/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1, var/multichoice = 0)
|
||||
if(pollid == -1 || optionid == -1)
|
||||
return
|
||||
|
||||
@@ -282,15 +345,18 @@
|
||||
establish_db_connection()
|
||||
if(dbcon.IsConnected())
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
|
||||
select_query.Execute()
|
||||
|
||||
var/validpoll = 0
|
||||
var/multiplechoiceoptions = 0
|
||||
|
||||
while(select_query.NextRow())
|
||||
if(select_query.item[4] != "OPTION")
|
||||
if(select_query.item[4] != "OPTION" && select_query.item[4] != "MULTICHOICE")
|
||||
return
|
||||
validpoll = 1
|
||||
if(select_query.item[5])
|
||||
multiplechoiceoptions = text2num(select_query.item[5])
|
||||
break
|
||||
|
||||
if(!validpoll)
|
||||
@@ -316,13 +382,18 @@
|
||||
voted_query.Execute()
|
||||
|
||||
while(voted_query.NextRow())
|
||||
alreadyvoted = 1
|
||||
break
|
||||
alreadyvoted += 1
|
||||
if(!multichoice)
|
||||
break
|
||||
|
||||
if(alreadyvoted)
|
||||
if(!multichoice && alreadyvoted)
|
||||
usr << "\red You already voted in this poll."
|
||||
return
|
||||
|
||||
if(multichoice && (alreadyvoted >= multiplechoiceoptions))
|
||||
usr << "\red You already have more than [multiplechoiceoptions] logged votes on this poll. Enough is enough. Contact the database admin if this is an error."
|
||||
return
|
||||
|
||||
var/adminrank = "Player"
|
||||
if(usr && usr.client && usr.client.holder)
|
||||
adminrank = usr.client.holder.rank
|
||||
|
||||
Reference in New Issue
Block a user