• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] read access error

Status
Not open for further replies.
Level 7
Joined
Oct 12, 2004
Messages
186
i have 3 jass scripts in my map. Map will startup fine but when the player uses the
inventory ability(A000) it gives me a read access error.

WoWGUI Main Script
Code:
//####################################################################################################
//
// Script: WoWGUI (World of Warcraft Graphic User Interface)
//Version: 1.0
//
//Made By: Linera
//
//
//
//
//####################################################################################################


//####################################################################################################
constant function fs_H2I takes handle h returns integer
return h
return 0
endfunction

constant function fs_I2U takes integer i returns unit
return i
return null
endfunction

constant function fs_I2T takes integer i returns trigger
return i
return null
endfunction

constant function fs_I2TT takes integer i returns texttag
return i
return null
endfunction

constant function fs_I2It takes integer i returns item
return i
return null
endfunction

constant function fs_I2D takes integer i returns destructable
return i
return null
endfunction

constant function fs_I2FM takes integer i returns fogmodifier
return i
return null
endfunction


//####################################################################################################
function setcfg takes string key, string val returns nothing
  call StoreString(udg_fs_cache, "config", key, val)
endfunction

function cfg takes string key returns string
  return GetStoredString(udg_fs_cache, "config", key)
endfunction

function cfgr takes string key returns real
  return S2R(cfg(key))
endfunction

function cfgi takes string key returns integer
  return S2I(cfg(key))
endfunction


//####################################################################################################
function fs_echo takes integer playerID, string msg returns nothing
  if playerID == -1 then
     call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,5.00,msg)
  else
     call DisplayTimedTextToPlayer(Player(playerID),0,0,5.00,msg)
  endif
endfunction

//################################################################################

function get_object_iparam takes handle h, string key returns integer
   return GetStoredInteger(udg_fs_cache, I2S(fs_H2I(h)), key)
endfunction

function set_object_iparam takes handle h, string key, integer val returns nothing
   call StoreInteger(udg_fs_cache, I2S(fs_H2I(h)), key, val)
endfunction

function get_object_rparam takes handle h, string key returns real
   return GetStoredReal(udg_fs_cache, I2S(fs_H2I(h)), key)
endfunction

function set_object_rparam takes handle h, string key, real val returns nothing
   call StoreReal(udg_fs_cache, I2S(fs_H2I(h)), key, val)
endfunction

function flush_object takes handle h returns nothing
   call FlushStoredMission(udg_fs_cache, I2S(fs_H2I(h)))
endfunction

//################################################################################

function get_session_iparam takes string key returns integer
   return GetStoredInteger(udg_fs_cache, "session" + cfg("player"), key)
endfunction

function set_session_iparam takes string key, integer val returns nothing
   call StoreInteger(udg_fs_cache, "session" + cfg("player"), key, val)
endfunction

function get_session_rparam takes string key returns real
   return GetStoredReal(udg_fs_cache, "session" + cfg("player"), key)
endfunction

function set_session_rparam takes string key, real val returns nothing
   call StoreReal(udg_fs_cache, "session" + cfg("player"), key, val)
endfunction

function get_session_param takes string key returns string
   return GetStoredString(udg_fs_cache, "session" + cfg("player"), key)
endfunction

function set_session_param takes string key, string val returns nothing
   call StoreString(udg_fs_cache, "session" + cfg("player"), key, val)
endfunction


//################################################################################
function fs_chr takes integer i returns string
   local string abc = "abcdefghijklmnopqrstuvwxyz"
   local string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   local string digits = "0123456789"
   if i >= 65 and i <= 90 then
      return SubString(ABC, i-65,i-64)
   elseif i >= 97 and i <= 122 then
      return SubString(abc, i-97,i-96)
   elseif i >= 48 and i <= 57 then
      return SubString(digits, i-48,i-47)
   endif
   return ""
endfunction

//################################################################################
function fs_iif takes boolean cond, string s1, string s2 returns string
   if cond then
      return s1
   endif
   return s2
endfunction


//################################################################################
constant function fs_Coords2Id takes integer x, integer y returns integer
   return y * 20 + x
