Answer the question
In order to leave comments, you need to log in
Error while running Lua script?
I wanted to write a script that would see a certain line in the chat and start writing a command to the chat.
gives an error message:
[ML] (error) house.lua: C:\Program Files (x86)\gta for3\moonloader\house.lua:7: bad argument #1 to 'find' (string expected, got nil)
stack traceback:
[C]: in function 'find'
C:\Program Files (x86)\gta for3\moonloader\house.lua:7: in function <C:\Program Files (x86)\gta for3\moonloader\house.lua:6>
[ML] (error) house.lua: Script died due to an error. (1F5B303C)
require 'lib.moonloader'
require 'lib.sampfuncs'
local SE = require 'lib.samp.events'
function main()
if(string.find(text, "Неоплаченное частное имущество выставлено на продажу")) then
wait(50)
sampSendChat(string.format('/buyhouse'))
wait(200)
sampSendChat(string.format('/buyhouse'))
wait(200)
sampSendChat(string.format('/buyhouse'))
end
end
Answer the question
In order to leave comments, you need to log in
The error "bad argument #1 to 'find' (string expected, got nil)" literally translates to
bad argument #1 for find (string expected, but nil instead).
This means that the text variable is not set for you (it contains the value nil).
Yes, the script is interrupted specifically in this place, but the real error is somewhere else in accordance with your idea, and it will need to be corrected / supplemented there.
[ML] (error) house.lua: C:\Program Files (x86)\gta for3\moonloader\house.lua:8: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
C:\Program Files (x86)\gta for3\moonloader\house.lua:8: in function 'callback'
...Files (x86)\gta for3\moonloader\lib\samp\events\core.lua:77: in function 'process_event'
...Files (x86)\gta for3\moonloader\lib\samp\events\core.lua:100: in function 'process_packet'
...Files (x86)\gta for3\moonloader\lib\ samp\events\core.lua:127: in function <...Files (x86)\gta for3\moonloader\lib\samp\events\core.lua:126>
[ML] (error) house.lua: Script died due to an error. (01CA1A9C)
began to give such an error
, here is the code:
require 'lib.
require 'lib.sampfuncs'
local SE = require 'lib.samp.events'
function SE.onServerMessage(color, text)
if(string.find(text, "" Unpaid private property up for sale "")) then
wait(50 )
sampSendChat("/buyhouse")
wait(200)
sampSendChat("/buyhouse")
wait(200)
sampSendChat("/buyhouse")
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question