Clearing a single medal in Tutorials & Snippets
|
|
Thus far, with no procedure in BYOND to directly clear, how can you clear a single medal? Well, two ways.
1) Delete the medal and put it back up (well, I haven;t tried this but it should work in theory)
2) Parse through the medal page to get the list of players who earned the medal and clear it.
Obviously, this is the second method. This is essentially a plug-and-play type of script, the only thing that needs to be changed is the URL to the medal, which the information (particularly the medal #) can be obtained through view source on the medal page.
client/New() var medal_url_page = "http://www.byond.com/games/[Hub key]/[hub name]?command=view_medals_ajax&medal=[medal #]&full=1" medal_name http i = 1 src << "Starting erasing" for() http = world.Export(medal_url_page) if(!http) CRASH("Is your internet working?") return http = file2text(http["CONTENT"]) if(findtext(http,"no players have earned this medal")) break if(!medal_name) alert(http) var/n = findtext(http,"title=")+7 n = copytext(http,n,findtext(http,"\"",n)) if(alert(src,"Are you sure you want to delete the medal \"[n]\"?","Erase Medal: [n]","?_?","No","Yes") != "Yes") break
medal_name = n for() var/Xkey=findtext(http, "http://www.byond.com/members/") if(!Xkey) break Xkey+=29 var/End = findtext(http, "\"", Xkey) Xkey = copytext(http, Xkey, End) if(world.ClearMedal(medal_name,Xkey)) src << "Erased [Xkey] (#[i++])" http = copytext(http, End) src << "Ending erasing!" return
|
|