endfunction


//################################################################################
function fs_BuildGroupIDs takes nothing returns nothing
   local integer i = 0
   local integer g
   local integer array count
   loop
      exitwhen i >= 200
      set g = get_session_iparam("tk_group" + I2S(i))
      if  g != -1 then
         call set_session_iparam("tk_groupid" + I2S(i), count[g]) 
         set count[g] = count[g] + 1
      else
         call set_session_iparam("tk_groupid" + I2S(i), -1) 
      endif
      set i = i + 1
   endloop
endfunction


//####################################################################################################
function fs_RegisterEffect takes integer id, string name returns nothing
  call StoreInteger(udg_fs_cache, "FX", name, id)
endfunction

//################################################################################
function fs_SetTrackableGroup takes integer tid, integer g returns nothing
   call set_session_iparam("tk_group" + I2S(tid), g) 
endfunction


//################################################################################
function fs_GetTrackableGroup takes integer tid returns integer
   return get_session_iparam("tk_group" + I2S(tid)) 
endfunction


//################################################################################
function fs_GetTrackableGroupID takes integer tid returns integer
   return get_session_iparam("tk_groupid" + I2S(tid)) 
endfunction

//################################################################################
function fs_GetTriggeringTrackableID takes nothing returns integer
   return get_session_iparam("fs_trigger_tid")
endfunction


//################################################################################
function fs_GetPlayerID takes nothing returns integer
   return cfgi("player")
endfunction

//################################################################################
function fs_GetTrackableX takes integer tid returns real
   return cfgr("tk_" + I2S(tid) + "_x" + I2S(fs_GetPlayerID()))
   return get_session_rparam("tk_x" + I2S(tid))
endfunction

//################################################################################
function fs_GetTrackableY takes integer tid returns real
   return cfgr("tk_" + I2S(tid) + "_y" + I2S(fs_GetPlayerID()))
   return get_session_rparam("tk_y" + I2S(tid))
endfunction


//################################################################################
function fs_AddNamedTextTag takes string name, real x, real y, string msg, real size returns nothing
   local texttag tt
   local integer id = get_session_iparam("fs_texttags")

   call DestroyTextTag(fs_I2TT(get_session_iparam("fs_texttag_" + name)))

   if msg == "" then
      call set_session_iparam("fs_texttag_" + name, 0)
      return
   endif
   if size == 0 then
      set size = cfgr("fs_texttag_size")
   endif

   set tt = CreateTextTag()
   call SetTextTagPos(tt, get_session_rparam("fs_base_x") + x, get_session_rparam("fs_base_y") + y, 0)
   call SetTextTagColor(tt, 255, 255, 255, 255)
   call SetTextTagVelocity(tt, 0, 0)
   call SetTextTagVisibility(tt, true)
   call SetTextTagText(tt, msg, size)
   call SetTextTagPermanent(tt, true)

   call set_session_iparam("fs_texttag_" + name,  fs_H2I(tt))
   call set_session_iparam("fs_texttag" + I2S(id), fs_H2I(tt))
   call set_session_iparam("fs_texttags", id + 1)
//   call debugMsg("fs_AddNamedTextTag: name = " + name + " x = " + R2SW(x, 0, 0) + ", y = " + R2SW(y, 0, 0) + ",  msg = " + msg)
endfunction


//################################################################################
function fs_SetNamedTextTagText takes string name, string msg, real size returns nothing
   local texttag tt = fs_I2TT(get_session_iparam("fs_texttag_" + name))
   if size == 0 then
      set size = cfgr("fs_texttag_size")
   endif
   call SetTextTagText(tt, msg, size)
endfunction



//################################################################################
function fs_PlaySound takes string soundfile returns nothing
   if cfgi("fs_sound") == 0 then
      return
   endif
   if Player(fs_GetPlayerID()) == GetLocalPlayer() then
      call PlaySound(soundfile)
   endif
endfunction

