anotapreta
New Member
- Joined
- Mar 12, 2010
- Messages
- 104
- Reaction score
- 0
lib
talkactions (enable or disable) and default is off
<talkaction log="yes" words="!ppdeath" script="ppdeath.lua"/>
..........................................
. !ppdeath --> check ............
. !ppdeath ON --> activate ....
. !ppdeath OFF --> deactivate
..........................................
-------
creaturescripts
<event type="preparedeath" name="ppdeath" event="script" value="ppdeath.lua"/>
<event type="login" name="ppdeath" event="script" value="ppdeath.lua"/>
-------
if he is on, (point premium) exchange for death and teleports the player to the temple
-------
Lua:
function doAddPP(cid, points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function doRemovePP(cid, points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function getPP(cid, points)
local Query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";")
return Query:getDataInt("premium_points")
end
talkactions (enable or disable) and default is off
<talkaction log="yes" words="!ppdeath" script="ppdeath.lua"/>
..........................................
. !ppdeath --> check ............
. !ppdeath ON --> activate ....
. !ppdeath OFF --> deactivate
..........................................
Lua:
function onSay(cid, words, param, channel)
local stg = 321 -- storage
local pps = 1 -- premium points
-------------------------------------------------------------------------
if(param == "") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "Trade PP for the death is OFF. !ppdeath ON" or getPlayerStorageValue(cid, stg) == 1 and "Trade PP for the death is ON. !ppdeath OFF"
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")
end
-------------------------------------------------------------------------
if(param == "ON") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "Trade PP for the death is ON. !ppdeath OFF" or getPlayerStorageValue(cid, stg) == 1 and "Trade PP for the death is OFF. !ppdeath ON"
if getPP(cid, pps) >= pps then
if (getPlayerStorageValue(cid, stg) <= 0) then
setPlayerStorageValue(cid, stg, 1)
doRemovePP(cid, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Already is ON.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have "..pps.." Premium point(s)")
end
return TRUE
end
-------------------------------------------------------------------------
if(param == "OFF") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "Trade PP for the death is ppdeath ON. !ppdeath OFF" or getPlayerStorageValue(cid, stg) == 1 and "Trade PP for the death is OFF. !ppdeath ON"
if (getPlayerStorageValue(cid, stg) == 1) then
setPlayerStorageValue(cid, stg, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")
doAddPP(cid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Already is OFF.")
end
return TRUE
end
-------------------------------------------------------------------------
return TRUE
end
creaturescripts
<event type="preparedeath" name="ppdeath" event="script" value="ppdeath.lua"/>
<event type="login" name="ppdeath" event="script" value="ppdeath.lua"/>
Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
local stg = 321 -- storage
if (getPlayerStorageValue(cid,stg) >= 1) then
doTeleportThing(cid, {{x=32383,y=31779,z=7}})
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doPlayerSendTextMessage(cid, 21, "We removed 1 premium point of your account so you don\'t die!")
setPlayerStorageValue(cid, stg, 0)
end
return true
end
function onLogin(cid)
local check = getPlayerStorageValue(cid, stg) <= 0 and "Trade PP for the death is OFF. !ppdeath ON" or getPlayerStorageValue(cid, stg) == 1 and "Trade PP for the death is ON. !ppdeath OFF"
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")
return true
end
if he is on, (point premium) exchange for death and teleports the player to the temple
-------
Last edited: