Как создать локальную переменную в функции?

lionex

Потрачен
Автор темы
33
1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Версия MoonLoader
.026-beta
Lua:
local keys = require "vkeys"
local sampev = require "lib.samp.events"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("/ad", Ad)

    while true do
        wait(0)

        if isKeyDown(97) then
            wait(300)
            sampSendChat(ad)
        end

    end
end

function Ad(ad) 
    sampAddChatMessage("Ваше объявление: {90EE90}" .. ad, 0x4682B4)
end

function sampev.onShowDialog(id, style, tittle, b1, b2, text)
    if id == 839 then
        sampSendDialogResponse(id, 1, 0, '')
        return false
    end
end

Я пробовал вписать команду в main, не получалось, пытался делать local ad - не работает.
Что не так?
 
Решение
Lua:
local keys = require "vkeys"
local sampev = require "lib.samp.events"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("/ad", Ad)

    while true do
        wait(0)

        if isKeyDown(97) then
            wait(300)
            sampSendChat(ad)
        end

    end
end

function Ad(ad)
    sampAddChatMessage("Ваше объявление: {90EE90}" .. ad, 0x4682B4)
end

function sampev.onShowDialog(id, style, tittle, b1, b2, text)
    if id == 839 then
        sampSendDialogResponse(id, 1, 0, '')
        return false
    end
end

Я пробовал вписать команду в main, не получалось, пытался делать local ad - не работает.
Что не так...

neverlane

t.me/neverlane00
Друг
1,000
1,137
Lua:
local keys = require "vkeys"
local sampev = require "lib.samp.events"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("/ad", Ad)

    while true do
        wait(0)

        if isKeyDown(97) then
            wait(300)
            sampSendChat(ad)
        end

    end
end

function Ad(ad)
    sampAddChatMessage("Ваше объявление: {90EE90}" .. ad, 0x4682B4)
end

function sampev.onShowDialog(id, style, tittle, b1, b2, text)
    if id == 839 then
        sampSendDialogResponse(id, 1, 0, '')
        return false
    end
end

Я пробовал вписать команду в main, не получалось, пытался делать local ad - не работает.
Что не так?
Lua:
local keys = require "vkeys"
local sampev = require "lib.samp.events"
local sendad = ""

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("/ad", Ad)

    while true do
        wait(0)

        if isKeyDown(97) then
            wait(300)
            sampSendChat(sendad)
        end

    end
end

function Ad(ad)
    sendad = ad or ""
    sampAddChatMessage("Ваше объявление: {90EE90}" .. ad, 0x4682B4)
end

function sampev.onShowDialog(id, style, tittle, b1, b2, text)
    if id == 839 then
        sampSendDialogResponse(id, 1, 0, '')
        return false
    end
end
 
  • Нравится
Реакции: ArzAh и lionex