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.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top