ID:2498452
 
Code:
var
Route1ShinySpawn=8000
Route1SpawnActive=0
Route1ReSpawn=0
list/Route1 = list()
list/NormalRoute1Pokemon=list("Charmander", "Bulbasuar", "Squirtle")
list/ShinyRoute1Pokemon=list("ShinyCharmander", "ShinyBulbasuar", "ShinySquirtle")
Route1Pokemon1
Route1Empty=1
mob/var
Route1=0
turf/PokemonSpawn
icon='Route.dmi'
Route1
density=0
Crossed(mob/A)
if(ismob(A) && A.client)
if(Route1SpawnActive<=0)
Route1SpawnActive+=1
Route1.Add(A)
Route1Empty=0
if(Route1SpawnActive==1)
if(Route1ReSpawn==0)
Route1Spawn()
..()

Route1DeSpawn
icon_state="TEST"
Crossed(mob/A)
if(ismob(A) && A.client)
if(A.dir==EAST||A.dir==NORTH)
Route1.Remove(A)
if(Route1.len==0)
sleep(40)
if(Route1.len==0)
if(Route1SpawnActive==1)
Route1SpawnActive=0
if(Route1.len==0)
if(Route1ReSpawn==1)
Route1ReSpawn=0
Route1Empty=1
for(var/mob/Route1Pokemon/P in world)
if(P)
del(P)

..()
Route1PokeBlock
Enter(mob/A)
if(ismob(A) && A.client)
return 1
else
return 0
proc
Route1Spawn()
spawn while(Route1SpawnActive&&!Route1ReSpawn&&!Route1Empty)
Route1ReSpawn=1
if(Route1.len==0)
Route1SpawnActive=0
for(var/mob/Route1Pokemon/P in world)
if(P)
del(P)
for(var/mob/M in Route1)
if(M.ShinyCharm==1)
Route1ShinySpawn=7000
var/ShinyChance=rand(1,Route1ShinySpawn)
if(ShinyChance==5000)
Route1Pokemon1=pick(ShinyRoute1Pokemon)
else
Route1Pokemon1=pick(NormalRoute1Pokemon)
if(Route1Pokemon1=="Charmander"){ var/mob/Route1Pokemon/Charmander/C = new;C.loc=M.loc }
if(Route1Pokemon1=="Bulbasuar"){ var/mob/Route1Pokemon/Bulbasuar/B= new;B.loc=M.loc }
if(Route1Pokemon1=="Squirtle"){ var/mob/Route1Pokemon/Squirtle/S = new;S.loc=M.loc }
if(Route1Pokemon1=="ShinyCharmander"){ var/mob/Route1Pokemon/ShinyCharmander/SC = new;SC.loc=M.loc }
if(Route1Pokemon1=="ShinyBulbasuar"){ var/mob/Route1Pokemon/ShinyBulbasuar/SB= new;SB.loc=M.loc }
if(Route1Pokemon1=="ShinySquirtle"){ var/mob/Route1Pokemon/ShinySquirtle/SS = new;SS.loc=M.loc }
if(Route1ReSpawn==1)
Route1ReSpawn=0
for(var/mob/Route1Pokemon/P in world)
if(P)
del(P)
sleep(40)


Problem description:
If player enters and stays in the timer works fine, if player leaves the timer works correctly

BUT if player enters then leaves then enters then leaves then enters say real fast the timers stack and it causes problems how do i fix this issue?



Your code is too needlessly complex to follow. At the moment I can't make head or tails of it. Look how deep that's nested! Also look at all the vars like var1, var2, var3, etc. Those are both huge red flags.

For your numbered vars those should all use lists. You may also want to use a single list, with datums that hold info about these things, rather than a list for each var.

Finally that block of ifs where you're basically copy-pasting the same code over and over: no good. If you had an associative list with name=type pairs, you could simply look up the type without all those ifs and it would perform much better.
var
Route1SpawnActive=0
Route1ReSpawn=0
list/Route1 = list()
list/NormalRoute1Pokemon=list("Charmander", "Bulbasuar", "Squirtle")
Route1Pokemon1=""

////////Crossing This Activates Route1Spawn() To Spawn Pokemon////////
turf/PokemonSpawn
icon='Route.dmi'
Route1
density=0
Crossed(mob/A)
if(ismob(A) && A.client)
if(Route1SpawnActive<=0)
Route1SpawnActive=1
Route1.Add(A)

if(Route1SpawnActive==1)
if(Route1ReSpawn==0)
Route1Spawn()
..()

///////When All Players Leave the area it DeSpawns the pokemon in area///////
Route1DeSpawn
Crossed(mob/A)
if(ismob(A) && A.client)
if(A.dir==EAST||A.dir==NORTH)
Route1.Remove(A)
if(Route1.len==0)
sleep(40)
if(Route1SpawnActive==1)
Route1SpawnActive=0
if(Route1ReSpawn==1)
Route1ReSpawn=0
for(var/mob/Route1Pokemon/P in world)
if(P)
del(P)

..()
///////Stops Pokemon From Crossing Out Of Area/////////
Route1PokeBlock
Enter(mob/A)
if(ismob(A) && A.client)
return 1
else
return 0

/////Pokemon Spawner which is suppose to Respawn pokemon every so many secs after deleting the ones already in area/////
proc
Route1Spawn()
spawn while(Route1SpawnActive&&!Route1ReSpawn)
Route1ReSpawn=1

for(var/mob/M in Route1)
Route1Pokemon1=pick(NormalRoute1Pokemon)
if(Route1Pokemon1=="Charmander"){ var/mob/Route1Pokemon/Charmander/C = new;C.loc=M.loc }
if(Route1Pokemon1=="Bulbasuar"){ var/mob/Route1Pokemon/Bulbasuar/B= new;B.loc=M.loc }
if(Route1Pokemon1=="Squirtle"){ var/mob/Route1Pokemon/Squirtle/S = new;S.loc=M.loc }
sleep(150)
if(Route1ReSpawn==1)
Route1ReSpawn=0
for(var/mob/Route1Pokemon/P in world)
if(P)
del(P)
sleep(40)


Is This Easier to read?
It addresses none of what I said, really. You have a lot of serious design flaws you should address before even worrying about the timer.
well i don't understand

For your numbered vars those should all use lists. You may also want to use a single list, with datums that hold info about these things, rather than a list for each var.

1 list is for pokemon
the other list is for what players on are the route so i don't want them to be in the same list.

the other 2 vars are to check for timer
All those Route1 vars would make more sense grouped in a datum, so you can have the same kind of info for route 2, 3, etc.
good luk

turf/PokemonSpawn
var list/pokelist = new

Route1
pokelist = list("Charmander", "Bulbasaur", "Squirtle")
Route2
pokelist = list("Absol", "Ditto", "Mew")

Entered(mob/m)
if(pokelist.len && ismob(m) && m.client)
var choice = pick(pokelist)
choice = text2path("/mob/pokemon/[choice]")
choice = new choice
choice:loc = m.loc
..()
That's not a good idea either, you'd want the list to belong to the area, not the turf. You don't want a bunch of turfs on the map with their own lists. Having a region-sized area with a single list is much smoother.