//################################################################################
function fs_AddBackgroundEffectXY takes string modelfile, real x, real y, boolean useskin returns destructable
   local destructable d 
   local integer id = get_session_iparam("fs_effects")

   if useskin then
      set modelfile = modelfile + get_session_param("fs_skin")
   endif
   set d = CreateDestructable(GetStoredInteger(udg_fs_cache, "FX", modelfile), get_session_rparam("fs_base_x") + x, get_session_rparam("fs_base_y") + y, 0, 1.0, 1)

   call set_session_iparam("fs_effect" + I2S(id), fs_H2I(d))
   call set_session_iparam("fs_effects", id + 1)
   return d
endfunction


//################################################################################
function fs_AddBackgroundEffect takes string modelfile, integer tid, boolean useskin returns destructable
   return fs_AddBackgroundEffectXY(modelfile, fs_GetTrackableX(tid), fs_GetTrackableY(tid), useskin)
endfunction


//################################################################################
function fs_AddNamedEffectXY takes string name, string modelfile, real x, real y, boolean useskin returns nothing
   call RemoveDestructable(fs_I2D(get_session_iparam("fs_effect_" + name)))
   if modelfile != "" then
      call set_session_iparam("fs_effect_" + name, fs_H2I(fs_AddBackgroundEffectXY(modelfile, x, y, useskin)))
   else
      call set_session_iparam("fs_effect_" + name, 0)
   endif
endfunction


//################################################################################
function fs_AddNamedEffect takes string name, string modelfile, integer tid, boolean useskin returns nothing
   call fs_AddNamedEffectXY(name, fs_iif(tid >= 0, modelfile, ""), fs_GetTrackableX(tid), fs_GetTrackableY(tid), useskin)
endfunction


//################################################################################
function fs_ClickHandler takes nothing returns nothing
   local integer tid = get_object_iparam(GetTriggeringTrackable(), "id")
   local integer p   = get_object_iparam(GetTriggeringTrackable(), "p")

   call setcfg("player", I2S(p))
   if get_session_iparam("fs_enabled") == 0 then
      return
   endif

   call set_session_iparam("fs_trigger_tid", tid)

   call ExecuteFunc(get_session_param("fs_module") + "_ClickHandler")
endfunction


//################################################################################
function fs_HoverHandler takes nothing returns nothing
   local integer tid = get_object_iparam(GetTriggeringTrackable(), "id")
   local integer p   = get_object_iparam(GetTriggeringTrackable(), "p")

   call setcfg("player", I2S(p))
   if get_session_iparam("fs_enabled") == 0 then
      return
   endif

   call set_session_iparam("fs_trigger_tid", tid)

   call ExecuteFunc(get_session_param("fs_module") + "_HoverHandler")
endfunction



//################################################################################
constant function fs_GetRaceID takes integer p returns string
   local race r = GetPlayerRace(Player(p))
   if r == RACE_NIGHTELF then
      return "4"
   elseif r == RACE_UNDEAD then
      return "2"
   elseif r == RACE_ORC then
      return "3"
   endif
   return "1"
endfunction


//################################################################################
function fs_Shutdown takes integer p returns nothing
   local integer i
   local destructable d
   local texttag tt

   local real x
   local real y

   call setcfg("player", I2S(p))

   if get_session_iparam("fs_enabled") == 0 then
      return
   endif


   // ############ reset camera and visibility ############
   if Player(p) == GetLocalPlayer() then 
      call SetCameraBoundsToRect(bj_mapInitialCameraBounds)
      call ResetToGameCamera(0)
      call SetCameraPosition(get_session_rparam("fs_cam_x"), get_session_rparam("fs_cam_y"))
   endif

   set x = get_session_rparam("fs_base_x")
   set y = get_session_rparam("fs_base_y")

   call DestroyFogModifier(fs_I2FM(get_session_iparam("fs_fogmodifier")))
   call SetFogStateRect(Player(p), FOG_OF_WAR_MASKED, Rect(x + 100 , y + 100, x + 2100, y + 1100), false)


   // ##### exec module shutdown func #####

   call ExecuteFunc(get_session_param("fs_module") + "_Exit")

   // ########## do some cleanup ###########

   set i = get_session_iparam("fs_effects") - 1
   loop
      exitwhen i < 0
      set d = fs_I2D(get_session_iparam("fs_effect" + I2S(i)))
      call RemoveDestructable(d)
      set i = i - 1
   endloop

   set i = get_session_iparam("fs_texttags") - 1
   loop
      exitwhen i < 0
      set tt = fs_I2TT(get_session_iparam("fs_texttag" + I2S(i)))
      call DestroyTextTag(tt)
      set i = i - 1
   endloop


   call set_session_iparam("fs_enabled", 0)
