ID:400567
 
(See the best response by Neimo.)
Code:
mob/learn
verb/Instant_Transmission()
set category = "Techniques"
var/ki_cost = rand(60,100)

if(src.doing)
src << "You are already doing something!"
return

if(src.grav)
src << "<font color=#FF9900><b>Training Information:</font> \white You cannot IT while gravity training!"
return

if(src.buku)
return

if(src.arenab)
return

if(src.inx)
return

if(src.grav_on)
return

if(src.dead)
return

if(src.stone_form)
return

if(src.arenab)
return

if(src.donut_wrapped)
return

if(src.grav_popup)
return

if(src.grav_delay)
return

if(src.regen_dead)
return

if(src.KO)
return

if(src.it_lock)
src << "Cannot use this Technique at his time"
return

if(src.ki_lock)
src << "Cannot use this Technique at his time"
return

if(src.in_guild)
switch(alert("EC Or Guild Member?","Instant Transmission","EC","Guild Member"))
if("Guild Member")
usr.Guild_IT()
if("EC")
if(src.ki > ki_cost)
var/code = input("Which Energy Code do you wish to IT to?")as num

if(lentext(code) > 7)
src << "EC too Long!"
return

if(code == src.energy_code)
src << "Thats your EC!"
return

if(!src.arenab)
return

if(!src.inx)
return

if(!src.GM_House == 1)
return

if(!code)
return
else
if(src.dead)
return
else
for(var/mob/M in world)
if(M.energy_code == code)
if(!M.it_blocked)
src.ki -= ki_cost
src << "<B>Locking onto [M]..."
sleep(15)
src << "<B>[M] Found!"
src.icon_state = "IT"
sleep(6)
usr.icon_state = ""
if(!usr)return
if(!M)return
src.x = M:x
src.y = M:y-1
src.z = M:z
view(6) << "<B>[usr] appears from nowhere!"
src.icon_state = "IT"
sleep(6)
src.icon_state = ""
src.afk_time = 0
else
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return
else
src << "You do not have enough Ki!"
return
else


if(src.ki > ki_cost)
var/code = input("Which Energy Code do you wish to IT to?")as num

if(lentext(code) > 7)
src << "EC too Long!"
return

if(code == src.energy_code)
src << "Thats your EC!"
return

if(!code)
return
else
if(src.dead)
return
else
for(var/mob/M in world)
if(M.energy_code == code)
if(!M.it_blocked)
src.ki -= ki_cost
src << "<B>Locking onto [M]..."
sleep(15)
src << "<B>[M] Found!"
src.icon_state = "IT"
sleep(6)
usr.icon_state = ""
if(!usr)return
if(!M)return
src.x = M:x
src.y = M:y-1
src.z = M:z
view(6) << "<B>[usr] appears from nowhere!"
src.icon_state = "IT"
sleep(6)
src.icon_state = ""
src.afk_time = 0
else
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return
else
src << "You do not have enough Ki!"
return


mob/proc/Guild_IT()
var/list/Menu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
if(M.in_guild)
if(M.guild_name == usr.guild_name)
Menu.Add(M)
var/mob/M = input("IT to whom?","Guild Instant Transmission") as null | anything in Menu
if(!M)return

if(src.it_lock == 0)
if(M.it_lock == 0)
if(src.dead == 0)
if(M.dead == 0)
if(M.GM_House == 0)
if(!M.it_blocked)
src << "<B>Locking onto [M]..."
sleep(15)
src << "<B>[M] Found!"
src.icon_state = "IT"
sleep(6)
src.icon_state = ""
src.x = M:x
src.y = M:y-1
src.z = M:z
view(6) << "<font size=1><B>[usr.name] appears from nowhere!"
src.icon_state = "IT"
sleep(6)
src.icon_state = ""
else
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return


Problem description:
idk why the code looks good and get no errors, but the IT wont work when u put in ec code it wont do anything and with guild it when u use it and click the guild memeber it wont do anything
Best response
You have a lot of redundant things in the code, I have not tested this but I wrote it up just a minute ago.

mob/verb
instanttransmission()
set categorry = "techniques"
// this is where you overcomplicated things with if() statements
// combine all of these into one if() statement instead of wasting space
if(buku || arenab || inx || gravon || dead || stoneform || donutwrapped || gravpopup || gravdelay || regendead)
return
if(kilock || itlock || grav || doing)
usr << "you are unable do this right now"
return
// that random number was redundant
if(ki > 60)
var/energycode = 0000000
do
energycode = input("enter the energy code of the target", "energy code") as num
// create a loop to re-neter the number until they enter 7 digits
while(length(energycode) != 7)
if(energycode == myenegerycode)
usr << "you cannot instant transmit to yourself"
return
// now you loop through all mobs
for(var/mob/m in world)
// skip them if they are dead or their code is not correct
if(m.dead || m.energycode != energycode)
continue
// check if they are blocking it
if(!m.blockingit)
usr << "you begin to instant transmit to [m.name]"
// flick would be better off used here
flick("IT", usr)
sleep(6)
// usr is the one who holds the proc, so if(!usr) is useless
if(!m)
break // break the loop properly
// colons are useless here and loc = locate() is perfect for this situation
loc = locate(m.x, m.y - 1, m.z)
ki -= 60
hearers(6, usr) << "[usr.name] appears out of nowhere"
flick("IT", usr)
afktime = 0
else
usr << "they are blocking instant transmission"
break
With so many if() conditionals with instant return statements, there's no wonder that you're having problems. What I suggest to pinpoint the culprit is to use Debugging Output. This is when, just before you return something that failed, you output a message indicating the EXACT location of the failure, i.e:
mob/learn
verb/Instant_Transmission()
//stuff
if(src.buku)
world << "DEBUG: condition \"if(src.buku)\" returned true!" //This tells you exactly where the function is and what happened to cause it to return the value it did
return

if(src.arenab)
world << "DEBUG: condition \"if(src.arenab)\" returned true!" //Another example of Debugging text.
return
//Other code


Do this for each and every if() statement and report the results. If everything comes back saying that it should be working, we can move on from there. You just need to figure out WHERE your if() statement is returning true. Then you can create a solution.
kk ty ill try it
In response to Solomn Architect
Solomn Architect wrote:
Do this for each and every if() statement and report the results. If everything comes back saying that it should be working, we can move on from there. You just need to figure out WHERE your if() statement is returning true. Then you can create a solution.

He said that the code does not work once he puts in the energy code (original post), therefore he passes the if() checks successfully.

Nourn wrote:
idk why the code looks good and get no errors, but the IT wont work when u put in ec code it wont do anything and with guild it when u use it and click the guild memeber it wont do anything
In response to Neimo
This hot mess is just making my head hurt trying to pick through it. I was having enough trouble understanding the bloated puss-cannon in my face than the obscure details. I wasn't at all sure what "ec" was.
oh nvm i fixed it thanks for ur help though man