Help dialog thing

maldivass

Member
Joined
Dec 25, 2022
Messages
12
Reaction score
1
hello, I made a lua where the script by clicking on the letter Z, the script will automatically open /mechanic menu and select "Sutvarkyti kebula(€500)
but something is wrong with the script, it just throws errors and that's it, and it doesn't open the latest art


Code:
local key = require 'vkeys'
pcall(require, 'sflua')
local sendDialogResponse = false

function main()
    while isSampLoaded() == false do
        wait(5) --Wait 5 milliseconds
    end

    while isSampLoaded() do
        if wasKeyPressed(key.VK_Z) then
            sendDialogResponse = true
        end          

        if sampIsDialogActive() and sendDialogResponse then
            sampSendDialogResponse(2063, 0, 12, ' ')
            sendDialogResponse = false
        end
        wait(5)
    end
end
7QpYR7R.png
@Tuzas maybe you have any idea why it's doesnt work?
 

Expl01T3R

Active member
Joined
Nov 20, 2022
Messages
128
Reaction score
21
Location
Czech Republic
On blast.hk wiki, sampSendDialogResponse contains parameter listitem which starts from 0, you are filling it with 12, try 11.
Just an attempt, idk if its gonna work but it should.
Looks like u are filling it with listitem 12 which isn't in the list, so it auto-picks first item.
 

maldivass

Member
Joined
Dec 25, 2022
Messages
12
Reaction score
1
On blast.hk wiki, sampSendDialogResponse contains parameter listitem which starts from 0, you are filling it with 12, try 11.
Just an attempt, idk if its gonna work but it should.
Looks like u are filling it with listitem 12 which isn't in the list, so it auto-picks first item.
nah, tried everything


@Tuzas need yo help
 

Tuzas

Active member
Joined
Nov 1, 2019
Messages
145
Reaction score
80
Location
null
On blast.hk wiki, sampSendDialogResponse contains parameter listitem which starts from 0, you are filling it with 12, try 11.
Just an attempt, idk if its gonna work but it should.
Looks like u are filling it with listitem 12 which isn't in the list, so it auto-picks first item.
Yep, listitem / array will always start from 0, so the problem was that you wrote 11 instead of 12, and the structure of the code was strange, this should work now


JavaScript:
pcall(require, 'sflua')
local key = require 'vkeys'
local sendDialogResponse = false

function main()
    while not isSampAvailable() do
        wait(0)
    end
    while true do
        wait(0)
        if wasKeyPressed(key.VK_Z) then
            sendDialogResponse = true
            lua_thread.create(mechanic)
        end
    end
end

function mechanic()
    if sendDialogResponse then
        sampSendChat('/mechanic')
        wait(250)
        sampSendDialogResponse(2063, 0, 11, ' ')
        wait(250)
        sampCloseCurrentDialogWithButton(0)
        sendDialogResponse = false
    end
end
 

maldivass

Member
Joined
Dec 25, 2022
Messages
12
Reaction score
1
Code:
local key = require 'vkeys'
pcall(require, 'sflua')

function main()
    if isSampLoaded() then           
        if wasKeyPressed(key.VK_Z) then
            sampSendDialogResponse(2063, 0, 11, ' ')
        end           
    end
end


this code works, it doesn't throw any error or problem in the moonloader windows, but it doesn't open the menu or select the dialog
 
Top