Function isn't finished executing

ShadowInTheD

Active Member
Reaction score
12
I'm thinking there's some infinite loop in my function that encrypts data that needs to be saved (as mentioned by comments). The game doesn't lag, so I actually don't know if it is that, but I can't find anything..

Here's my function:
JASS:
function Encrypt_Hero takes player pl returns string
  local integer Hero_Number
  local string array Item_Number
  local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*"
  local integer HeroCheckInt = 0
  local integer ItemCheckInt = 0
  local integer ItemSlot = 1
  local string name = GetPlayerName(pl)
  local integer namelength = StringLength(name)
  local string array characterPosition
  local integer nameIntegerCheck = 0
  local integer charPosInt
//Getting 15 char Username
    loop
      if namelength < 15 then
        set name = name + "#"
        exitwhen false
    endif
    set namelength = StringLength(name)
    endloop
//Getting Hero Data 0,1
    loop
      if udg_HeroSaveCount[HeroCheckInt] == GetUnitTypeId(udg_Heroes[GetPlayerId(pl)]) then
        set Hero_Number = HeroCheckInt
        exitwhen true
      endif
      set HeroCheckInt = HeroCheckInt+1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + SubString(Alphabet,HeroCheckInt+15,HeroCheckInt+16)
//Break from Hero, Getting Item Data 1,3,3,5,5,7,7,9,9,11,11,13
    loop
      exitwhen ItemSlot > 6
        if UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)== null then
        set ItemSlot = ItemSlot + 1
        else
        loop
          exitwhen ItemCheckInt > 1
          if udg_ItemSaveCount[ItemCheckInt] == GetItemTypeId(UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)) then
          set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(ItemCheckInt+147)
          endif
        set ItemCheckInt = ItemCheckInt+1
        endloop
       set ItemSlot = ItemSlot + 1
       endif
    endloop
//Break from Items, Getting Attribute Data 14,19
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroStr(udg_Heroes[GetPlayerId(pl)],false)+104) + Decimal2Base70(GetHeroAgi(udg_Heroes[GetPlayerId(pl)],false)+74) + Decimal2Base70(GetHeroInt(udg_Heroes[GetPlayerId(pl)],false)+192)
//Break from Attribute Data, Getting Experience 19,23
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroXP(udg_Heroes[GetPlayerId(pl)])+1029353)
//Break from Experience, Getting Name 23,38
    loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
        set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1)))
        else
        set name = SubString(name,0,nameIntegerCheck-1) + Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))) + SubString(name,nameIntegerCheck+2,15)
        endif
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + name
//Break from Name, Getting Gold and PVP 38, 42 ,46
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_GOLD)+1072045) + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_LUMBER)+1395427)
//Break from Gold and PVP, Getting Attribute Points 46,48
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(udg_PlayerAttributePoints[GetPlayerId(pl)]+92)
//Break from Attribute Points, Mixing up Code
    loop
      exitwhen charPosInt > 48
      set characterPosition[charPosInt] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],charPosInt,charPosInt+1)
      set charPosInt = charPosInt + 1
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    set udg_CodePerPlayer[GetPlayerId(pl)] = characterPosition[33] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],1,32) + characterPosition[0] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],33,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,2) + characterPosition[10] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],3,9)+characterPosition[1]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],10,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,3) + characterPosition[13] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,12)+characterPosition[2]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],13,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,4) + characterPosition[42] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,41)+characterPosition[4]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],42,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,7) + characterPosition[18] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],8,17)+characterPosition[8]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],18,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,8) + characterPosition[46] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],9,45)+characterPosition[9]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],46,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,10) + characterPosition[37] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],11,36)+characterPosition[11]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],37,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,13) + characterPosition[22] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],14,21)+characterPosition[14]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],22,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,16) + characterPosition[26] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],17,25)+characterPosition[17]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],26,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,18) + characterPosition[30] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],19,29)+characterPosition[19]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],30,48)
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    return udg_CodePerPlayer[GetPlayerId(pl)]
endfunction


Appreciate any help =)
 

Azlier

Old World Ghost
Reaction score
461
Well, scanning the first loop...

JASS:
loop
      if namelength < 15 then
        set name = name + "#"
        exitwhen false
    endif
    set namelength = StringLength(name)
    endloop

exitwhen false can never occur. You'll hit the op limit, and function execution will end.
 

Azlier

Old World Ghost
Reaction score
461
Because false can never be true?
 

ShadowInTheD

Active Member
Reaction score
12
I fixed that loop, I think, but it's still not working.

