ID:158450
 
I'm not very good at this, but it looks like I'd have to make three variables for Bans and Temp. Bans in this code:
            BanList()
set category = "Admin"
if(Admin_Allow() == 0) alert(usr,"Your may not do that.") ; return
var/NBans
if(!Bans) usr<<"There are no Perm. Bans on this server."
else usr<<"There are some Perm. Bans on this server." ; NBans+=1
if(!Temp_Bans) usr<<"There are no Temp. Bans on this server."
else usr<<"There are some Temp. Bans on this server." ; NBans+=1
if(!(NBans)) return
var/List=input("Which list would you like to see?") in list("Key","IP","Computer","All")
usr<<"Retrieving Ban List."
if(List == "Key"||List == "All")
if(findtext("Key:",Bans)) usr<<"[copytext(Bans,1,50)]"
else usr<<"There are no Perm. Key Bans."
if(findtext("Key:",Bans)) usr<<"[copytext(Temp_Bans,1,50)]"
else usr<<"There are no Temp. Key Bans."
if(List == "IP"||List == "All")
if(findtext("Key:",Bans)) usr<<"[copytext(Bans,1,50)]"
else usr<<"There are no Perm. IP Bans."
if(findtext("Key:",Bans)) usr<<"[copytext(Temp_Bans,1,50)]"
else usr<<"There are no Temp. IP Bans."
if(List == "Computer"||List == "All")
if(findtext("CPU:",Bans)) usr<<"[copytext(Bans,Start=1,End=50)]"
else usr<<"There are no Perm. CPU Bans."
if(findtext("CPU:",Temp_Bans)) usr<<"[copytext(Temp_Bans,Start=1,End=50)]"
else usr<<"There are no Temp. CPU Bans."


Question: I know this code would never work because of the copytext, anyways, so is there a way to only use Temp_Bans and Bans to hold all three types of bans?(Key, IP, and CPU)
Megelic wrote:

Question: I know this code would never work because of the copytext, anyways, so is there a way to only use Temp_Bans and Bans to hold all three types of bans?(Key, IP, and CPU)

1: This code could work if you used a system more like this:
var/X=findtext("BLAH")
copytext(Text,X,X+length("BLAH"))


Because findtext doesn't return TRUE or FALSE, it returns the location it found the text in whatever you're searching.

And in response to your question: Yes, this is possible. I wouldn't advise using a text system like this.. But it would just require understanding parsing.
In response to AJX
Is this code any better?
            BanList()
set category = "Admin"
if(Admin_Allow() == 0) alert(usr,"Your may not do that.") ; return
var/list/NBans
if(!IPBans) usr<<"There are no IP Bans on this server."
else usr<<"There are IP Bans on this server." ; NBans+="IP"
if(!KeyBans) usr<<"There are no Key Bans on this server."
else usr<<"There are some Key Bans on this server." ; NBans+=1
if(!CPUBans) usr<<"There are no CPU Bans on this server."
else usr<<"There are some CPU Bans on this server." ; NBans+=1
if(!(NBans)) return
if(NBans.len > 2) NBans += "All"
var/List=input("What would you like to see?") as null|anything in NBans
usr<<"Retrieving Bans" ; sleep(2)
if(List=="IPBans"||List=="All")
if(findtext("Perm:",IPBans)) usr<<"There are Perm. IP Bans."
else usr<<"There are no Perm. IP Bans."
if(findtext("Temp:",IPBans)) usr<<"There are Temp. IP Bans."
else usr<<"There are no Temp. IP Bans."
usr<<"Collecting IP Ban Information."; sleep(2)
var/Z = list2params(IPBans)
usr<<"[Z]"
if(List=="KeyBans"||List=="All")
if(findtext("Perm:",KeyBans)) usr<<"There are Perm. Key Bans."
else usr<<"There are no Perm. Key Bans."
if(findtext("Temp:",KeyBans)) usr<<"There are Temp. Key Bans."
else usr<<"There are no Temp. Key Bans."
usr<<"Collecting Key Ban Information."; sleep(2)
var/Z = list2params(KeyBans)
usr<<"[Z]"
if(List=="CPUBans"||List=="All")
if(findtext("Perm:",CPUBans)) usr<<"There are Perm. CPU Bans."
else usr<<"There are no Perm. CPU Bans."
if(findtext("Temp:",CPUBans)) usr<<"There are Temp. CPU Bans."
else usr<<"There are no Temp. CPU Bans."
usr<<"Collecting CPU Bans Information."; sleep(2)
var/Z = list2params(CPUBans)
usr<<"[Z]"