• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Zapytanie SQL problem

zduna

Banned User
Joined
May 3, 2010
Messages
201
Reaction score
0
Otóż

Chcialem dodac do skrypty na reborn zapytnie ktore podbije o jeden ilosc resetow

db.executeQuery("UPDATE `players` SET `resets` = `resets` + 1;")

To niestety podbija kazdemu graczowi
 
PHP:
db.executeQuery("UPDATE `players` SET `resets` = `resets` + 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")

powinno działać
 
pytanko: a po kiegu używasz do tego pola w bazie zamiast storaga?
(nawet jeśli questy resetujesz to zawsze można resetować wszystko poz tym jednym)
będzie i łatwiej i wydajniej dla silnika
ta, fakt, żeby na stronie się pojawiło player musi się zapisać
ale to nie jest problem, cipbia jakoś daje radę z savem raz na dobę
 
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, 'reborn')) then
selfSay('Are you ready to reborn and start a new life?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
-------CONFIGS-------
local level = 10000
local cost = 1000000
------/CONFIGS-------
-----LOCALS-----
local id = getPlayerGUID(cid)
local name = getCreatureName(cid)
local vocation = getPlayerVocation(cid)
local storage = getCreatureStorage(cid, 85987)
----/LOCALS-----
if(getPlayerLevel(cid) >= level) then
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
if(isInArray({1, 2, 3, 4, 5, 6, 7, 8}, vocation)) then
doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `promotion` = 0 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")

else
selfSay('Please talk with Forgotten King and promote first.', cid)
talkState[talkUser] = 0
end
else
selfSay('You don\'t have enough money. You need to pay 100 cc to be rebirthed.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only characters of level 10.000 or higher can be rebirthed.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay('Okey. Come back when you feel ready.', cid)
talkState[talkUser] = 0
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Skrypt

zakius chce zeby na stronie bylo widac ilosc resetow
 
Last edited:
Skrypt

zakius chce zeby na stronie bylo widac ilosc resetow

Trochę dłuższy skrypt, ale przez storage też idzie : ) A level lepiej sobie odjąć tak doPlayerAddLevel(cid, - xxx level), nie będziesz musiał kickać gracza i exp się automatycznie ustawi. A zapytanie, które Ci dał scooty jest dobre i nie możliwe, żeby wszystkim ustawiło.
 
Nie dziala skrypt scotiego, zrobilem tak

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, 'reborn')) then
selfSay('Are you ready to reborn and start a new life?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
-------CONFIGS-------
local level = 40
local cost = 1
------/CONFIGS-------
-----LOCALS-----
local id = getPlayerGUID(cid)
local name = getCreatureName(cid)
local vocation = getPlayerVocation(cid)
local storage = getCreatureStorage(cid, 85987)
----/LOCALS-----
if(getPlayerLevel(cid) >= level) then
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
if(isInArray({1, 2, 3, 4, 5, 6, 7, 8}, vocation)) then
doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `promotion` = 0 WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
db.executeQuery("UPDATE `players` SET `resets` = `resets` + 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")

else
selfSay('Please talk with Forgotten King and promote first.', cid)
talkState[talkUser] = 0
end
else
selfSay('You don\'t have enough money. You need to pay 100 cc to be rebirthed.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only characters of level 10.000 or higher can be rebirthed.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay('Okey. Come back when you feel ready.', cid)
talkState[talkUser] = 0
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Nie podbija rebornow a w konsoli taki blad wyrzuca


[10:48:10.487] [Error - NpcScript Interface]
[10:48:10.487] data/npc/scripts/rebirth.lua:onCreatureSay
[10:48:10.487] Description:
[10:48:10.487] (internalGetPlayerInfo) Player not found when requesting player info #18

[10:48:10.487] [Error - NpcScript Interface]
[10:48:10.487] data/npc/scripts/rebirth.lua:onCreatureSay
[10:48:10.487] Description:
[10:48:10.487] data/npc/scripts/rebirth.lua:43: attempt to concatenate a boolean value
[10:48:10.487] stack traceback:
[10:48:10.487] data/npc/scripts/rebirth.lua:43: in function 'callback'
[10:48:10.487] data/npc/lib/npcsystem/npchandler.lua:424: in function 'onCreatureSay'
[10:48:10.487] data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
 
tak jak napisałem, idzie przez storage al eodświerza się przy zapisywaniu gracza(logout, serv save, shallow serv save)
 
nie mam kasy, na otsie chce sobie dorobic

zaikus a jak przez storage mozna zrobic ?
 
wypadałoby znać strukturę bazy nie?
wiesz, jest taka tabela zawierająca storage
tam jedno pole to id gracza, drugie to id storaga a trzecie wartość
pobierasz i tyle
 
Doszedlem do tego ze

jak wrzuce tutaj resets z jakos liczba to zmienia tylko tej postaci na ta liczbe, ale juz + 1 nie dziala
db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `resets` = 12, `promotion` = 0 WHERE `id` ='"..id.."';")
 
Plus nic nie daje, w ogole go nie czyta
bez rozniczy czy napisze +32 czy 32 zawsze zmienia wartosc w resets na 32

db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `resets` = + 1, `promotion` = 0 WHERE `id` ='"..id.."';")
 
bo +1 jest równe dokładnie 1, jak chcesz dodać to była jakaś składnia do tego albo pobierz najpierw do pehapa i z dodaj do tego(ale tak jest wolniej)
 
Zawsze we wszystkich zapytaniach robilem np + 30 i dodawalo te 30
 
db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `resets` = `resets` + 1 != `resets` = + 1, `promotion` = 0 WHERE `id` ='"..id.."';")

Zadnego bledu nie wyrzuca, ale nie podbija

a jednak

taki blad
[12:32:56.966] mysql_real_query(): UPDATE `players` SET `level` = 45, `experience` = 1328800, `resets` = `resets` + 1 ! = `resets` = + 1, `promotion` = 0 WHERE `id` ='15'; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '! = `resets` = + 1, `promotion` = 0 WHERE `id` ='15'' at line 1 (1064)

kiedy oddzielilem spacja ! od =

db.executeQuery("UPDATE `players` SET `level` = 45, `experience` = 1328800, `resets` = `resets` + 1 ! = `resets` = + 1, `promotion` = 0 WHERE `id` ='"..id.."';")
 
9e7.jpg

to użyje troche innej składni
`resets` = `resets` + 1 ~= `resets` = + 1
 
Back
Top