• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Modern AAC -> shop

Status
Not open for further replies.

straher

???
Joined
Mar 23, 2010
Messages
255
Reaction score
3
Dziwny błąd mam, otóż:

skrypt w globalevents powinien zmieniac po dodaniu przedmiotu tabele processed z 0 na 1 - nie zmienia... brak bledu, linijka za to odpowiedzialna:

Code:
db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
 
A czy baza nie zapisuje się dopiero po zrobieniu save? Zrób save i sprawdź czy jest 1 czy 0.
 
nie, w innym przypadku na duzych serwerach savy musialyby byc co pare sekund - za kazdym razem kiedy ktos cos zamowi - tutaj dopoki 0 nie zmieni sie na 1 skrypt nie przestanie sie wykonywac => przedmiot kopiuje sie w nieskonczonosc
 
Nie chce nic mówić ale jeśli jest crash serwera to jest cofka (do stanu ostatniego zapisu) czyli lvle graczy skille itemy itd wczystko się cofa, baza jest nadpisywana przy save.

Sprawdź sobie czy tid jest taki sam jak id, poza tym sprawdź sobie np printem czy w ogóle wykonuje się db.executeQuery

Wstaw cały skrypt, może coś tam zamotałeś.
 
właśnie sprawdź funkcje bo może zamiast db.executeQuery masz db.Query :) różne servy mają różne funkcje
 
caly skrypt:

Lua:
function onThink(interval, lastExecution, thinkInterval)

	local result = db.getResult("SELECT * FROM shop_history WHERE `processed` = 0;")
	
		if(result:getID() ~= -1) then
			while(true) do
				cid = getCreatureByName(tostring(result:getDataString("player")))
				product = tonumber(result:getDataInt("product"))
				itemr = db.getResult("SELECT * FROM shop_offer WHERE `id` = "..product..";")
					if isPlayer(cid) then
						local id = tonumber(itemr:getDataInt("item"))
						local tid = tonumber(result:getDataInt("id"))
						local count = tonumber(itemr:getDataInt("count"))
						local tipe = tonumber(itemr:getDataInt("type"))
						local productn = tostring(itemr:getDataString("name"))
							if isInArray({5,8},tipe) then
								if getPlayerFreeCap(cid) >= getItemWeightById(id, count) then
									if isContainer(getPlayerSlotItem(cid, 3).uid) then
										received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, id,count)
										if received then
											doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")
										else
											doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space on container to receive >> "..productn.." <<")
										end
									else
										doPlayerSendTextMessage(cid,19, "Sorry, you don't have a container to receive >> "..productn.." <<")
									end
								else
									doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough capacity to receive >> "..productn.." << (You need: "..getItemWeightById(id, count).." Capacity)")
								end
							elseif isInArray({6,7},tipe) then
									if tipe == 6 then
										bcap = 8
										bid = 1987
									elseif tipe == 7 then
										bcap = 20
										bid = 1988
									end
									if isItemRune(id) then
										count = 1
									end
									if getPlayerFreeCap(cid) >= (getItemWeightById(1987, 1) + getItemWeightById(id,count * bcap)) then
										local bag = doCreateItemEx(bid, 1)
											for i = 1,bcap do
												doAddContainerItem(bag, id, count)
											end
										received = doPlayerAddItemEx(getPlayerSlotItem(cid, 3).uid, bag)
										if received == RETURNVALUE_NOERROR then
											doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")
											db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
										else
											doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space to receive >> "..productn.." <<")
										end
									else
										doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough capacity to receive >> "..productn.." << (You need: "..getItemWeightById(id, count).." Capacity)")
									end
							end
					end
				itemr:free()
				if not(result:next()) then
					break
				end
			end
			result:free()
		end
	return true
end
 
Code:
if received == RETURNVALUE_NOERROR then
											doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")
											db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
										else
											doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space to receive >> "..productn.." <<")
										end

A co ci potem piszę ?


to:
doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")

czy to:
doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space to receive >> "..productn.." <<")

?? bo jeśli to drugie, to widać, że funkcja sprawdzająca czy received jest true zwraca false
 
zaleznie od tego czy mam miejsce w bpku albo dostaje informacje, ze dostalem przedmiot i dostaje go w nieskonczonosc co 30 sekund az do wyczerpania wolnych miejsc w bp, wtedy dostaje info, ze brakuje miejsca w plecaku
 
zmień
local result = db.getResult("SELECT * FROM shop_history WHERE `processed` = 0;")

na
local result = db.getResult("SELECT * FROM shop_history WHERE `processed` = '0';")
 
znalazlem cos, ale teraz wyrzuca blad:

Lua:
							if isInArray({5,8},tipe) then
								if getPlayerFreeCap(cid) >= getItemWeightById(id, count) then
									if isContainer(getPlayerSlotItem(cid, 3).uid) then
										received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, id,count)
										if received then
											doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")
                         db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")

dodane:

db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")

blad:

[21:53:00.675] [Error - GlobalEvent Interface]
[21:53:00.675] data/globalevents/scripts/shop.lua:eek:nThink
[21:53:00.675] Description:
[21:53:00.675] data/globalevents/scripts/shop.lua:22: attempt to call field 'executeQuery' (a nil value)
[21:53:00.675] stack traceback:
[21:53:00.675] data/globalevents/scripts/shop.lua:22: in function <data/globalevents/scripts/shop.lua:1>
[21:53:00.675] [Error - GlobalEvents::think] Couldn't execute event: shop
 
Status
Not open for further replies.
Back
Top