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

Adding to SQL query (creaturescripts)

Faraonekkk

New Member
Joined
Feb 15, 2010
Messages
686
Reaction score
4
Hello otlanders,

Is there any script to place "1" into players.level (DB) if someone log in? (At creaturescripts, globalevents etc)
I saw something like this can anyone gimme simple code? P:

Ty <3

i have added

mysql_query("UPDATE players SET level = 1 WHERE name = '.getPlayerName(cid).'");

but got error attempt to call global "mysql_query"
 
Last edited:
Code:
db.query('UPDATE `players` SET `level` = 1 WHERE `name` = ' .. getPlayerName(cid) .. ';')
 
LUA:
function onLogin(cid)
    if(getPlayerLevel(cid) >= 1 and true) then --Replace true with other conditions you might want to give, or the players will go back to level 1 everytime they login
        doRemoveCreature(cid)
        db.query('UPDATE `players` SET `level` = 1 WHERE `name` = ' .. getPlayerName(cid) .. ';')
    end
    return true
end
you have to first remove the player from the game, otherwise the player will first load its current level and ignore the fact that you made it level 1
 
avesta, bro :) there is needed functions to db

- - - Updated - - -

any ideas where to add ? its 7,6 engine there is no libs :p its using global.lua and functions.lua
 
By porting a sql function from a newer version and making it work on Avesta or by creating one.
 
Back
Top