endfunction


//################################################################################
function fs_LoadModule takes integer p, string modname returns nothing
   local integer i = 0
   local real x
   local real y
   local fogmodifier fm

   if p >= cfgi("max_players") then
      call fs_echo(p, "|c00ff0000ERROR:|r cannot access fullscreen interface")
      call fs_echo(p, "(try increasing max_players setting in map configuration)")
      return
   endif

   call setcfg("player", I2S(p))

   if get_session_iparam("fs_enabled") == 1 then
      call fs_Shutdown(p)
   endif

   call FlushStoredMission(udg_fs_cache, "session" + I2S(p))

   set x = cfgr("fs_base_x" + I2S(p))
   set y = cfgr("fs_base_y" + I2S(p))
   call set_session_rparam("fs_base_x", x)
   call set_session_rparam("fs_base_y", y)


   set fm = CreateFogModifierRect(Player(p), FOG_OF_WAR_VISIBLE, Rect(x + 100 , y + 100, x + 2100, y + 1100), false, false)
   call set_session_iparam("fs_fogmodifier", fs_H2I(fm))
   call FogModifierStart(fm)

   set x = x + 1024
   set y = y + 512

   // ############# set camera #############

   call set_session_param("fs_module", modname)
   call set_session_rparam("fs_cam_x", GetCameraTargetPositionX())
   call set_session_rparam("fs_cam_y", GetCameraTargetPositionY())

   if Player(p) == GetLocalPlayer() then
      call SetCameraPosition(x,y)
      call SetCameraBounds(x,y,x,y,x,y,x,y)
   endif



   // ############## init vars #############

   call set_session_iparam("fs_enabled", 1)
   call set_session_iparam("fs_effect_count", 0)

   if cfgi("fs_skin") == 0 then
      call set_session_param("fs_skin", fs_GetRaceID(p))
   else
      call set_session_param("fs_skin", cfg("fs_skin"))
   endif

   loop
      exitwhen i >= 200
      call set_session_iparam("tk_group" + I2S(i), -1)
      set i = i + 1
   endloop

   // ##### exec module init functions #####

   call ExecuteFunc(modname + "_Init")
   call fs_BuildGroupIDs()
endfunction


//################################################################################
function fs_ForceCameraAction takes nothing returns nothing
   if GetStoredInteger(udg_fs_cache, "session" + I2S(GetPlayerId(GetLocalPlayer())), "fs_enabled") != 1 then
      return
   endif
   call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 269.00, 0 )
   call SetCameraField(CAMERA_FIELD_ROTATION, 90.00, 0 )
   call SetCameraField(CAMERA_FIELD_FARZ, 5000.00, 0 )
   call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 3100.00, 0 )
   call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, 44.00, 0 )
endfunction


//####################################################################################################
function fs_Initialize takes nothing returns nothing
   local integer i = 0
   local integer p = 0
   local integer j
   local trigger t
   local timer tm
   local real x
   local real y

   // ############### set up workspace ##############
   call setcfg("base_x", R2S(GetRectMinX(bj_mapInitialPlayableArea) + 100.00))
   call setcfg("base_y", R2S(GetRectMinY(bj_mapInitialPlayableArea) + 100.00))

   set bj_mapInitialPlayableArea = Rect(cfgr("base_x") + 2300, GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))


   // ############### set up path blocker line ##############
   set x = cfgr("base_x") + 2600
   set y = GetRectMinY(GetWorldBounds())

   loop
      exitwhen y > GetRectMaxY(GetWorldBounds())
      call CreateDestructable('BX00', x, y, 0, 1.28, 0)
      set y = y + 128
   endloop

   // ############### auto detect max players if necessary ##############
   if cfgi("max_players") <= 0 then
      loop
         exitwhen i >= 12
         if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
            call setcfg("max_players", I2S(i + 1))
         endif
         set i = i + 1
      endloop
   endif
