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

[HELP] Rook System on playerdeath.lua

sircurse

Curseria RTG - TFS 1.1
Joined
Nov 12, 2007
Messages
107
Reaction score
2
Location
Brazil
Twitch
curseofcourse
I think its possible, and I really need it urgent, I made a server with rookguard, and the players get lvl 8, make a sorcerer, then die until lvl 1 and uplvl again getting more mana than normal...

It's a problem for me. My server dont work with rooksystem, so I think its a nice way make a update on player deat file, so when player get lvl 7 his char is rooked back to the first vocation with hp and mana correspodent....


This is my script, I tried but it is not saving the new info on players when die.

PHP:
function onDeath(cid, corpse, killer)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
    dofile("./config.lua")
    if sqlType == "mysql" then
        env = assert(luasql.mysql())
        con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
    else -- sqlite
        env = assert(luasql.sqlite3())
        con = assert(env:connect(sqliteDatabase))
    end

    local level = assert(con:execute("SELECT `level` FROM `players` WHERE `name` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
    local rookLevel = level:numrows()
    if rookLevel == 7 then
    query = assert(con:execute("UPDATE `players` SET (`vocation`, `healthmax`, `manamax`, `cap`, `town_id`, `posx`, `posy`, `posz`) VALUES (0, 180, 30, 475, 9, 349, 930, 7) WHERE `name` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ""));
    end


    query = assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUIDByName(getCreatureName(cid)) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. getCreatureName(killer) .. "', " .. isPlayer(killer) .. ");"))
    local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
    local deathRecords = cursor:numrows()
    while deathRecords > maxDeathRecords do
        delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. " ORDER BY `time` LIMIT 1;"))
        deathRecords = deathRecords - 1
    end

    con:close()
    env:close()
end
 
Update this row:
query = assert(con:execute("UPDATE `players` SET (`vocation`, `healthmax`, `manamax`, `cap`, `town_id`, `posx`, `posy`, `posz`) VALUES (0, 180, 30, 475, 9, 349, 930, 7) WHERE `name` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ""));
to this:
query = assert(con:execute("UPDATE `players` SET (`vocation`, `healthmax`, `manamax`, `cap`, `town_id`, `posx`, `posy`, `posz`) VALUES (0, 180, 30, 475, 9, 349, 930, 7) WHERE `id` = " .. getPlayerGUID(cid) .. ";"))
and see what happens.
 
Well, you never set the new level, you set new level as the old level :p

You wrote:
Code:
WHERE `name` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ""));

It shouldn't be getPlayerGUIDByName, cuz then it doesn't return the name it returns the GUID!
Should be:
Code:
WHERE `name` = " .. getCreatureName(cid)));

Or:
Code:
WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid))));

Also, it is level 6 you get rooked ;)
 
Last edited:
I didn't read the script, but if i've understand what you want it is a script to 'rook' a player when he get's level 7, this is possible without using LuaSQL, you have only to use doPlayerSetVocation and doPlayerSetTown.
Making a condition to see if the level is 7.
 
Back
Top