• 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!

SQL Fuction how to add in script?

Ghazer

Member
Joined
Mar 13, 2009
Messages
350
Reaction score
6
How I can use this script with SQL "update players set mag_level = 60" because that set magic level to 60...
and doPlayerAddMagLevel add one by one and that produce lag

I create that can you repair or optmize please?

LUA:
function onLogin(cid)
    if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6 then
	    doRemoveCreature(cid)
        db.query('UPDATE `players` SET `mag_level` = 60 WHERE `name` = ' .. getPlayerName(cid) .. ';')
        getPlayerStorageValue(cid, 56364)
    end
    return true
end

When I use i have this error
wawPl.png
 
Last edited:
LUA:
function onLogin(cid)
    if getPlayerStorageValue(cid, 56364) < 1 and (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6) then
	    doRemoveCreature(cid)
        db.query('UPDATE `players` SET `mag_level` = 60 WHERE `name` = \'' .. db.escapeString(getPlayerName(cid)) .. '\';')
        doCreatureSetStorage(cid, 56364, 1)
    end
    return true
end
 
LUA:
db.query("UPDATE `players` SET `mag_level` = 60 WHERE `name` = " .. db.escapeString(getPlayerName(cid)) .. ";")
 
LUA:
function onLogin(cid)
    if getPlayerStorageValue(cid, 56364) < 1 and (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6) then
	    doRemoveCreature(cid)
        db.query('UPDATE `players` SET `mag_level` = 60 WHERE `name` = ' .. db.escapeString(getPlayerName(cid)) .. ';')
        doCreatureSetStorage(cid, 56364, 1)
    end
    return true
end

Didnt know that escape string add the ' symbols around the string also.


___
@Diath
What is the fail about Ninja's line? First he had a fail one, now it seems fine though.
 
I thought my mistake would go unnoticed but oh well, haha. :)
 
Last edited:
Do you take for consideration that I could have loaded the page between the time he edited his post and I actually posted? I wouldn't point out his mistake if it was edited because there would be nothing to point out, right? Please stop defending his mistakes and making yourself a fool.
 
I have this error:
QNXFR.png

0794369a92ab45d49b001cf.png


In my SQLITE table the name of mag_level is maglevel I change that and I dont have errors in console but script doesnt work
HELP PLEASE! I really need that
 
script have that
doRemoveCreature(cid)

- - - Updated - - -

but when enter players his player no is kicked to add magic level... I think the error is doRemoveCreature(cid)
 
Can you create that for me please? I'm new on ots servers
I dont know how to do it

- - - Updated - - -

bump

- - - Updated - - -

bump
 
@Polat Alemdar, I think you dont understand what I want...

I think that scripts is good but not work in doRemoveCreature... its possible to set magic level 60 when druid or sorcerer is created? before of first login

- - - Updated - - -

LUA:
function onLogin(cid)
    if getPlayerStorageValue(cid, 56364) < 1 and (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6) then
	    doRemoveCreature(cid)
        db.query('UPDATE `players` SET `mag_level` = 60 WHERE `name` = ' .. db.escapeString(getPlayerName(cid)) .. ';')
        doCreatureSetStorage(cid, 56364, 1)
    end
    return true
end
 
Back
Top