It's not really system, just a item-sell function. I've tested it and it worked only for the first slot of hero. (No matter what I type the number, the result come out as slot1)
udg_Player_Hero is variable which I set to hero when the player is picking.
The command is "-sell (number of slot)" for example: -sell 1
It seems to work only first slot but I can't find anything wrong.
Thank you very much for helping. +rep to all helpful reply.
Code:
function Trig_Item_Sell_Conditions takes nothing returns boolean
if ( SubStringBJ(GetEventPlayerChatString(), 1, 6) == "-sell " ) and ( S2I(SubStringBJ(GetEventPlayerChatString(), 7, 7)) <= 6 ) and ( S2I(SubStringBJ(GetEventPlayerChatString(), 7, 7)) >= 1 ) then
return true
endif
return false
endfunction
function Trig_Item_Sell_Actions takes nothing returns nothing
local string Message
local item SoldItem = UnitItemInSlot(udg_Player_Hero[GetConvertedPlayerId(GetTriggerPlayer())],S2I(SubString(GetEventPlayerChatString(),7,7)))
if GetItemType(SoldItem) == ITEM_TYPE_CHARGED then
set Message = "You cannot sell the Charged Item"
else
call UnitRemoveItemFromSlot(udg_Player_Hero[GetConvertedPlayerId(GetTriggerPlayer())], S2I(SubString(GetEventPlayerChatString(),7,7)))
set Message = "You have sold " + GetItemName(SoldItem) + " for " + I2S(GetItemLevel(SoldItem)*2) + " gold."
call SetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) + GetItemLevel(SoldItem)*2)
call RemoveItem( SoldItem )
endif
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 10, Message)
endfunction
//===========================================================================
function InitTrig_Item_Sell takes nothing returns nothing
set gg_trg_Item_Sell = CreateTrigger( )
call TriggerAddCondition( gg_trg_Item_Sell, Condition( function Trig_Item_Sell_Conditions ) )
call TriggerAddAction( gg_trg_Item_Sell, function Trig_Item_Sell_Actions )
endfunction
udg_Player_Hero is variable which I set to hero when the player is picking.
The command is "-sell (number of slot)" for example: -sell 1
It seems to work only first slot but I can't find anything wrong.
Thank you very much for helping. +rep to all helpful reply.