endfunction


//####################################################################################################

function InitTrig_WoWGUI_Main_Script takes nothing returns nothing
local trigger t

set gg_trg_WoWGUI_Main_Script = CreateTrigger()
call TriggerAddAction(gg_trg_WoWGUI_Main_Script, function fs_Initialize)

set udg_fs_cache = InitGameCache("WOWGUI.w3v")
call FlushGameCache(udg_fs_cache)
call SaveGameCache(udg_fs_cache)
set udg_fs_cache = InitGameCache("WOWGUI.w3v")
endfunction

Configuration
Code:
//################################################################################
function InitTrig_configuration takes nothing returns nothing

// ### Note: ALL settings in this section are strings, so they must be enclosed in quotes
// ### Most of these settings could be changed at any point of game via setcfg function


// #############################################
// #######     WoWGUI basic settings      ######
// #############################################


   // number of players allowed to access the fullscreen panel
   // value of 0 enables auto-detection, i.e. it will be set to max player id used in the game
   // note that each player requires about extra 10 cells of dead-zone height
   call setcfg("max_players", "0")

   // default text labels size
   call setcfg("fs_texttag_size", "0.0204")

   // style used in interface:
   //   0 - Auto (depends on player race)
   //   1 - Human
   //   2 - Undead
   //   3 - Orc
   //   4 - Night Elf
   call setcfg("fs_skin", "0")

   // enables or disables sound effects
   // !!!WARNING!!! it seems to be multiplayer incompatible, that's why it's disabled by default
   // set to 1 in single player maps ONLY!
   call setcfg("fs_sound", "0")


// #############################################
// ############# WoW GUI settings ##############
// #############################################


   // inventory ability id
   // replace 'A000' below with the actual id of "inventory screen" ability
   // (press Ctrl+D in Object Editor to view codes)
   call setcfg("inv100_ability", I2S('A000'))

   // enables / disables selling items directly from backpack:
   //   0 - always off
   //   1 - only if standing at most sell_range away from closest shop
   //   2 - always on
   call setcfg("inv100_sell_mode" ,   "1")
   call setcfg("inv100_sell_range",   "400")

   // part of actual cost paid when selling (1.00 = 100%)
   call setcfg("inv100_sell_rate",    "0.50")

   // enables / disables using or dropping items directly from backpack: 0 - off, 1 - on
   call setcfg("inv100_allow_use",    "1")
   call setcfg("inv100_allow_drop",   "1")

   // default backpack dimensions - min 1, max 10
   // you can explicitly set backpack dimensions of any unit using inv100_SetInventorySize function
   // (see "init" trigger for an example)
   call setcfg("inv100_default_rows", "10")
   call setcfg("inv100_default_cols", "10")

   // if you had camera locked on a unit before entering the inventory screen, this lock will be lost
   // setting this option to "1" will force camera re-locking to the unit using the inventory
   call setcfg("inv100_lock_cam", "0")

   // allow exiting the inventory by pressing ESC key
   call setcfg("inv100_allow_escape", "1")

   // enables / disables fade filter effect when entering / exiting inventory
   call setcfg("inv100_fadefilter", "1")


// #############################################
// ####### background effects database  ########
// #############################################

// do not change unless you know what you're doing

