Glidarn
Member
check post 8
Attachments
-
shoplua.jpg36.5 KB · Views: 31 · VirusTotal
Last edited:
/threaditemid:1 itemcount: 12608
/thread
The item Snake god's wristguard << that you just bought on the website couldnt be added. Han error has ocurred, please wait 30 seconds.. Shop ID: 4
since you won't post the script, i'll have to guess that your libs (primarily 000-constant.lua) are outdated
-- Credits for inspiration and ideas to Azi, <a href="http://forum.otsmedia.eu/archive/index.php/thread-876.html" target="_blank">http://forum.otsmedia.eu/archive/ind...hread-876.html</a>
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
npcHandler:onThink()
end
function creatureSayCallback(cid, type, msg)
if(not(npcHandler:isFocused(cid))) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, "lottery")) then
npcHandler:say("Welcome to our {lottery}. The lottery is a chance to get rich really quick! All you need to do is to {buy} a {ticket}, state four numbers from 1 to " .. lotteryConfig.maxNumber .. " and wait for the draw.", cid)
elseif(msgcontains(msg, "buy") or msgcontains(msg, "ticket")) then
npcHandler:say("Do you want to buy a ticket for a lottery?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "yes")) then
if(talkState[talkUser] == 1) then
if(db.getResult("SELECT * FROM `lottery` WHERE `player_id` = " .. getPlayerGUID(cid) .. ""):getID() < 1) then
npcHandler:say("Please state four numbers from 1 to " .. lotteryConfig.maxNumber .. ". You can always state random numbers saying 'random'. Remember you cannot state two exact numbers.", cid)
talkState[talkUser] = 2
else
npcHandler:say("You've already bought a ticket for this lottery.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, "no")) then
if(talkState[talkUser] > 0) then
npcHandler:say("Then no.", cid)
talkState[talkUser] = 0
end
elseif(talkState[talkUser] == 2) then
local numbers = {}
if(string.lower(msg) == "random") then
repeat
randomNumber = math.random(1, lotteryConfig.maxNumber)
if(not(isInArray(numbers, randomNumber))) then
table.insert(numbers, randomNumber)
end
until table.maxn(numbers) == lotteryConfig.numbersCount
else
if(string.explode(msg, ", ")) then
if(table.maxn(string.explode(msg, ", ")) == lotteryConfig.numbersCount) then
for i = 1, lotteryConfig.numbersCount do
if(tonumber(string.explode(msg, ", ")[i]) < 1 or tonumber(string.explode(msg, ", ")[i]) > lotteryConfig.maxNumber or isInArray(numbers, string.explode(msg, ", ")[i])) then
npcHandler:say("The combination of numbers is wrong.", cid)
talkState[talkUser] = 0
return true
end
table.insert(numbers, string.explode(msg, ", ")[i])
end
else
npcHandler:say("You must state atleast " .. lotteryConfig.numbersCount .. " numbers.", cid)
return true
end
else
npcHandler:say("You can state numbers only.", cid)
return true
end
end
local output = ""
for i = 1, lotteryConfig.numbersCount do
if(i ~= lotteryConfig.numbersCount) then
output = output .. numbers[i] .. ", "
else
output = output .. numbers[i]
end
end
if(getPlayerMoney(cid) < lotteryConfig.ticketPrice) then
npcHandler:say("You don't have enought money.", cid)
talkState[talkUser] = 0
else
db.executeQuery("INSERT INTO `lottery` (`player_id`, `numbers`) VALUES (" .. getPlayerGUID(cid) .. ", '" .. tostring(output) .. "')")
npcHandler:say("Your numbers are " .. output .. ". I wish you good luck and big winnings!", cid)
talkState[talkUser] = 0
doPlayerRemoveMoney(cid, lotteryConfig.ticketPrice)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
then the error is coming up -.-19:42 Lottermo: Hello, Apa. You can buy a ticket for a lottery.
19:42 Apa [9]: buy
19:42 Lottermo: Do you want to buy a ticket for a lottery?
19:42 Apa [9]: yes
since you won't post the script, i'll have to guess that your libs (primarily 000-constant.lua) are outdated
-- Credits for inspiration and ideas to Azi, <a href="http://forum.otsmedia.eu/archive/index.php/thread-876.html" target="_blank">http://forum.otsmedia.eu/archive/ind...hread-876.html</a>
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
npcHandler:onThink()
end
function creatureSayCallback(cid, type, msg)
if(not(npcHandler:isFocused(cid))) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, "lottery")) then
npcHandler:say("Welcome to our {lottery}. The lottery is a chance to get rich really quick! All you need to do is to {buy} a {ticket}, state four numbers from 1 to " .. lotteryConfig.maxNumber .. " and wait for the draw.", cid)
elseif(msgcontains(msg, "buy") or msgcontains(msg, "ticket")) then
npcHandler:say("Do you want to buy a ticket for a lottery?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "yes")) then
if(talkState[talkUser] == 1) then
if(db.getResult("SELECT * FROM `lottery` WHERE `player_id` = " .. getPlayerGUID(cid) .. ""):getID() < 1) then
npcHandler:say("Please state four numbers from 1 to " .. lotteryConfig.maxNumber .. ". You can always state random numbers saying 'random'. Remember you cannot state two exact numbers.", cid)
talkState[talkUser] = 2
else
npcHandler:say("You've already bought a ticket for this lottery.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, "no")) then
if(talkState[talkUser] > 0) then
npcHandler:say("Then no.", cid)
talkState[talkUser] = 0
end
elseif(talkState[talkUser] == 2) then
local numbers = {}
if(string.lower(msg) == "random") then
repeat
randomNumber = math.random(1, lotteryConfig.maxNumber)
if(not(isInArray(numbers, randomNumber))) then
table.insert(numbers, randomNumber)
end
until table.maxn(numbers) == lotteryConfig.numbersCount
else
if(string.explode(msg, ", ")) then
if(table.maxn(string.explode(msg, ", ")) == lotteryConfig.numbersCount) then
for i = 1, lotteryConfig.numbersCount do
if(tonumber(string.explode(msg, ", ")[i]) < 1 or tonumber(string.explode(msg, ", ")[i]) > lotteryConfig.maxNumber or isInArray(numbers, string.explode(msg, ", ")[i])) then
npcHandler:say("The combination of numbers is wrong.", cid)
talkState[talkUser] = 0
return true
end
table.insert(numbers, string.explode(msg, ", ")[i])
end
else
npcHandler:say("You must state atleast " .. lotteryConfig.numbersCount .. " numbers.", cid)
return true
end
else
npcHandler:say("You can state numbers only.", cid)
return true
end
end
local output = ""
for i = 1, lotteryConfig.numbersCount do
if(i ~= lotteryConfig.numbersCount) then
output = output .. numbers[i] .. ", "
else
output = output .. numbers[i]
end
end
if(getPlayerMoney(cid) < lotteryConfig.ticketPrice) then
npcHandler:say("You don't have enought money.", cid)
talkState[talkUser] = 0
else
db.executeQuery("INSERT INTO `lottery` (`player_id`, `numbers`) VALUES (" .. getPlayerGUID(cid) .. ", '" .. tostring(output) .. "')")
npcHandler:say("Your numbers are " .. output .. ". I wish you good luck and big winnings!", cid)
talkState[talkUser] = 0
doPlayerRemoveMoney(cid, lotteryConfig.ticketPrice)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())