LucasFerraz
Systems Analyst
Tested in dev0.4, 3777 and 3884. Working 100%
NPC
Creatureevent
PVPBless.lua
PVPBless2.lua
If someone know how to optimize this 'system' please post here
NPC
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function pvpbless(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if(isPremium(cid)) then
local price = 2000
if(getPlayerLevel(cid) > 30) then
price = (price + ((math.min(270, getPlayerLevel(cid)) - 30) * 200))
end
if getPlayerStorageValue(cid,77777) == TRUE then
npcHandler:say("Gods have already blessed you with this blessing!", cid)
elseif(not doPlayerRemoveMoney(cid, price)) then
npcHandler:say("You don't have enough money for blessing.", cid)
else
local any = false
for i = 1, 5 do
if(getPlayerBlessing(cid, i)) then
any = true
break
end
end
if(any) then
npcHandler:say("You have been blessed by the god of war!", cid)
setPlayerStorageValue(cid,77777,1)
else
npcHandler:say("You need to be blessed by at least one god to get this blessing.", cid)
end
end
else
npcHandler:say("You need to be premium to get this blessing", cid)
end
end
local node1 = keywordHandler:addKeyword({'twist of fate'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want Twist of Fate for '.. price ..' gps?'})
node1:addChildKeyword({'yes'}, pvpbless, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then', reset = true})
npcHandler:addModule(FocusModule:new())
Creatureevent
XML:
<event type="preparedeath" name="PVPBless" event="script" value="PVPBless.lua"/>
<event type="death" name="PVPBless2" event="script" value="PVPBless2.lua"/>
PVPBless.lua
Lua:
function onDeath(cid, corpse, deathList)
for i = 1, #deathList do
if(isPlayer(cid) and isPlayer(deathList[i])) then
if getPlayerStorageValue(cid,77777) == TRUE then
setPlayerStorageValue(cid,88888,1)
end
end
end
return true
end
PVPBless2.lua
Lua:
function onLogin(cid)
if getPlayerStorageValue(cid,88888) == TRUE then
doPlayerAddBless(cid, 1)
doPlayerAddBless(cid, 2)
doPlayerAddBless(cid, 3)
doPlayerAddBless(cid, 4)
doPlayerAddBless(cid, 5)
end
return true
end
If someone know how to optimize this 'system' please post here
Last edited: