<?xml version="1.0" encoding="UTF-8"?>
<mod name="Characters Market System" version="1.0" author="LuckOake" contact="none" enabled="yes">
------------------------------------------------------------------------------------
<config name="market"><![CDATA[
price = 27112
owner = 27113
level = 30 -- Level mínimo que o character deve ter para ser vendido
min_price = 100 -- Preço mínimo de um character
max_price = 1000000 -- Preço máximo de um character
function doTransferCharacter(cid, accId)
return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
function doOfflinePlayerAddMoney(guid, money)
return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
function setOfflinePlayerStorageValue(name, key, value)
local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
if result:getID() == -1 then
return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
else
result:free()
return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
end
end
function getOfflinePlayerStorageValue(name, key)
local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
if result:getID() == -1 then
return nil
end
ret = result:getDataInt("value")
result:free()
return ret
end
function getOfflinePlayerValue(name, value)
local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
ret = result:getDataInt(value)
result:free()
return ret
end
function isCharacterForSale(name)
if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
return false
else
return true
end
end
]]></config>
------------------------------------------------------------------------------------
<talkaction words="!character" event="buffer"><![CDATA[
domodlib('market')
local t = string.explode(param, ",")
if t[1] == "sell" then
if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
elseif isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
elseif getPlayerByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
elseif getOfflinePlayerValue(t[2], "level") < level then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
elseif tonumber(t[3]) < min_price then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
elseif tonumber(t[3]) > max_price then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
end
setOfflinePlayerStorageValue(t[2], price, t[3])
setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
elseif t[1] == "buy" then
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
elseif not playerExists(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
elseif not isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
end
if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
else
doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
end
doTransferCharacter(t[2], getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
setOfflinePlayerStorageValue(t[2], owner, -1)
setOfflinePlayerStorageValue(t[2], price, -1) return true
elseif t[1] == "remove" then
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
elseif not isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
end
setOfflinePlayerStorageValue(t[2], price, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Market.') return true
elseif t[1] == "list" then
local result = db.getResult("SELECT `name` FROM `players`")
if result:getID() == -1 then
return true
end
local msg = "Characters for Sale:\n\n"
while true do
local name = result:getDataString("name")
if isCharacterForSale(name) then
local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
end
if not result:next() then
break
end
end
doPlayerPopupFYI(cid, msg) return true
elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Market or see the 'list' of characters for sale.") return true
end
return true
]]></talkaction>
------------------------------------------------------------------------------------
<event type="login" name="MarketLogin" event="script"><![CDATA[
function onLogin(cid)
domodlib('market')
if getPlayerStorageValue(cid, price) > 0 then return false
elseif getPlayerStorageValue(cid, 41792) ~= -1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
setPlayerStorageValue(cid, 41792, -1)
end
return true
end
]]></event>
</mod>
E esse é meu sistema de resetar
Spoiler
--[[ SCRIPTING> MarcelloMkez <scriptING ]]
--[[ [Advanced Reset System]
Autor: MarcelloMkez
Versão: 1.0
TFS: 0.3.6
Testado em: 8.50
Fórum: Somente usuários registrados poderão ver os links.
[Características]
~ Versão 1.0 ~
- Resets no Look;
- Premium Account ou não;
- Mudar Vocação;
- Limite de Resets;
- Opções para Abilitar e Desabilitar Condições;
[Em Construção]
- Stages Free e Premium;
- 'Talvez' um novo sistema de mudar Vocação;
sem data para postagem. ]]
function onSay(cid, words, param)
--[Configurações de Condição]__
config = { --[[verdadeiro / Falso]]
needPa = false, -- Precisa de Premium Account? [true / false]
needPz = false, -- Precisa estar em Protection Zone? [true / false]
battle = false, -- Precisa estar sem Batlle para Resetar? [true / false]
withe = false, -- Players PK Withe pode Resetar? [true / false]
red = false, -- Players PK Red pode Resetar? [true / false]
tp = false, -- Teleportar para o Templo após o reset? [true / false]
look = true, -- Mostrar Resets no Look do Player? [true / false]
addLimite = false, -- Abilitar Limite de Resets? [true / false]
setClasse = false, -- Mudar Vocação do player quando resetar? [true / false]
storage = 2310, -- Storage [valor]
--[Configurações do Reset]__
resetStatus = {
player = getPlayerGUID(cid), -- Não Mude.
lvl = 350 , -- Level Necessário para Resetar. [valor]
lvlreset = 8, -- Level que retornará após o Reset. [valor]
limite = 400, -- Máximo de resets que um player pode chegar. [valor]
newClasse = 1, -- Id da Nova Vocação após o Reset. [valor]
tempo= 2 -- Tempo para o Player deslogar para Resetar. Em segundos. [valor]
},
}
--[Funções]__
function Reseting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function noAll(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noTeleporting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noLook(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noClasse(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function setClasse(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function look(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function teleporting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function getResets(cid)
resets = getPlayerStorageValue(cid,config.storage)
if resets < 0 then
resets = 0
end
return resets
end
local resets = getResets(cid)
local needLvl ="Você precisa de "..config.resetStatus.lvl-getPlayerLevel(cid).." level's para resetar."
local msg ="~~[Reset: "..getResets(cid).."]~~ 'Sucesso ao Resetar! Você será deslogado em "..config.resetStatus.tempo.." Segundos."
--[Condiçoes]__
if(config.needPz == true) and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid,22,"Você Precisa estar em Protection Zone Para Resetar.")
return TRUE
elseif(config.addLimite == true) and (getResets(cid) == config.resetStatus.limite) then
doPlayerSendTextMessage(cid, 22, "Você ja atingiu o Limite de Resets.")
return TRUE
elseif(config.withe == false) and (getCreatureSkullType(cid) == 3) then
doPlayerSendTextMessage(cid,22,"Você ta PK White, por isso não pode resetar.")
return TRUE
elseif(config.red == false) and (getCreatureSkullType(cid) == 4) then
doPlayerSendTextMessage(cid,22,"Você ta PK Red, por isso não pode resetar.")
return TRUE
elseif(config.needPa == true) and not isPremium(cid) then
doPlayerSendTextMessage(cid,22,"Você Precisa ser Premium Account para Resetar.")
return TRUE
elseif(config.battle == true) and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid,22,"Você Precisa estar sem Battle para Resetar.")
return TRUE
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == true) and (config.setClasse == true) then
addEvent(Reseting, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == false) and (config.setClasse == false) then
addEvent(noAll, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == true) and (config.setClasse == true) then
addEvent(noTeleporting, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == false) and (config.setClasse == true) then
addEvent(noLook, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == true) and (config.setClasse == false) then
addEvent(noClasse, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == false) and (config.setClasse == true) then
addEvent(setClasse, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == true) and (config.setClasse == false) then
addEvent(look, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == false) and (config.setClasse == false) then
addEvent(teleporting, config.resetStatus.tempo* 1000, cid)
elseif doPlayerSendCancel(cid, needLvl) then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return TRUE
end
Pergunta
mczx4ndinho 0
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Characters Market System" version="1.0" author="LuckOake" contact="none" enabled="yes">
------------------------------------------------------------------------------------
<config name="market"><![CDATA[
price = 27112
owner = 27113
level = 30 -- Level mínimo que o character deve ter para ser vendido
min_price = 100 -- Preço mínimo de um character
max_price = 1000000 -- Preço máximo de um character
function doTransferCharacter(cid, accId)
return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
end
function doOfflinePlayerAddMoney(guid, money)
return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
end
function setOfflinePlayerStorageValue(name, key, value)
local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
if result:getID() == -1 then
return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
else
result:free()
return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
end
end
function getOfflinePlayerStorageValue(name, key)
local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
if result:getID() == -1 then
return nil
end
ret = result:getDataInt("value")
result:free()
return ret
end
function getOfflinePlayerValue(name, value)
local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
ret = result:getDataInt(value)
result:free()
return ret
end
function isCharacterForSale(name)
if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
return false
else
return true
end
end
]]></config>
------------------------------------------------------------------------------------
<talkaction words="!character" event="buffer"><![CDATA[
domodlib('market')
local t = string.explode(param, ",")
if t[1] == "sell" then
if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
elseif isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
elseif getPlayerByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
elseif getOfflinePlayerValue(t[2], "level") < level then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
elseif tonumber(t[3]) < min_price then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
elseif tonumber(t[3]) > max_price then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
end
setOfflinePlayerStorageValue(t[2], price, t[3])
setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" gold coins.')
elseif t[1] == "buy" then
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
elseif not playerExists(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
elseif not isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
elseif not doPlayerRemoveMoney(cid, getOfflinePlayerStorageValue(t[2], price)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough money. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." gold coins.") return true
end
if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
doOfflinePlayerAddMoney(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
else
doPlayerAddMoney(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), getOfflinePlayerStorageValue(t[2], price))
doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
end
doTransferCharacter(t[2], getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' gold coins.')
setOfflinePlayerStorageValue(t[2], owner, -1)
setOfflinePlayerStorageValue(t[2], price, -1) return true
elseif t[1] == "remove" then
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
elseif not isCharacterForSale(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
end
setOfflinePlayerStorageValue(t[2], price, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Market.') return true
elseif t[1] == "list" then
local result = db.getResult("SELECT `name` FROM `players`")
if result:getID() == -1 then
return true
end
local msg = "Characters for Sale:\n\n"
while true do
local name = result:getDataString("name")
if isCharacterForSale(name) then
local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
end
if not result:next() then
break
end
end
doPlayerPopupFYI(cid, msg) return true
elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Market or see the 'list' of characters for sale.") return true
end
return true
]]></talkaction>
------------------------------------------------------------------------------------
<event type="login" name="MarketLogin" event="script"><![CDATA[
function onLogin(cid)
domodlib('market')
if getPlayerStorageValue(cid, price) > 0 then return false
elseif getPlayerStorageValue(cid, 41792) ~= -1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The money is in your bank account.")
setPlayerStorageValue(cid, 41792, -1)
end
return true
end
]]></event>
</mod>
E esse é meu sistema de resetar
--[[ SCRIPTING> MarcelloMkez <scriptING ]]
--[[ [Advanced Reset System]
Autor: MarcelloMkez
Versão: 1.0
TFS: 0.3.6
Testado em: 8.50
Fórum: Somente usuários registrados poderão ver os links.
[Características]
~ Versão 1.0 ~
- Resets no Look;
- Premium Account ou não;
- Mudar Vocação;
- Limite de Resets;
- Opções para Abilitar e Desabilitar Condições;
[Em Construção]
- Stages Free e Premium;
- 'Talvez' um novo sistema de mudar Vocação;
sem data para postagem. ]]
function onSay(cid, words, param)
--[Configurações de Condição]__
config = { --[[verdadeiro / Falso]]
needPa = false, -- Precisa de Premium Account? [true / false]
needPz = false, -- Precisa estar em Protection Zone? [true / false]
battle = false, -- Precisa estar sem Batlle para Resetar? [true / false]
withe = false, -- Players PK Withe pode Resetar? [true / false]
red = false, -- Players PK Red pode Resetar? [true / false]
tp = false, -- Teleportar para o Templo após o reset? [true / false]
look = true, -- Mostrar Resets no Look do Player? [true / false]
addLimite = false, -- Abilitar Limite de Resets? [true / false]
setClasse = false, -- Mudar Vocação do player quando resetar? [true / false]
storage = 2310, -- Storage [valor]
--[Configurações do Reset]__
resetStatus = {
player = getPlayerGUID(cid), -- Não Mude.
lvl = 350 , -- Level Necessário para Resetar. [valor]
lvlreset = 8, -- Level que retornará após o Reset. [valor]
limite = 400, -- Máximo de resets que um player pode chegar. [valor]
newClasse = 1, -- Id da Nova Vocação após o Reset. [valor]
tempo= 2 -- Tempo para o Player deslogar para Resetar. Em segundos. [valor]
},
}
--[Funções]__
function Reseting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function noAll(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noTeleporting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noLook(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
return TRUE
end
function noClasse(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function setClasse(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doPlayerSetVocation(cid, config.resetStatus.newClasse)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function look(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = ' [Reset "..resets.."]' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function teleporting(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,config.storage,resets+1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `description` = '' WHERE `players`.`id` = "..config.resetStatus.player)
db.executeQuery("UPDATE `players` SET `level` = "..config.resetStatus.lvlreset..", `experience` = 0 WHERE `id` = "..config.resetStatus.player)
return TRUE
end
function getResets(cid)
resets = getPlayerStorageValue(cid,config.storage)
if resets < 0 then
resets = 0
end
return resets
end
local resets = getResets(cid)
local needLvl ="Você precisa de "..config.resetStatus.lvl-getPlayerLevel(cid).." level's para resetar."
local msg ="~~[Reset: "..getResets(cid).."]~~ 'Sucesso ao Resetar! Você será deslogado em "..config.resetStatus.tempo.." Segundos."
--[Condiçoes]__
if(config.needPz == true) and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid,22,"Você Precisa estar em Protection Zone Para Resetar.")
return TRUE
elseif(config.addLimite == true) and (getResets(cid) == config.resetStatus.limite) then
doPlayerSendTextMessage(cid, 22, "Você ja atingiu o Limite de Resets.")
return TRUE
elseif(config.withe == false) and (getCreatureSkullType(cid) == 3) then
doPlayerSendTextMessage(cid,22,"Você ta PK White, por isso não pode resetar.")
return TRUE
elseif(config.red == false) and (getCreatureSkullType(cid) == 4) then
doPlayerSendTextMessage(cid,22,"Você ta PK Red, por isso não pode resetar.")
return TRUE
elseif(config.needPa == true) and not isPremium(cid) then
doPlayerSendTextMessage(cid,22,"Você Precisa ser Premium Account para Resetar.")
return TRUE
elseif(config.battle == true) and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid,22,"Você Precisa estar sem Battle para Resetar.")
return TRUE
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == true) and (config.setClasse == true) then
addEvent(Reseting, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == false) and (config.setClasse == false) then
addEvent(noAll, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == true) and (config.setClasse == true) then
addEvent(noTeleporting, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == false) and (config.setClasse == true) then
addEvent(noLook, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == true) and (config.setClasse == false) then
addEvent(noClasse, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == false) and (config.setClasse == true) then
addEvent(setClasse, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == false) and (config.look == true) and (config.setClasse == false) then
addEvent(look, config.resetStatus.tempo* 1000, cid)
elseif getPlayerLevel(cid) >= config.resetStatus.lvl and (config.tp == true) and (config.look == false) and (config.setClasse == false) then
addEvent(teleporting, config.resetStatus.tempo* 1000, cid)
elseif doPlayerSendCancel(cid, needLvl) then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return TRUE
end
if doPlayerPopupFYI(cid, msg) then
end
return TRUE
end
--[By: MarcelloMkez]__
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados