Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Tenho esse sistema de points

<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-points" version="1.0" author="slawkens" contact="[email protected]" enabled="yes">
<config name="command-points-config"><![CDATA[
config = {
logFile = "data/logs/points.log", -- set file name where to save logs. Leave empty do disable logs.
 
pointsRune = {
enabled = "yes",
points = 50,
runeId = 2294,
minLevel = 10
},
 
changeName = {
enabled = "yes",
points = 50,
storage = 70009,
delay = 30 * 24 * 60 * 60 -- 30 days, in seconds
},
 
changeSex = {
enabled = "yes",
points = 20
},
 
removeSkull = {
enabled = "yes",
points = 50
},
 
refuelStamina = {
enabled = "yes",
points = 30
}
}
]]></config>
 
<lib name="command-points-lib"><![CDATA[
domodlib('command-points-config')
 
config.pointsRune.enabled = getBooleanFromString(config.pointsRune.enabled)
config.changeName.enabled = getBooleanFromString(config.changeName.enabled)
config.changeSex.enabled = getBooleanFromString(config.changeSex.enabled)
 
config.removeSkull.enabled = getBooleanFromString(config.removeSkull.enabled)
--config.removeSkull.frags = getBooleanFromString(config.removeSkull.frags)
 
config.refuelStamina.enabled = getBooleanFromString(config.refuelStamina.enabled)
 
function getPlayerPoints(cid)
return getAccountPoints(getPlayerAccountId(cid))
end
 
function doPlayerAddPoints(cid, points)
return doAccountAddPoints(getPlayerAccountId(cid), points)
end
 
function doPlayerRemovePoints(cid, points)
return doPlayerAddPoints(cid, -points)
end
 
function getAccountPoints(accountId)
local result = db.getResult('SELECT premium_points FROM accounts WHERE id = ' .. accountId)
local v = 0
if(result:getID() ~= -1) then
v = tonumber(result:getDataInt("premium_points"))
result:free()
end
 
return v
end
 
function doAccountAddPoints(accountId, points)
if(points < 0 and getAccountPoints(accountId) < math.abs(points)) then
return false
end
 
return db.executeQuery('UPDATE accounts SET premium_points = premium_points + ' .. points .. ' WHERE id = ' .. accountId)
end
 
command_points = {
config = config,
 
logAction = function (str)
if(command_points.config.logFile:trim() == '') then
return
end
 
doWriteLogFile(command_points.config.logFile, str)
end,
 
pointsRune = function (cid)
if(command_points.config.pointsRune.minLevel and getPlayerLevel(cid) < command_points.config.pointsRune.minLevel) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. command_points.config.pointsRune.minLevel .. " level to buy this rune.")
return true
end
 
if(getPlayerPoints(cid) < command_points.config.pointsRune.points) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. This rune cost " .. command_points.config.pointsRune.points .. " points.")
return true
end
 
local item = doCreateItemEx(command_points.config.pointsRune.runeId, 1)
local status = doPlayerAddItemEx(cid, item, false)
if(status ~= RETURNVALUE_NOERROR and status) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enought space for rune.")
return true
end
 
if(doPlayerRemovePoints(cid, command_points.config.pointsRune.points)) then
doSendMagicEffect(getCreaturePos(cid), 40)
doPlayerSave(cid)
command_points.logAction("pointsRune: " .. getCreatureName(cid))
else
doPlayerSendCancel(cid, "ERROR. Please try again later.")
end
end,
 
changeName = function (cid)
if(not getTileInfo(getCreaturePosition(cid)).protection) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use this command only in protection zone.")
return true
end
 
local lastChange = getPlayerStorageValue(cid, command_points.config.changeName.storage)
if(os.time() < lastChange + command_points.config.changeName.delay) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, this command have limited usage. You will be able to use it next time at " .. os.date("%X on %d.%m.%y", lastChange + command_points.config.changeName.delay) .. ".")
return true
end
 
if(getPlayerPoints(cid) < command_points.config.changeName.points) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Namelock cost " .. command_points.config.changeName.points .. " points.")
return true
end
 
if(doPlayerRemovePoints(cid, command_points.config.changeName.points)) then
setPlayerStorageValue(cid, command_points.config.changeName.storage, os.time())
doAddPlayerBanishment(getCreatureName(cid), BAN_PLAYER, -1, ACTION_NAMELOCK)
command_points.logAction("changeName: " .. getCreatureName(cid))
doRemoveCreature(cid)
else
doPlayerSendCancel(cid, "ERROR. Please try again later.")
end
end,
 
changeSex = function (cid)
if(getPlayerPoints(cid) < command_points.config.changeSex.points) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Change sex cost " .. command_points.config.changeSex.points .. " points.")
return true
end
 
local partner = getPlayerPartner(cid)
if(partner and partner ~= 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you cannot change your sex while being married.")
return true
end
 
if(doPlayerRemovePoints(cid, command_points.config.changeSex.points)) then
local newSex = getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE
doPlayerSetSex(cid, newSex)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sex changed to " .. (newSex == PLAYERSEX_FEMALE and "female" or "male") .. ".")
doPlayerSave(cid)
command_points.logAction("changeSex: " .. getCreatureName(cid))
else
doPlayerSendCancel(cid, "ERROR. Please try again later.")
end
end,
 
removeSkull = function (cid)
local skull = getCreatureSkullType(cid)
if(skull ~= SKULL_RED and skull ~= SKULL_BLACK) then
doPlayerSendCancel(cid, "You do not have red/black skull.")
return true
end
 
if(getPlayerPoints(cid) < command_points.config.removeSkull.points) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Remove skull cost " .. command_points.config.removeSkull.points .. " points.")
return true
end
 
if(doPlayerRemovePoints(cid, command_points.config.pointsRune.points)) then
db.executeQuery("UPDATE killers SET unjustified = 0 WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = " .. getPlayerGUID(cid) .. ")")
doCreatureSetSkullType(cid, SKULL_NONE)
doPlayerSetSkullEnd(cid, 0, skull)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your skull has been taken off!\nRemaining premium points: " .. getPlayerPoints(cid))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
doPlayerSave(cid)
command_points.logAction("removeSkull: " .. getCreatureName(cid))
else
doPlayerSendCancel(cid, "ERROR. Please try again later.")
end
end,
 
refuelStamina = function (cid)
if(getPlayerPoints(cid) < command_points.config.refuelStamina.points) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Stamina refill cost " .. command_points.config.refuelStamina.points .. " points.")
return true
end
 
local full = getConfigValue('staminaRatingLimitTop')
if(getPlayerStamina(cid) >= full) then
doPlayerSendCancel(cid, "Your stamina is already full.")
elseif(not isPremium(cid)) then
doPlayerSendCancel(cid, "You must have a premium account.")
else
if(doPlayerRemovePoints(cid, command_points.config.refuelStamina.points)) then
doPlayerSetStamina(cid, full)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
doPlayerSave(cid)
command_points.logAction("refuelStamina: " .. getCreatureName(cid))
else
doPlayerSendCancel(cid, "ERROR. Please try again later.")
end
end
end
}
]]></lib>
 
