Координаты lua

floppov

Участник
Автор темы
85
18
Версия MoonLoader
.027.0-preview
Как сделать что бы когда персонаж становился в определённые координаты (2016.20 1017.96 996.88) Выполнялась функция например sampAddChatMessage?
 
  • Эм
Реакции: qdIbp
Решение
или опять же в цикле проверяй дистанцию между твоими и нужными координатами: https://wiki.blast.hk/ru/moonloader/lua/getdistancebetweencoords3d
Lua:
local bool = false
sampRegisterChatCommand("a", function() bool = not bool end)
while true do wait(0)
    if bool then
        local mx,my,mz = getCharCoordinates(PLAYER_PED)
        local dist = getDistanceBetweenCoords3d(mx, my, mz, 2016.20, 1017.96, 996.88)
        if dist <= 1 then
            print("+")
            bool = false
        end
    end
end

1 на столько точно он не сможет встать на нужные координаты
дописал, но автор не уточнил, может он 10 лет учился ходить по пикселям 😮

или так еще:
Lua:
local bool = true

sampRegisterChatCommand("a"...

вайега52

Налуашил состояние
Модератор
2,992
3,113
Lua:
script_name('AntiCasino')
script_author('FLOPPOV') -- 2016.1967773438, 1017.9692993164, 996.875
require ("lib.moonloader")
local key = require('vkeys')
local rkeys = require('rkeys')
local hook = require('lib.samp.events')

local imgui = require('imgui')
imgui.HotKey = require('imgui_addons').HotKey
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("{FF0000}Anti{FFFFFF}Casino started.", -1)

    sampRegisterChatCommand("anti", casino)
   
    while true do wait(0)
        local mx, my, mz = getCharCoordinates(PLAYER_PED)
        if mx == 2016.20 and my == 1017.96 and mz == 996.88 and bool then
            print("+")
            bool = false
        else
            bool = true
        end
    end
end

function casino()
    local positionX, positionY, positionZ = getCharCoordinates(PLAYER_PED)
    local str = positionX .. ", " .. positionY .. ", " .. positionZ
    sampAddChatMessage(str, -1)
end

Lua:
script_name('AntiCasino')
script_author('FLOPPOV') -- 2016.1967773438, 1017.9692993164, 996.875
require ("lib.moonloader")
local key = require('vkeys')
local rkeys = require('rkeys')
local hook = require('lib.samp.events')

local imgui = require('imgui')
imgui.HotKey = require('imgui_addons').HotKey
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

local bool = true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("{FF0000}Anti{FFFFFF}Casino started.", -1)

    sampRegisterChatCommand("anti", casino)
 
    while true do wait(0)
        local mx, my, mz = getCharCoordinates(PLAYER_PED)
        if mx == 2016.20 and my == 1017.96, mz == 996.88 then
            if bool then
                print("+")
                bool = false
            else
                bool = true
            end
        end
    end
end

function casino()
    local positionX, positionY, positionZ = getCharCoordinates(PLAYER_PED)
    local str = positionX .. ", " .. positionY .. ", " .. positionZ
    sampAddChatMessage(str, -1)
end
у меня там опечатка в условие, поставил ",", а не "and"
 
  • Ха-ха
Реакции: qdIbp

floppov

Участник
Автор темы
85
18
Lua:
script_name('AntiCasino')
script_author('FLOPPOV') -- 2016.1967773438, 1017.9692993164, 996.875
require ("lib.moonloader")
local key = require('vkeys')
local rkeys = require('rkeys')
local hook = require('lib.samp.events')

local imgui = require('imgui')
imgui.HotKey = require('imgui_addons').HotKey
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8

local bool = true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("{FF0000}Anti{FFFFFF}Casino started.", -1)

    sampRegisterChatCommand("anti", casino)
 
    while true do wait(0)
        local mx, my, mz = getCharCoordinates(PLAYER_PED)
        if mx == 2016.20 and my == 1017.96 and mz == 996.88 then
            if bool then
                print("+")
                bool = false
            else
                bool = true
            end
        end
    end
end

function casino()
    local positionX, positionY, positionZ = getCharCoordinates(PLAYER_PED)
    local str = positionX .. ", " .. positionY .. ", " .. positionZ
    sampAddChatMessage(str, -1)
end
Скрипт запускается но когда становишься на координаты ничего не происходит