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

Exchange, death for 1(premium points)

anotapreta

New Member
Joined
Mar 12, 2010
Messages
104
Reaction score
0
lib
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
-------
:rolleyes:
 
Last edited:
creature script:
why use onKill when you can use onPrepareDeath? why just one temple position instead of the temple of the player?
Lua:
local stg = 1000 -- SAME AS THE TALKACTION ONE!

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if getPlayerStorageValue(cid, stg) == 1 then
    doPlayerSendTextMessage(cid, 21, "We removed 1 day of your premium so you don\'t die!")
    doPlayerRemovePremiumDays(cid, 1)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    doPlayerAddMana(cid, getPlayerMaxMana(cid))
    doTeleportThing(cid, getPlayerTown(cid))
end
return TRUE
end
isn't this a bit better?

not flaming, tho, I don't even know if it works.
 
@UP I added this in my script, thanks

EDIT: I am die and lose level, skills, bag, etc


(ok) talkactions


(error) creaturescripts

(error) doTeleportThing(cid, {{x=32383,y=31779,z=7}})
(error) doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
(error) doCreatureAddMana(cid, getCreatureMaxMana(cid))
(error) doPlayerSendTextMessage(cid, 21, "We removed 1 premium point of your account so you don\'t die!")
(ok) setPlayerStorageValue(cid, stg, 0)

\No bads msg on console/
 
Last edited:
edited, made a mistake, just use it as it is without editing anything, only the storage & the pd (premium days that will get removed after dying)
remember to separate the scripts!
Lua:
--------------------||------
------CreauteScript \/------
----------------------------
local pd = 1 -- SAME AS TALKACTION!
local stg = 1000 -- SAME AS THE TALKACTION ONE!
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if getPlayerStorageValue(cid, stg) == 1 and getPlayerPremiumDays(cid) >= pd then
    doPlayerSendTextMessage(cid, 21, "We removed 1 day of your premium so you don\'t die!")
    doPlayerRemovePremiumDays(cid, 1)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    doPlayerAddMana(cid, getPlayerMaxMana(cid))
    doTeleportThing(cid, getPlayerTown(cid))
end
return TRUE
end



-----------------||---------
------TALKACTION \/---------
----------------------------


local stg = 1000 -- same as the creature script.
local pd = 1 --SAME AS CREATURE SCRIPT!
function onSay(cid, words, param)
if getPlayerStorageValue(cid, stg) == false and getPlayerPremiumDays(cid) >= pd then
    doSendMagicEffect(getPlayerPosition(cid), 49)
    doPlayerSendTextMessage(cid, 21, "You have activated the no death mode for 1 premium day!") --it doesn't remove the premium day until he dies
    setPlayerStorageValue(cid, stg, 1)
     elseif getPlayerPremiumDays(cid) > pd then
     doSendMagicEffect(getPlayerPosition(cid), 2)
     doPlayerSendTextMessage(cid, 21, "You don\'t have atleast 1 premium day to activate the no death mode!")
    elseif getPlayerStorageValue(cid, stg) == 1 then
    doSendMagicEffect(getPlayerPosition(cid), 17)
    doPlayerSendTextMessage(cid, 21, "You have disactivated the no death mode, be aware!")
    setPlayerStorageValue(cid, stg, -1)
    end
return TRUE
end
 
Add for lib/data.lua
Lua:
dofile(getDataDir() .. "lib/pps.lua")

Add for lib/pps.lua
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

Add for creaturescripts/login.lua
Lua:
	registerCreatureEvent(cid, "onBlessPp")

-----
Add for creaturescripts.lua
Lua:
<event type="preparedeath" name="onBlessPp" event="script" value="blesspp.lua"/> 
<event type="login" name="blesspp" event="script" value="blesspp.lua"/>


Add for creaturescripts/blesspp.lua
Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
local stg = 321 -- storage
local templePosition = getTownTemplePosition(getPlayerTown(cid)) 
local playerPosition = getThingPosition(cid) 
local loss = getConfigValue('deathLostPercent')

 
 
		if (getPlayerStorageValue(cid,stg) >= 1) then
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) 
			doCreatureAddMana(cid, getCreatureMaxMana(cid)) 
		doTeleportThing(cid, templePosition)
			doPlayerSendTextMessage(cid, 21, "We removed 1 premium point of your account so you don\'t die!")
			setPlayerStorageValue(cid, stg, 0)

			doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 10*loss-loss-loss-loss-loss-loss-loss-loss-0) 
			doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 10*loss-loss-loss-loss-loss-loss-loss-loss-0) 
			doPlayerSetLossPercent(cid, PLAYERLOSS_SKILL, 10*loss-loss-loss-loss-loss-loss-loss-loss-0)

			doPlayerSendTextMessage(cid, 21, ""..loss.."")
			doSetCreatureDropLoot(cid, false) 
 			doSendAnimatedText(playerPosition, 'BLESS PP', 180) 
 			doSendMagicEffect(getPlayerPosition(cid), 53)
		end
	return true
end


function onLogin(cid)

local check = getPlayerStorageValue(cid, stg) <= 0 and "[OFF]"  or getPlayerStorageValue(cid, stg) == 1 and "[ON]" 

if getPlayerStorageValue(cid, stg) then
			doPlayerSendTextMessage(cid, 21, "SUPER BLESS: "..check.."  HELP: !blesspp ")
		end
 	return true
end

-----
Add for talkactions.lua
Lua:
<talkaction log="yes" words="!blesspp" script="blesspp.lua"/>

Add for talkactions/blesspp.lua
Lua:
function onSay(cid, words, param, channel)
local stg = 321 -- storage
local pps = 3 -- premium points
-------------------------------------------------------------------------	
	if(param == "") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "SUPER BLESS: [OFF] " or getPlayerStorageValue(cid, stg) == 1 and "SUPER BLESS: [ON] " 

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "..................")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "PRICE: "..pps.." Premium Points.")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "COMMANDS: !blesspp off | !blesspp on")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "VALUE: If you die, you will not lose anything. And you do not need (!bless) or (AOL) ")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have "..getPP(cid).." Premium point(s) on site.")

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "..................")

	end

-------------------------------------------------------------------------	
if(param == "on") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "SUPER BLESS: [ON] " or getPlayerStorageValue(cid, stg) == 1 and "SUPER BLESS: [OFF] " 


		if getPP(cid) >= pps then
		if (getPlayerStorageValue(cid, stg) <= 0) then

			setPlayerStorageValue(cid, stg, 1)
			doRemovePP(cid, pps)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")

else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Already is (on).")

		end
		end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have "..getPP(cid).." Premium point(s)")
	end

-------------------------------------------------------------------------	
 
	if(param == "off") then
local check = getPlayerStorageValue(cid, stg) <= 0 and "Trade PP for the death is blesspp (on)." or getPlayerStorageValue(cid, stg) == 1 and "SUPER BLESS: [OFF] " 
		if (getPlayerStorageValue(cid, stg) == 1) then
			setPlayerStorageValue(cid, stg, 0)
			doAddPP(cid, pps)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..check.."")
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have "..getPP(cid).." Premium point(s)")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Already is (off).")

		end
		return TRUE
	end
 
-------------------------------------------------------------------------
		return TRUE
end

-----
Now SPUER BLESS for premium points 1.0 [tsf 0.4.0] working ok!
-----


Now i need help in this script:
http://otland.net/f132/atomic-bomb-3x-charges-137682/#post1324722
 
Last edited:
Knight God
is possible to kill a person that receives 1 point premium?


Sim é so usar o onKill e depois o doAddPP(cid, 1) se você não tiver essa função é só adicionar

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
 
Back
Top