- Joined
- Dec 19, 2012
- Messages
- 411
[jass=My jass]
type sarray extends string array [10]
function BaseConvert takes integer i, integer LI, sarray sa, string fc returns nothing
local integer array I
local integer I2
local integer LI2 = 1
local integer CI
call BJDebugMsg("1")
if R2I(Pow(62, 3)) < i then
set CI = 4
else
if R2I(Pow(62, 2)) < i then
set CI = 3
else
if R2I(Pow(62, 1)) < i then
set CI = 2
else
set CI = 1
endif
endif
endif
loop
set I[LI] = i / R2I(Pow(62, CI-LI))
set I2 = I[LI] * R2I(Pow(62, CI-LI))
loop
exitwhen LI2 > 62
if LI2 == I[LI] then
set sa[LI] = GS[LI2]
set fc = fc + sa[LI]
endif
set LI2 = LI2 + 1
endloop
exitwhen LI > CI
set LI = LI + 1
endloop
endfunction
function Save takes nothing returns boolean
local integer array i
local string fc
local sarray sa = sarray.create()
set i[1] = GetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD)
call BJDebugMsg("1")
call BaseConvert (i[1], 1, sa, fc)
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, fc)
return false
endfunction
//===========================================================================
function InitTrig_Save takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerAddCondition( t, Filter (function Save))
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-save", true)
exitwhen i == bj_MAX_PLAYERS
set i = i + 1
endloop
set t = null
endfunction[/code]
type sarray extends string array [10]
function BaseConvert takes integer i, integer LI, sarray sa, string fc returns nothing
local integer array I
local integer I2
local integer LI2 = 1
local integer CI
call BJDebugMsg("1")
if R2I(Pow(62, 3)) < i then
set CI = 4
else
if R2I(Pow(62, 2)) < i then
set CI = 3
else
if R2I(Pow(62, 1)) < i then
set CI = 2
else
set CI = 1
endif
endif
endif
loop
set I[LI] = i / R2I(Pow(62, CI-LI))
set I2 = I[LI] * R2I(Pow(62, CI-LI))
loop
exitwhen LI2 > 62
if LI2 == I[LI] then
set sa[LI] = GS[LI2]
set fc = fc + sa[LI]
endif
set LI2 = LI2 + 1
endloop
exitwhen LI > CI
set LI = LI + 1
endloop
endfunction
function Save takes nothing returns boolean
local integer array i
local string fc
local sarray sa = sarray.create()
set i[1] = GetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD)
call BJDebugMsg("1")
call BaseConvert (i[1], 1, sa, fc)
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, fc)
return false
endfunction
//===========================================================================
function InitTrig_Save takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerAddCondition( t, Filter (function Save))
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-save", true)
exitwhen i == bj_MAX_PLAYERS
set i = i + 1
endloop
set t = null
endfunction[/code]
Here's an another trigger related to it.
[jass=My jass]globals
string array GS
endglobals
function Init takes nothing returns boolean
local string s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
local integer i = 1
loop
exitwhen i > 62
set GS = SubString( s, i, i)
set i = i + 1
endloop
call DestroyTrigger(GetTriggeringTrigger())
return false
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddCondition( t, Condition(function Init))
set t = null
endfunction[/code]
string array GS
endglobals
function Init takes nothing returns boolean
local string s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
local integer i = 1
loop
exitwhen i > 62
set GS = SubString( s, i, i)
set i = i + 1
endloop
call DestroyTrigger(GetTriggeringTrigger())
return false
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddCondition( t, Condition(function Init))
set t = null
endfunction[/code]
I have no idea why this trigger stop running, the debug massage only showed "1" one time only. Anyone can help me find the problem?
Last edited: