# 获取商店目标
function GetStoreTarget takes unit store, player p returns unit
1
# 描述
获取指定商店 选择 指定玩家的哪个单位 返回值是同步的接口 可以安全使用
# 参数
| 类型 | 名字 | 说明 | 
|---|---|---|
| 单位 | store | 商店单位 拥有 出售物品 选择英雄 的单位 | 
| 玩家 | p | 每个在线的玩家 | 
如果商店周围没有可选的人的时候 会返回 0
# 返回值
| 类型 | 说明 | 
|---|---|
| 单位 | 被选中的单位 | 
# 例子
local unit u
local integer i = 0
loop
    exitwhen i > 12 
    set u = GetStoreTarget(store, Player(i))
    if u != null then 
        call BJDebugMsg("商店 " + GetUnitName(store) + "选中了 " + GetPlayerName(Player(i)) + " 的 " + GetUnitName(u))
    endif 
    set i = i + 1
endloop
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
local japi = require 'jass.japi'
for i = 0, 11 do 
    local u = japi.GetStoreTarget(store, jass.Player(i))
    if u ~= 0 then
    print('玩家' .. i .. '的' .. jass.GetUnitName(u), '被商店', store, '选中了')
    end
end 
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9