New code:
JASS:
function Encrypt_Hero takes player pl returns string
  local integer Hero_Number
  local string array Item_Number
  local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*"
  local integer HeroCheckInt = 0
  local integer ItemCheckInt = 0
  local integer ItemSlot = 1
  local string name = GetPlayerName(pl)
  local integer namelength = StringLength(name)
  local string array characterPosition
  local integer nameIntegerCheck = 0
  local integer charPosInt
//Getting 15 char Username
    loop
      exitwhen namelength > 15
      if namelength < 15 then
        set name = name + "#"
    endif
    set namelength = StringLength(name)
    endloop
//Getting Hero Data 0,1
    loop
      if udg_HeroSaveCount[HeroCheckInt] == GetUnitTypeId(udg_Heroes[GetPlayerId(pl)]) then
        set Hero_Number = HeroCheckInt
        exitwhen true
      endif
      set HeroCheckInt = HeroCheckInt+1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + SubString(Alphabet,HeroCheckInt+15,HeroCheckInt+16)
//Break from Hero, Getting Item Data 1,3,3,5,5,7,7,9,9,11,11,13
    loop
      exitwhen ItemSlot > 6
        if UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)== null then
        set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(147)
        set ItemSlot = ItemSlot + 1
        else
        loop
          exitwhen ItemCheckInt > 1
          if udg_ItemSaveCount[ItemCheckInt] == GetItemTypeId(UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)) then
          set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(ItemCheckInt+147)
          endif
        set ItemCheckInt = ItemCheckInt+1
        endloop
       set ItemSlot = ItemSlot + 1
       endif
    endloop
//Break from Items, Getting Attribute Data 14,19
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroStr(udg_Heroes[GetPlayerId(pl)],false)+104) + Decimal2Base70(GetHeroAgi(udg_Heroes[GetPlayerId(pl)],false)+74) + Decimal2Base70(GetHeroInt(udg_Heroes[GetPlayerId(pl)],false)+192)
//Break from Attribute Data, Getting Experience 19,23
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroXP(udg_Heroes[GetPlayerId(pl)])+1029353)
//Break from Experience, Getting Name 23,38
    loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
        set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1)))
        else
        set name = SubString(name,0,nameIntegerCheck-1) + Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))) + SubString(name,nameIntegerCheck+2,15)
        endif
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + name
//Break from Name, Getting Gold and PVP 38, 42 ,46
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_GOLD)+1072045) + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_LUMBER)+1395427)
//Break from Gold and PVP, Getting Attribute Points 46,48
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(udg_PlayerAttributePoints[GetPlayerId(pl)]+92)
//Break from Attribute Points, Mixing up Code
    loop
      exitwhen charPosInt > 48
      set characterPosition[charPosInt] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],charPosInt,charPosInt+1)
      set charPosInt = charPosInt + 1
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    set udg_CodePerPlayer[GetPlayerId(pl)] = characterPosition[33] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],1,32) + characterPosition[0] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],33,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,2) + characterPosition[10] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],3,9)+characterPosition[1]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],10,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,3) + characterPosition[13] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,12)+characterPosition[2]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],13,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,4) + characterPosition[42] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,41)+characterPosition[4]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],42,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,7) + characterPosition[18] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],8,17)+characterPosition[8]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],18,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,8) + characterPosition[46] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],9,45)+characterPosition[9]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],46,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,10) + characterPosition[37] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],11,36)+characterPosition[11]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],37,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,13) + characterPosition[22] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],14,21)+characterPosition[14]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],22,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,16) + characterPosition[26] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],17,25)+characterPosition[17]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],26,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,18) + characterPosition[30] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],19,29)+characterPosition[19]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],30,48)
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    return udg_CodePerPlayer[GetPlayerId(pl)]
endfunction
 

WolfieeifloW

WEHZ Helper
Reaction score
372
JASS:
if namelength < 15 then

Sort of unneeded now isn't it :p ?



JASS:
set ItemSlot = ItemSlot + 1

[del]You're doing this twice?[/del]
Oops, nevermind this one :p .
 

ShadowInTheD

Active Member
Reaction score
12
Nah :D

Now it's
JASS:
loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
        set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1))+2)
        endif
        set name = SubString(name,0,nameIntegerCheck-1) + Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))+2) + SubString(name,nameIntegerCheck+2,15)
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop
 

ShadowInTheD

Active Member
Reaction score
12
SUPER BUMP? It's been 13 hours!! and I've done a lot to it, (fixed 2 problems), but I still have more. and.... I'm impatient! :D

Could it be that the setting the string is too long? (like the whole line length)
 

ShadowInTheD

Active Member
Reaction score
12
JASS:
function Encrypt_Hero takes player pl returns string
  local integer Hero_Number
  local string array Item_Number
  local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*"
  local integer HeroCheckInt = 0
  local integer ItemCheckInt = 0
  local integer ItemSlot = 1
  local string name = GetPlayerName(pl)
  local integer namelength = StringLength(name)
  local string array characterPosition
  local integer nameIntegerCheck = 0
  local integer charPosInt
  local string array a
  set udg_CodePerPlayer[GetPlayerId(pl)]=""