call fs_RegisterEffect('BX00', "square")
call fs_RegisterEffect('BX01', "borderD1")
call fs_RegisterEffect('BX02', "borderD2")
call fs_RegisterEffect('BX03', "borderD3")
call fs_RegisterEffect('BX04', "borderD4")
call fs_RegisterEffect('BX05', "borderL1")
call fs_RegisterEffect('BX06', "borderL2")
call fs_RegisterEffect('BX07', "borderL3")
call fs_RegisterEffect('BX08', "borderL4")
call fs_RegisterEffect('BX09', "borderR1")
call fs_RegisterEffect('BX10', "borderR2")
call fs_RegisterEffect('BX11', "borderR3")
call fs_RegisterEffect('BX12', "borderR4")
call fs_RegisterEffect('BX13', "borderU1")
call fs_RegisterEffect('BX14', "borderU2")
call fs_RegisterEffect('BX15', "borderU3")
call fs_RegisterEffect('BX16', "borderU4")
call fs_RegisterEffect('BX17', "central1")
call fs_RegisterEffect('BX18', "central2")
call fs_RegisterEffect('BX19', "central3")
call fs_RegisterEffect('BX20', "central4")
call fs_RegisterEffect('BX21', "cornerDL1")
call fs_RegisterEffect('BX22', "cornerDL2")
call fs_RegisterEffect('BX23', "cornerDL3")
call fs_RegisterEffect('BX24', "cornerDL4")
call fs_RegisterEffect('BX25', "cornerDR1")
call fs_RegisterEffect('BX26', "cornerDR2")
call fs_RegisterEffect('BX27', "cornerDR3")
call fs_RegisterEffect('BX28', "cornerDR4")
call fs_RegisterEffect('BX29', "cornerUL1")
call fs_RegisterEffect('BX30', "cornerUL2")
call fs_RegisterEffect('BX31', "cornerUL3")
call fs_RegisterEffect('BX32', "cornerUL4")
call fs_RegisterEffect('BX33', "cornerUR1")
call fs_RegisterEffect('BX34', "cornerUR2")
call fs_RegisterEffect('BX35', "cornerUR3")
call fs_RegisterEffect('BX36', "cornerUR4")
call fs_RegisterEffect('BX37', "cost")
call fs_RegisterEffect('BX38', "description1")
call fs_RegisterEffect('BX39', "description2")
call fs_RegisterEffect('BX40', "description3")
call fs_RegisterEffect('BX41', "description4")
call fs_RegisterEffect('BX42', "empinv1")
call fs_RegisterEffect('BX43', "empinv2")
call fs_RegisterEffect('BX44', "empinv3")
call fs_RegisterEffect('BX45', "empinv4")
call fs_RegisterEffect('BX46', "selecter1")
call fs_RegisterEffect('BX47', "selecter2")
call fs_RegisterEffect('BX48', "selecter3")
call fs_RegisterEffect('BX49', "selecter4")
call fs_RegisterEffect('BX50', "selector")
call fs_RegisterEffect('BX51', "number")
call fs_RegisterEffect('BX52', "BTNAutoPickup")
call fs_RegisterEffect('BX53', "BTNDrop")
call fs_RegisterEffect('BX54', "BTNExit")
call fs_RegisterEffect('BX55', "BTNSell")
call fs_RegisterEffect('BX56', "BTNUse")
call fs_RegisterEffect('BX57', "DISBTNDrop")
call fs_RegisterEffect('BX58', "DISBTNSell")
call fs_RegisterEffect('BX59', "DISBTNUse")


endfunction

WoWGUI Module
Code:
//####################################################################################################
function gui_enteraction takes nothing returns nothing
  if GetSpellAbilityId()!=cfgi("inv100_ability") then
     return
  endif

  call IssueImmediateOrderBJ(GetTriggerUnit(), "Stop")
  call TriggerSleepAction(0.00)
  call fs_loadmodule(GetPlayerId(GetOwningPlayer(GetTriggerUnit())), "inv100")
endfunction

//################################################################################
function InitTrig_WoWGUI_Module takes nothing returns nothing
   local trigger t
   local integer i = 0

   set t = CreateTrigger()
   call TriggerAddAction(t, function inv100_EnterAction)
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
endfunction
 
Level 7
Joined
May 6, 2005
Messages
390
Linera said:
//Made By: Linera

yeah right, like anybody wants to help you when you're claiming it as your own and the EXACT same script was released as a FullScreenGUI system. Claiming this as your own is stealing.
 
Status
Not open for further replies.
Top