Напоммните LUA скриптинг (2)

hol0s

Активный
Автор темы
169
26
я забыл в луа как скоротить в коде команду допустим есть команда /members а я в скрипте хочу сделать чтобы при написании команды /mem чтобы открывалось /members
 

hol0s

Активный
Автор темы
169
26
такое чувство, что и не знал никогда
Lua:
sampRegisterChatCommand('mem', function()
    sampSendChat('/members')
end)
слышишь а не подскажешь еще получить-возрщанеи id игрока по типу
Говно код:
sampRegisterChatCommand("pas", function()
    sampSendChat("/showpass" id ближайшего игрока)
end)
 

percheklii

Известный
749
279
слышишь а не подскажешь еще получить-возрщанеи id игрока по типу
Говно код:
sampRegisterChatCommand("pas", function()
    sampSendChat("/showpass" id ближайшего игрока)
end)
Lua:
function getClosestPlayerId()
    local minDist = 9999
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = math.sqrt( (xi - x) ^ 2 + (yi - y) ^ 2 + (zi - z) ^ 2 )
            if dist < minDist then
                minDist = dist
                closestId = i
            end
        end
    end
    return closestId
end
 

hol0s

Активный
Автор темы
169
26
Lua:
function getClosestPlayerId()
    local minDist = 9999
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = math.sqrt( (xi - x) ^ 2 + (yi - y) ^ 2 + (zi - z) ^ 2 )
            if dist < minDist then
                minDist = dist
                closestId = i
            end
        end
    end
    return closestId
end
после этого в sampSendChat("/showpass", getClosestPlayerId) ?
 

Hinаta

Известный
782
352
после этого в sampSendChat("/showpass", getClosestPlayerId) ?
Lua:
function getClosestPlayerId()
    local minDist = 9999
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = math.sqrt((xi - x) ^ 2 + (yi - y) ^ 2 + (zi - z) ^ 2)
            if dist < minDist then
                minDist = dist
                closestId = i
            end
        end
    end
    return closestId
end

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('pas', function()
        sampSendChat('/showpass ' .. getClosestPlayerId())
    end)
    wait(-1)
end
 

hol0s

Активный
Автор темы
169
26
Lua:
function getClosestPlayerId()
    local minDist = 9999
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = math.sqrt((xi - x) ^ 2 + (yi - y) ^ 2 + (zi - z) ^ 2)
            if dist < minDist then
                minDist = dist
                closestId = i
            end
        end
    end
    return closestId
end

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('pas', function()
        sampSendChat('/showpass ' .. getClosestPlayerId())
    end)
    wait(-1)
end
лю тебя