//Getting 15 char Username
call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
    loop
      exitwhen namelength > 15
      set name = name + "#"
      set namelength = StringLength(name)
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
//Getting Hero Data 0,1
    loop
      if udg_HeroSaveCount[HeroCheckInt] == GetUnitTypeId(udg_Heroes[GetPlayerId(pl)]) then
        set Hero_Number = HeroCheckInt
        exitwhen true
      endif
      set HeroCheckInt = HeroCheckInt+1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + SubString(Alphabet,HeroCheckInt+15,HeroCheckInt+16)
call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
    //Break from Hero, Getting Item Data 1,3,3,5,5,7,7,9,9,11,11,13
    loop
      exitwhen ItemSlot > 6
        if UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)== null then
        set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(147)
        set ItemSlot = ItemSlot + 1
        else
        loop
          exitwhen ItemCheckInt > 1
          if udg_ItemSaveCount[ItemCheckInt] == GetItemTypeId(UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)) then
          set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(ItemCheckInt+147)
          endif
        set ItemCheckInt = ItemCheckInt+1
        endloop
       set ItemSlot = ItemSlot + 1
       endif
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
//Break from Items, Getting Attribute Data 14,19
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroStr(udg_Heroes[GetPlayerId(pl)],false)+104)
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroAgi(udg_Heroes[GetPlayerId(pl)],false)+74)
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroInt(udg_Heroes[GetPlayerId(pl)],false)+192)
call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
//Break from Attribute Data, Getting Experience 19,23
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroXP(udg_Heroes[GetPlayerId(pl)])+1029353)
call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
//Break from Experience, Getting Name 23,38
    loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
          set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1))+2)
        endif
        set a[1] =SubString(name,0,nameIntegerCheck-1)
        set a[2] = Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))+2)
        set a[3] = SubString(name,nameIntegerCheck+2,15)
        set name = a[1] + a[2] + a[3]
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + name
//Break from Name, Getting Gold and PVP 38, 42 ,46
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_GOLD)+1072045) + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_LUMBER)+1395427)
//Break from Gold and PVP, Getting Attribute Points 46,48
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(udg_PlayerAttributePoints[GetPlayerId(pl)]+92)
//Break from Attribute Points, Mixing up Code
    loop
      exitwhen charPosInt > 48
      set characterPosition[charPosInt] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],charPosInt,charPosInt+1)
      set charPosInt = charPosInt + 1
    endloop
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Debug " + udg_CodePerPlayer[GetPlayerId(pl)])
    set udg_CodePerPlayer[GetPlayerId(pl)] = characterPosition[33] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],1,32) + characterPosition[0] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],33,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,2) + characterPosition[10] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],3,9)+characterPosition[1]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],10,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,3) + characterPosition[13] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,12)+characterPosition[2]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],13,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,4) + characterPosition[42] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,41)+characterPosition[4]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],42,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,7) + characterPosition[18] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],8,17)+characterPosition[8]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],18,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,8) + characterPosition[46] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],9,45)+characterPosition[9]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],46,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,10) + characterPosition[37] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],11,36)+characterPosition[11]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],37,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,13) + characterPosition[22] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],14,21)+characterPosition[14]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],22,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,16) + characterPosition[26] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],17,25)+characterPosition[17]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],26,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,18) + characterPosition[30] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],19,29)+characterPosition[19]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],30,48)
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    return udg_CodePerPlayer[GetPlayerId(pl)]
endfunction


Function stops around

JASS:
loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
          set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1))+2)
        endif
        set a[1] =SubString(name,0,nameIntegerCheck-1)
        set a[2] = Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))+2)
        set a[3] = SubString(name,nameIntegerCheck+2,15)
        set name = a[1] + a[2] + a[3]
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop

Sidenote: I know it is :D
 
Reaction score
341
JASS:
    loop
      exitwhen charPosInt > 48
      set characterPosition[charPosInt] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],charPosInt,charPosInt+1)
      set charPosInt = charPosInt + 1
    endloop


Your incrementing charPosInt, when it doesn't even have an initial value.

Whats (null + 1) going to ==?

This goes for all the other variables.
 

ShadowInTheD

Active Member
Reaction score
12
Thanks Trigger, it's working fine.

JASS:
function Encrypt_Hero takes player pl returns string
  local integer Hero_Number
  local string array Item_Number
  local string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*"
  local integer HeroCheckInt = 0
  local integer ItemCheckInt = 0
  local integer ItemSlot = 1
  local string name = GetPlayerName(pl)
  local integer namelength = StringLength(name)
  local string array characterPosition
  local integer nameIntegerCheck = 0
  local integer charPosInt = 0
  local string array a
  set udg_CodePerPlayer[GetPlayerId(pl)]=""
