Вопросик

FreX

Активный
Автор темы
125
35
Версия MoonLoader
Другое
Lua:
local price = ' 25000'
function main()
    while not isSampAvailable() do wait(0) end
    while true do
    wait(0)
    local result, target = getCharPlayerIsTargeting(playerHandle)
    if result then result, playerid = sampGetPlayerIdByCharHandle(target) end
        if result and isKeyJustPressed(VK_1) then
            name = sampGetPlayerNickname(playerid)
            sampSendChat('/heal ' .. name .. price)
            lua_thread.create(function()
                sampSendChat('/me достал из сумки лекарства и начал расматривать')
                wait(1000)
                sampSendChat('/todo Принимайте их 2 раза в сутки и все будет хорошо*передавая лекарства')
            end)
        end
    end
end
Помогите пожалуйста как сделать так что-бы человек который будет пользоваться скриптом мог сам задавать цену в price
Заранее спасибо
 
  • Клоун
Реакции: vuyy и XRLM

qdIbp

Автор темы
Проверенный
1,386
1,141
Lua:
local price = 25000
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterCharCommand('setprice', function(arg)
        price = (tonumber(arg) and tonumber(arg) > 0) and tonumber(arg) or 25000
        sampAddChatMessage('Теперь сумма равна: '..price,-1)
    end)
    while true do
        wait(0)
        local result, target = getCharPlayerIsTargeting(playerHandle)
        if result then
            result, playerid = sampGetPlayerIdByCharHandle(target) end
        if result and isKeyJustPressed(VK_1) then
            sampSendChat(string.format('/heal %s %d', sampGetPlayerNickname(playerid), price) )
            sampSendChat('/me достал из сумки лекарства и начал расматривать')
            wait(1000)
            sampSendChat('/todo Принимайте их 2 раза в сутки и все будет хорошо*передавая лекарства')
        end
    end
end
 
  • Нравится
Реакции: FreX

mooh

Известный
156
42
Lua:
local price = 25000
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterCharCommand('setprice', function(arg)
        price = (tonumber(arg) and tonumber(arg) > 0) and tonumber(arg) or 25000
        sampAddChatMessage('Теперь сумма равна: '..price,-1)
    end)
    while true do
        wait(0)
        local result, target = getCharPlayerIsTargeting(playerHandle)
        if result then
            result, playerid = sampGetPlayerIdByCharHandle(target) end
        if result and isKeyJustPressed(VK_1) then
            sampSendChat(string.format('/heal %s %d', sampGetPlayerNickname(playerid), price )
            sampSendChat('/me достал из сумки лекарства и начал расматривать')
            wait(1000)
            sampSendChat('/todo Принимайте их 2 раза в сутки и все будет хорошо*передавая лекарства')
        end
    end
end
Скобку забыл закрыть на 14 строке
 
  • Нравится
Реакции: FreX и qdIbp