• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent PVPBless Twist of Fate (NPC + Creatureevent)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
Tested in dev0.4, 3777 and 3884. Working 100%

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:
I know, but there is some similar npc and there is hundred of commands
 
lololololololololololol

pvp bless working only if player has been killed by other player...
 
Amaigad, I made a mistake, how can I check 'if died by player'?

EDIT: Should this work? I'm at job cant test
 
Last edited:
LOL and when on death for monster? need remove storage 77777 and 88888 LOL this script is wrong
 
I mark the following error
[Warning - Event::loadScript] Event onPreparedeath nor found <data/creaturescripts/scripts/PVPBless.lua>
 
Lets look:
Player can get PvP bless when have atleast one blessing (if have only second bless, i can get pvp bless),
then when i die with one bless and pvp bless, ive recive all 5 blessings after login.

fuck logic
 
Back
Top