<talkaction words="!points;/points" event="script"><![CDATA[
domodlib('command-points-lib')
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. getPlayerPoints(cid) .. " points on your account.")
return true
end
 
param = param:lower():trim()
if(command_points.config.changeName.enabled and isInArray({"name", "namelock", "changename"}, param)) then
command_points.changeName(cid)
elseif(command_points.config.changeSex.enabled and isInArray({"sex", "changesex", "changender", "changegender"}, param)) then
command_points.changeSex(cid)
elseif(command_points.config.pointsRune.enabled and isInArray({"rune", "pointsrune"}, param)) then
command_points.pointsRune(cid)
elseif(command_points.config.removeSkull.enabled and isInArray({"rs", "skull", "frags"}, param)) then
command_points.removeSkull(cid)
elseif(command_points.config.refuelStamina.enabled and isInArray({"stamina"}, param)) then
command_points.refuelStamina(cid)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid option.")
end
return true
end
]]></talkaction>
 
<!--talkaction words="!rs" event="script"><![CDATA[
domodlib('command-points-lib')
function onSay(cid, words, param, channel)
command_points.removeSkull(cid)
return true
end
]]></talkaction>
 
  <talkaction words="!changename" event="script"><![CDATA[
domodlib('command-points-lib')
function onSay(cid, words, param, channel)
command_points.changeName(cid
return true
end
]]></talkaction>
 
  <talkaction words="!changesex" event="script"><![CDATA[
domodlib('command-points-lib')
function onSay(cid, words, param, channel)
command_points.changeSex(cid
return true
end
]]></talkaction-->
 
<!-- Points rune -->
<!-- You can remove/comment below lines if you don't want to use it -->
<action itemid="2294" allowfaruse="1" blockwalls="1" event="script"><![CDATA[
domodlib('command-points-lib')
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(not isPlayer(itemEx.uid) or not command_points.config.pointsRune.enabled) then
return false
end
 
if(doRemoveItem(item.uid, 1)) then
doPlayerAddPoints(itemEx.uid, command_points.config.pointsRune.points)
doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
doPlayerSave(cid)
command_points.logAction("pointsRune: " .. getCreatureName(cid) .. " (used)")
else
doPlayerSendTextMessage(cid, "Points couldn't be added. Please try again later.")
end
 
return true
end
]]></action>
 
<item id="2294" article="a" name="points rune" override="yes">
<attribute key="runeSpellName" value="Points Rune"/>
<attribute key="weight" value="120"/>
<attribute key="description" value="50 points. Use it on yourself or other player to add points."/>
</item>
</mod>

Tenho 2 Duvidas

 

1-Esse script tem erro?

 

2-Tem como criar uma talkaction,que add os points?

Editado por SkyThez (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo