• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] AddingUnitToStock bug...

Status
Not open for further replies.
Level 12
Joined
Aug 7, 2004
Messages
875
Hey I have the following code that repicks a player's hero...

JASS:
function RemoveHeroIcon takes player who returns nothing
local player p = who
local integer i = GetConvertedPlayerId(p)
if(i <= 5) then
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 2 ), "" )
else
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 3 ), "" )
endif
set p = null
endfunction

JASS:
function Repick takes player who returns nothing
local player p = who
local integer i = GetConvertedPlayerId(p)
local location l = GetUnitLoc(udg_heroselector[i])
call RemoveHeroIcon(p)
call DisplayTextToForce(GetPlayersAll(), GetPlayerNameColoured(p) +" has repicked |c001398F4" + GetHeroProperName(udg_dead[i]) + ".")
call SetUnitOwner(udg_heroselector[i], p, true)
call AddUnitToStockBJ(GetUnitTypeId(udg_dead[i]), GetUnitBelongsToTavern(udg_dead[i]), 1, 1) 
call PanCameraToTimedLocForPlayer(p,l,0)
call RemoveUnit(udg_dead[i])
set udg_dead[i] = null 
call RemoveLocation(l)
set p = null
set l = null
endfunction


Everything works fine except for one thing... whenever the unit is added to the tavern one other unit disappears from the stock and it keeps happening everytime this repick action gets called... I don't know how to fix this...

Anyone got a shot?:spell_breaker:
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I don't know why that bug occurs, but you do know you can do this this way, right ?

JASS:
function RemoveHeroIcon takes player who returns nothing
local integer i = GetConvertedPlayerId(who)
if(i <= 5) then
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 2 ), "" )
else
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 3 ), "" )
endif
endfunction
function Repick takes player who returns nothing
local integer i = GetConvertedPlayerId(who)
local location l = GetUnitLoc(udg_heroselector[i])
call RemoveHeroIcon(who)
call DisplayTextToForce(GetPlayersAll(), GetPlayerNameColoured(who) +" has repicked |c001398F4" + GetHeroProperName(udg_dead[i]) + ".")
call SetUnitOwner(udg_heroselector[i], who, true)
call AddUnitToStockBJ(GetUnitTypeId(udg_dead[i]), GetUnitBelongsToTavern(udg_dead[i]), 1, 1) 
call PanCameraToTimedLocForPlayer(who,l,0)
call RemoveUnit(udg_dead[i])
set udg_dead[i] = null 
call RemoveLocation(l)
set l = null
endfunction

Since you already took the player, you don't need to declare him.
 
Status
Not open for further replies.
Top