- Joined
- Oct 16, 2010
- Messages
- 680
I Couldn't load and test my map with the basics of a Save/Load system
I've made it with JASS, but have trouble with the syntax since i triggered a long time ago :/
Could someone check the code for me?
The Code :
I've made it with JASS, but have trouble with the syntax since i triggered a long time ago :/
Could someone check the code for me?
The Code :
JASS:
library SLS initializer InitSaveLoadSystem
//private function SLInit takes nothing returns nothing
// private integer i2=1
// loop
// Char2Num[i2-1]= (substring(CharSet, i2, i2))
// exitwhen i2==62
// endloop
//endfunction
public function Save takes player PL, unit Uid returns nothing
local string Hero = UnitId2String(GetUnitTypeId(Uid))
local string HeroExp = I2S(GetHeroXP(Uid))
local string HeroS = I2S(GetHeroStr(Uid, false))
local string HeroA = I2S(GetHeroAgi(Uid, false))
local string HeroI = I2S(GetHeroInt(Uid, false))
local string Item1 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 1)))
local string Item2 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 2)))
local string Item3 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 3)))
local string Item4 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 4)))
local string Item5 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 5)))
local string Item6 = UnitId2String(GetItemTypeId(UnitItemInSlot(Uid, 6)))
local string Gold = I2S(PLAYER_STATE_RESOURCE_GOLD)
call DisplayTimedTextToPlayer(PL,0,0,300,Hero+"-"+HeroExp+"-"+HeroS+"-"+HeroA+"-"+HeroI+"-"+Item1+"-"+Item2+"-"+Item3+"-"+Item4+"-"+Item5+"-"+Item6+"-"+Gold)
endfunction
public function GetUnit takes player P returns unit
local unit group ug
local integer db
local unit u
local integer i = 0
set ug = GroupEnumUnitsOfPlayer(ug, P, true)
set db = CountUnitsInGroup(ug)
loop
set u = GroupPickRandomUnit(ug)
if IsUnitType(u, UNIT_TYPE_HERO) than
return u
endif
exitwhen u = null
endloop
endfunction
private function InitSaveLoadSystem takes nothing returns nothing
set local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.1, false)
// call TriggerAddAction(t, function SetUp)
// call TriggerAddAction(t, function SLInit)
endfunction
endlibrary
-
Save Code
-
Events
- Player - Player 1 (Red) types a chat message containing -save as An exact match
- Player - Player 2 (Blue) types a chat message containing -save as An exact match
- Player - Player 3 (Teal) types a chat message containing -save as An exact match
- Player - Player 4 (Purple) types a chat message containing -save as An exact match
- Player - Player 5 (Yellow) types a chat message containing -save as An exact match
- Player - Player 6 (Orange) types a chat message containing -save as An exact match
- Player - Player 7 (Green) types a chat message containing -save as An exact match
- Player - Player 8 (Pink) types a chat message containing -save as An exact match
- Player - Player 9 (Gray) types a chat message containing -save as An exact match
- Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
- Player - Player 11 (Dark Green) types a chat message containing -save as An exact match
- Player - Player 12 (Brown) types a chat message containing -save as An exact match
- Conditions
-
Actions
- Custom script: call SLS_Save(GetTriggerPlayer(),SLS_GetUnit(GetTriggerPlayer())
-
Events