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

2 questions.

cake

Banned User
Joined
Jul 24, 2010
Messages
838
Reaction score
58
Location
good or bad,
Hiya.

1) Is it possible to script so if any player has any skull [white, red, black], & if they try to talk to an NPC, the NPC will say something such as 'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!' - one of those random lines. When this is done, the NPC will deal an (invisible if possible) spell dealing about X damage on the player.

The damage will be:
If white skulled: 10-20
If red skulled: 20-40
If black skulled: 50-70

The NPC will only hit once unless they start over the conversation.


2) Is it possible to make an NPC who only talks to skulled people? If non-skulled people talks with the NPC will it strike an spell (again invisible) while saying 'Only outlaws may speak to me!', the spell will deal about 10-20 damage.


Thanks for any replies :)
 
1) Add this in the npc script:
LUA:
local t = {
	msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
	damage = {
		[SKULL_WHITE] = {10, 20},
		[SKULL_RED] = {20, 40},
		[SKULL_BLACK] = {50, 70}
	}
}

function greetCallback(cid)
	local v = t.damage[getCreatureSkullType(cid)]
	if v then
		selfSay(t.msg[math.random(#t.msg)], cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
		return false
	else
		return true
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
 
1) Add this in the npc script:
LUA:
local t = {
	msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
	damage = {
		[SKULL_WHITE] = {10, 20},
		[SKULL_RED] = {20, 40},
		[SKULL_BLACK] = {50, 70}
	}
}

function greetCallback(cid)
	local v = t.damage[getCreatureSkullType(cid)]
	if v then
		selfSay(t.msg[math.random(#t.msg)], cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
		return false
	else
		return true
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

Oh thanks!
I just add it at the end of all the NPCs? :p
 
Oh thanks!
I just add it at the end of all the NPCs? :p

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t = {
	msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
	damage = {
		[SKULL_WHITE] = {10, 20},
		[SKULL_RED] = {20, 40},
		[SKULL_BLACK] = {50, 70}
	}
}

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 greetCallback(cid)
	local v = t.damage[getCreatureSkullType(cid)]
	if v then
		selfSay(t.msg[math.random(#t.msg)], cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
		return false
	else
		return true
	end
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t = {
	msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
	damage = {
		[SKULL_WHITE] = {10, 20},
		[SKULL_RED] = {20, 40},
		[SKULL_BLACK] = {50, 70}
	}
}

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 greetCallback(cid)
	local v = t.damage[getCreatureSkullType(cid)]
	if v then
		selfSay(t.msg[math.random(#t.msg)], cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
		return false
	else
		return true
	end
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())

uhm, add that or the other code? I know nothing, so I don't know which one is 'best' :p

yep, anywhere :p

I'll test if it works =D

I'll leave now but I'll come back later tomorrow with a response :)
 
Last edited:
2)
LUA:
function greetCallback(cid)
	if getCreatureSkullType(cid) < SKULL_WHITE then
		selfSay('Only outlaws may speak to me!', cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, -10, -20, CONST_ME_NONE)
		return false
	else
		return true
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
I'll test if it works =D

I'll leave now but I'll come back later tomorrow with a response :)

Uh, I've tested and both of them work.
 
2)
LUA:
function greetCallback(cid)
	if getCreatureSkullType(cid) < SKULL_WHITE then
		selfSay('Only outlaws may speak to me!', cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, -10, -20, CONST_ME_NONE)
		return false
	else
		return true
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)


Uh, I've tested and both of them work.
I thought she wanted it so you cant speak to npcs while skulled. The script says only outlaws can speak to me o.o
 
I thought she wanted it so you cant speak to npcs while skulled. The script says only outlaws can speak to me o.o

1) Add this in the npc script:
LUA:
local t = {
	msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
	damage = {
		[SKULL_WHITE] = {10, 20},
		[SKULL_RED] = {20, 40},
		[SKULL_BLACK] = {50, 70}
	}
}

function greetCallback(cid)
	local v = t.damage[getCreatureSkullType(cid)]
	if v then
		selfSay(t.msg[math.random(#t.msg)], cid)
		doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
		return false
	else
		return true
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

VGS3d.jpg
 
Modify data/npc/lib/npcsystem/npchandler.lua:
Code:
[B][COLOR="red"]	local t = {
		msg = {'Outlaws like you helped Belial!', 'Leave me or you will get hurt!', 'Anyone helping Belial will be slain!'},
		damage = {
			[SKULL_WHITE] = {10, 20},
			[SKULL_RED] = {20, 40},
			[SKULL_BLACK] = {50, 70}
		},
		outlawNPCs = {"Foo", "Bar"}
	}[/COLOR][/B]

	-- Greets a new player.
	function NpcHandler:greet(cid)
		if(cid ~= 0) then
			local callback = self:getCallback(CALLBACK_GREET)
			if(callback == nil or callback(cid)) then
				if(self:processModuleCallback(CALLBACK_GREET, cid)) then
[B][COLOR="red"]					if isInArray(t.outlawNPCs, getCreatureName(getNpcCid())) and getCreatureSkullType(cid) < SKULL_WHITE then
						selfSay('Only outlaws may speak to me!', cid)
						doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, -10, -20, CONST_ME_NONE)
						return false
					end

					local v = t.damage[getCreatureSkullType(cid)]
					if v then
						selfSay(t.msg[math.random(#t.msg)], cid)
						doTargetCombatHealth(getNpcCid(), cid, COMBAT_PHYSICALDAMAGE, - v[1], - v[2], CONST_ME_NONE)
						return false
					end[/COLOR][/B]

					local msg = self:getMessage(MESSAGE_GREET)
					local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
					msg = self:parseMessage(msg, parseInfo)

					self:say(msg)
					self:addFocus(cid)
					self:say(msg, cid)
				end
			end
		end
	end
 
Back
Top