//Getting 15 char Username
    loop
      exitwhen namelength > 15
      set name = name + "#"
      set namelength = StringLength(name)
    endloop
//Getting Hero Data 0,1
    loop
      if udg_HeroSaveCount[HeroCheckInt] == GetUnitTypeId(udg_Heroes[GetPlayerId(pl)]) then
        set Hero_Number = HeroCheckInt
        exitwhen true
      endif
      set HeroCheckInt = HeroCheckInt+1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + SubString(Alphabet,HeroCheckInt+15,HeroCheckInt+16)
    //Break from Hero, Getting Item Data 1,3,3,5,5,7,7,9,9,11,11,13
    loop
      exitwhen ItemSlot > 6
        if UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)== null then
        set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(147)
        set ItemSlot = ItemSlot + 1
        else
        loop
          exitwhen ItemCheckInt > 1
          if udg_ItemSaveCount[ItemCheckInt] == GetItemTypeId(UnitItemInSlot(udg_Heroes[GetPlayerId(pl)],ItemSlot)) then
          set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(ItemCheckInt+147)
          endif
        set ItemCheckInt = ItemCheckInt+1
        endloop
       set ItemSlot = ItemSlot + 1
       endif
    endloop
//Break from Items, Getting Attribute Data 14,19
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroStr(udg_Heroes[GetPlayerId(pl)],false)+104)
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroAgi(udg_Heroes[GetPlayerId(pl)],false)+74)
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroInt(udg_Heroes[GetPlayerId(pl)],false)+192)
//Break from Attribute Data, Getting Experience 19,23
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetHeroXP(udg_Heroes[GetPlayerId(pl)])+1029353)
//Break from Experience, Getting Name 23,38
    loop
      exitwhen nameIntegerCheck > 15
        if nameIntegerCheck == 0 then
          set name = Decimal2Base70(Base70ToDecimal(SubString(name,0,1))+2)
        endif
        set a[1] =SubString(name,0,nameIntegerCheck-1)
        set a[2] = Decimal2Base70(Base70ToDecimal(SubString(name,nameIntegerCheck,nameIntegerCheck+1))+2)
        set a[3] = SubString(name,nameIntegerCheck+2,15)
        set name = a[1] + a[2] + a[3]
        set nameIntegerCheck = nameIntegerCheck + 1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + name
//Break from Name, Getting Gold and PVP 38, 42 ,46
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_GOLD)+1072045) + Decimal2Base70(GetPlayerState(pl,PLAYER_STATE_RESOURCE_LUMBER)+1395427)
//Break from Gold and PVP, Getting Attribute Points 46,48
    set udg_CodePerPlayer[GetPlayerId(pl)] = udg_CodePerPlayer[GetPlayerId(pl)] + Decimal2Base70(udg_PlayerAttributePoints[GetPlayerId(pl)]+92)
//Break from Attribute Points, Mixing up Code
    loop
      exitwhen charPosInt > 48
      set characterPosition[charPosInt] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],charPosInt,charPosInt+1)
      set charPosInt = charPosInt + 1
    endloop
    set udg_CodePerPlayer[GetPlayerId(pl)] = characterPosition[33] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],1,32) + characterPosition[0] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],33,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,2) + characterPosition[10] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],3,9)+characterPosition[1]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],10,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,3) + characterPosition[13] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,12)+characterPosition[2]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],13,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,4) + characterPosition[42] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],4,41)+characterPosition[4]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],42,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,7) + characterPosition[18] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],8,17)+characterPosition[8]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],18,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,8) + characterPosition[46] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],9,45)+characterPosition[9]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],46,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,10) + characterPosition[37] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],11,36)+characterPosition[11]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],37,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,13) + characterPosition[22] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],14,21)+characterPosition[14]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],22,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,16) + characterPosition[26] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],17,25)+characterPosition[17]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],26,48)
    set udg_CodePerPlayer[GetPlayerId(pl)] = SubString(udg_CodePerPlayer[GetPlayerId(pl)],0,18) + characterPosition[30] + SubString(udg_CodePerPlayer[GetPlayerId(pl)],19,29)+characterPosition[19]+SubString(udg_CodePerPlayer[GetPlayerId(pl)],30,48)
    call DisplayTimedTextToPlayer(pl,0,0,3600,"Your Code: " + udg_CodePerPlayer[GetPlayerId(pl)])
    return udg_CodePerPlayer[GetPlayerId(pl)]
endfunction


Decent save code, though it's kinda long.

EDIT: Bleh, I'll ask on another thread.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top