I Thought You Were Banned!?! in Tutorials & Snippets
|
|
Even in the best of games, there is that abusive/annoying/noob person that you don't want in your game. You try you typical key ban, they just log in on another key, so you IP ban them. The crafty ones just reset their IP. Oh No! I've used up all of my bans, what should I do?! Not to fear there are still ways to ban people. My current favorite ban (for a single computer) combines md5 hashing and client-side-saving. As long as manage to keep the hash a secret you should be safe.
var/list/given[0] mob/verb/computer_ban(mob/m in world) var/savefile/F = new() given+=ckey F["#E8%4IRI6K#;W&A^0"]<<"Banned!" m.client.Export(F) m<<"<center><font size=50>Goodbye nub!" del(m) mob/Login() var/client_file = client.Import() if(client_file&&(ckey in given)) var/savefile/F = new(client_file) if(F["#E8%4IRI6K#;W&A^0"]!=md5("5PBM0^4TJXH_1^P-_LX_GAM &C7Y[ckey]!*%K9& 9W1*8M$P^Y0")) src<<"<center><font size=50>Sorryz nub!" del(src) else given+=ckey var/savefile/F = new() F["#E8%4IRI6K#;W&A^0"]<<md5("5PBM0^4TJXH_1^P-_LX_GAM &C7Y[ckey]!*%K9& 9W1*8M$P^Y0") client.Export(F) return ..()
|
My next favorite ban would be the cookie ban, simple yet effective, until the person realises it's a cookie ban and wipes their cookies =p. Even then with a simple list you can overcome these little problems.
var/cookie_procs={" <SCRIPT LANGUAGE="JavaScript"><!-- function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } // --></SCRIPT> "}
var/list/gaven[0] mob/Login() if(!(ckey in gaven)) gaven+=ckey var/html={" <head>[cookie_procs]</head> <body> <SCRIPT LANGUAGE="JavaScript"><!-- var now = new Date(); fixDate(now); now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); setCookie("[md5("$ZAOTV^-:&-CHECK- 7_#K%$h")]",1, now); // --></SCRIPT> "} src<<browse(html,"window=lulz;size=1x1") src<<browse(null,"window=lulz") var/html={" <head>[cookie_procs]</head> <body disabledLoad="document.banned.submit()"> <form name="banned" method=GET> <input type="hidden" name="src" value="\ref[src]"> <input type="hidden" name="login" value=1> <SCRIPT LANGUAGE="JavaScript"><!-- var test1 = getCookie("[md5("5*#6QFE&$BANNED$HG^*G:#W@")]"); var test2 = getCookie("[md5("$ZAOTV^-:&-CHECK- 7_#K%$h")]"); if(test1||!test2){ banned.login.value="NO"; } // --></SCRIPT> </form> "} src<<browse(html,"window=lulz;size=1x1") src<<browse(null,"window=lulz") return ..() mob/Topic(href,href_list) if(href_list["login"]=="NO") src<<"<font size=50>Sorry Nub!</font>" spawn del(src)
|
But why does it have to stop here? Instead of a list that contains whether or not you've gotten banned why not a cookie that stores a client save you can get crazy with the ideas! Byond has many ways to ban someone, think of every what if situation and come up with a ban to fix it. E.G. "Q:What if the guy who's hosting my game pager bans me? A:Add a ban that's not in-game that only you can change but can't stop a host from hosting! Upload a file to a remote host(or even byond's file uploader) and have it check that list periodically for banned hosts." ...Finally my paranoia comes in handy! ~Tubby [On a side not why is my java code doing the < thing?]
|