Местонахождение игрока

Статус
В этой теме нельзя размещать новые ответы.

Lyonya Decart

Участник
Автор темы
140
22
Я начинаю изучать LUA. Написал уже 2 функции. И вот хочу чтобы по команде определяло местонахождение игрока(X,Y,Z). Функция function playerpos(param) не работает. У меня ошибка? Помогите.
Lua:
function main() 
if not isSampfuncsLoaded() or not isSampLoaded() then return end 
while not isSampAvailable() do wait(0) end 
sampAddChatMessage('{756767}[Скрипт успешно загружен]{FF4500} Создатель: vk.com/decartfamily ', -1)
sampRegisterChatCommand("hpdecart", cmdfunction) 
sampRegisterChatCommand('dpos', mypos)
sampRegisterChatCommand('ppos', playerpos)
while true do
wait(0) end
end
function cmdfunction() 
HP = getCharHealth(PLAYER_PED)
sampAddChatMessage("[HP HELPER BY DECART] У вас"..HP.." HP", -1) 
end
function mypos() 
 local X, Y, Z = getCharCoordinates(PLAYER_PED)
sampAddChatMessage(" {F08080} Вы находитесь тут: X - "..X..", Y - "..Y..", Z - "..Z, -1)
end
function playerpos(param)
id = tonumber(param)("(%s)")
resik, Handler = sampGetCharHandleBySampPlayerId(id)
X, Y, Z = getCharCoordinates(Handler)
sampAddChatMessage(" {F08080} Игрок находится тут: X - "..X..", Y - "..Y..", Z - "..Z, -1)
end
 

ShuffleBoy

Известный
Друг
754
429
Lua:
function main()
    while not isSampAvailable() do wait(0) end
  
    sampRegisterChatCommand("hpdecart", my_hp)
    sampRegisterChatCommand('dpos', mypos)
    sampRegisterChatCommand('ppos', playerpos)
  
    wait(-1)
end

function my_hp()
    local myhp = getCharHealth(playerPed)
    local str = string.format("У вас %.2f HP", myhp)
    sampAddChatMessage(str, -1)
end

function mypos()
    local x, y, z = getCharCoordinates(playerPed)
    local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z)
    sampAddChatMessage(str, -1)
end

function playerpos(params)
    local id = string.match(param, "(%d+)")
    local result, handle = sampGetCharHandleBySampPlayerId(id)
    if result then
        local x, y, z = getCharCoordinates(handle)
        local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z)
        sampAddChatMessage(str, -1)
    end
end
 
  • Нравится
Реакции: qdIbp

Lyonya Decart

Участник
Автор темы
140
22
function main() while not isSampAvailable() do wait(0) end sampRegisterChatCommand("hpdecart", my_hp) sampRegisterChatCommand('dpos', mypos) sampRegisterChatCommand('ppos', playerpos) wait(-1) end function my_hp() local myhp = getCharHealth(playerPed) local str = string.format("У вас %.2f HP", myhp) sampAddChatMessage(str, -1) end function mypos() local x, y, z = getCharCoordinates(playerPed) local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z) sampAddChatMessage(str, -1) end function playerpos(params) local id = string.match(param, "(%d+)") local result, handle = sampGetCharHandleBySampPlayerId(id) if result then local x, y, z = getCharCoordinates(handle) local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z) sampAddChatMessage(str, -1) end end
Из того что ты ответил, работает только функция с ХП.
 

ShuffleBoy

Известный
Друг
754
429
Из того что ты ответил, работает только функция с ХП.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
 
    sampRegisterChatCommand("hpdecart", my_hp)
    sampRegisterChatCommand('dpos', mypos)
    sampRegisterChatCommand('ppos', playerpos)
 
    wait(-1)
end

function my_hp()
    local myhp = getCharHealth(playerPed)
    local str = string.format("У вас %.2f HP", myhp)
    sampAddChatMessage(str, -1)
end

function mypos()
    local x, y, z = getCharCoordinates(playerPed)
    local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z)
    sampAddChatMessage(str, -1)
end

function playerpos(params)
    local id = string.match(params, "(%d+)")
    local result, handle = sampGetCharHandleBySampPlayerId(id)
    if result then
        local x, y, z = getCharCoordinates(handle)
        local str = string.format("Координаты игрока: %.2f %.2f %.2f", x, y, z)
        sampAddChatMessage(str, -1)
    end
end
 
Статус
В этой теме нельзя размещать новые ответы.