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

TFS 0.X [SQLite] -=[TFS]=- 0.4 8.60 How do I remove [VIP] from characters in the player name

btw. do you really use SQLite?
SQL:
UPDATE players SET name = TRIM(SUBSTR(name, LENGTH('[Vip]') + 1)) WHERE name LIKE '[Vip]%';

There might be a case that such player already exists (without [Vip]) so you could try with:
SQL:
UPDATE players p
LEFT JOIN players p2 ON p2.name = TRIM(SUBSTR(p.name, LENGTH('[Vip]') + 1))
SET p.name = TRIM(SUBSTR(p.name, LENGTH('[Vip]') + 1))
WHERE p.name LIKE '[Vip]%' AND p2.name IS NULL;

As for SQLite these kind of queries are not supported try handle such cases manually (duplicates), to get a list of such:
SQL:
SELECT p2.name
FROM players p
INNER JOIN players p2 ON p2.name = TRIM(SUBSTR(p.name, LENGTH('[Vip]') + 1))
WHERE p.name LIKE '[Vip]%'
 
Last edited:
just add to login.lua. No need to add a script, just login.lua. It checks if the VIP has finished and automatically removes the player’s ‘VIP’ name.

data/creaturescripts/scripts/login.lua

Lua:
if isPremium(cid) then


function EddyHavoc(cid)
if isPlayer(cid) then
db.executeQuery("UPDATE `players` SET `name` = '"..string.sub(getCreatureName(cid), 7).."' WHERE `id` = "..getPlayerGUID(cid)..";")
doRemoveCreature(cid)
end
end


if string.find(tostring(getCreatureName(cid)),"[[Vip]]") then
else
local name = getCreatureName(cid)
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(cid)..";")
doRemoveCreature(cid)
end
elseif (not (isPremium)) and string.find(tostring(getCreatureName(cid)),"[[Vip]]") then
addEvent(EddyHavoc, 3*1000, cid)
end
 
Just add login.lua and restart the server and power on, test. It will automatically check if the player has no more VIP days and will automatically remove the 'VIP' name from the player. It's that simple.

Post automatically merged:

you don't want to check the premium... I already removed it here... you can test there.

Lua:
function EddyHavoc(cid)
    if isPlayer(cid) then
        db.executeQuery("UPDATE `players` SET `name` = '" .. string.sub(getCreatureName(cid), 7) .. "' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
        doRemoveCreature(cid)
    end
end

if string.find(tostring(getCreatureName(cid)), "[[Vip]]") then
    local name = getCreatureName(cid)
    db.executeQuery("UPDATE `players` SET `name` = '[Vip] " .. name .. "' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    doRemoveCreature(cid)
end
 
Last edited:
So, try with what he said, just SQLite, it should work for you...
Quanto ao SQLite, esse tipo de consulta não é suportado, tente lidar com esses casos manualmente (duplicados), para obter uma lista deles:
SQL:
SELECT p2.name
FROM players p
INNER JOIN players p2 ON p2.name = TRIM(SUBSTR(p.name, LENGTH('[Vip]') + 1))
WHERE p.name LIKE '[Vip]%'
 
Back
Top