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

3 Small Requests. REPP++

Rthom19

New Member
Joined
Mar 2, 2009
Messages
50
Reaction score
0
Location
Australia
Number One:
I need an onLogin script so that when you log in it'll get your town id and send you there.

Example:
You log out in trainers but when you log in you'll be at your home town.


Number Two:
I need a broadcast script for players that when used only the same vocation can see.

Example:
A druid says !broadcast Exiva Me Fast
[Druid]: Exiva Me Fast.
That will only be visible to vocations 1 and 2 (Sorc and Druid)
and
A knight says !broadcast Come to me
[Knight]: Come to me
Only visible by vocation ids 3 and 4(Pally and Knight)
Also it should have a 1 min usage time to avoid spamming.


Number Three:
I need a script so that when a certain monster dies, a certain voaction dies.

Example:
A team of Knights and Pallys go and kill a boss called "Mage Boss" when the mage boss dies i want all people with voaction id 1 and 2(Sorc and Druid) to die also.
Also it should broadcast how many people died..
"23 Mages Were Killed."

Thanks Alot ;D
 
Code:
function onLogin(cid)
	doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
	return true
end

Code:
function onSay(cid, words, param, channel)
	if (not isKnight(cid) or not isPaladin(cid) or not param) then
		return true
	end

	if (exhaustion.get(cid, 12345) ~= false) then
		return true
	end

	for _, player in ipairs(getPlayersOnline()) do
		if (isKnight(player) or isPaladin(player)) then
			doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, param)
		end
	end

	return true
end

Code:
function onKill(cid, target)
	if (string.lower(getCreatureName(cid)) == "mage") then
		for _, player in ipairs(getPlayersOnline()) do
			if (isDruid(player) or isSorcerer(player)) then
				doCreatureAddHealth(player, -getCreatureHealth(player))
			end
		end
	end
	return true
end

F.U.
 
Last edited:
Thanks >.<
Number 1 Works Great but the other two dont. :/

Idk if its something to do where i put them but im 99% sure its right..

Number Two(In Talkactions.xml):
Code:
<talkaction words="!broadcast" event="script" value="playerbroadcast.lua"/>

Number Three(In Creature Events.xml):
Code:
<event type="kill" name="MageBoss" event="script" value="mageboss.lua"/>

I get no errors in the console..

Im using Tfs 0.3.5 (Crying Damson)
 
Last edited:
1. string.lower(getCreatureName(cid)) == "mage" - here you have to set up boss' name.
2. in boss file add <event><script name="MageBoss"/></event>

3. Edited broadcast with debbuging (txt msgs):
Code:
function onSay(cid, words, param, channel)
	if (isKnight(cid) ~= true or isPaladin(cid) ~= true) then
		doPlayerSendCancel(cid, "Your vocation can't use this command.")
		return true
	end

	if (param == "") then
		doPlayerSendCancel(cid, "You have to type !broadcast message.")
		return true
	end

	if (exhaustion.get(cid, 12345) ~= false) then
		doPlayerSendCancel(cid, "You are exhausted.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return true
	end

	for _, pid in ipairs(getPlayersOnline())
		if (isPaladin(pid) == true or isKnight(pid) == true) then
			doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, param)
		end
	end

	return true
end
 
I Dont Understand, Where Do I Put It?

Lets Use The Monster "Cat" As An Example.
So..
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Cat" nameDescription="a cat" race="blood" experience="0" speed="124" manacost="220">
	<health now="20" max="20"/>
	<look type="276" corpse="7637"/>
	<targetchange interval="2000" chance="0"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="1"/>
		<flag attackable="1"/>
		<flag hostile="0"/>
		<flag illusionable="1"/>
		<flag convinceable="1"/>
		<flag pushable="1"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag runonhealth="8"/>
	</flags>
	<attacks>
		<attack name="melee" interval="2000" skill="0" attack="0"/>
	</attacks>
	<defenses armor="1" defense="2"/>
	<voices interval="5000" chance="10">
		<voice sentence="Mew!"/>
		<voice sentence="Meow!"/>
		<voice sentence="Meow meow!"/>
	</voices>
</monster>

Do I Put:
Code:
<event><script name="Cat"/></event>
In This File? Is That What You Mean?

Or In Creaturescripts.xml
Code:
<event type="kill" name="Cat" event="script" value="Cat.lua"/>

Add It After That?

Sorry If I Seem Nooby, But It Doesnt Work.
Thanks
 
Buuump.
Where do i put the stuff?

Also the broadcast one doesnt work, im not at my computer right now but from memory the error was on line 19 (i think), something to do with "if" and "do".

More Rep++ For Anyone else that can help.

EDIT:
Also can someone change the boss one so it doesnt effect people in non-pvp zones(Trainers)
 
I guess it's just like this:
creaturescripts/scripts/boss.lua
Lua:
function onKill(cid, target)
	if (string.lower(getCreatureName(cid)) == "mage") then
		for _, player in ipairs(getPlayersOnline()) do
			if (isDruid(player) or isSorcerer(player)) then
				doCreatureAddHealth(player, -getCreatureHealth(player))
			end
		end
	end
	return true
end

creaturescripts.xml
PHP:
<event type="kill" name="boss" script="boss.lua"/>

creaturescripts/scripts/login.lua under:
Lua:
registerCreatureEvent(cid, "Mail")
add:
Lua:
registerCreatureEvent(cid, "boss")

Broadcast, not sure if it will work:
Lua:
function onSay(cid, words, param, channel)
	if (isKnight(cid) ~= true or isPaladin(cid) ~= true) then
		doPlayerSendCancel(cid, "Your vocation can't use this command.")
		return true
	end

	if (param == "") then
		doPlayerSendCancel(cid, "You have to type !broadcast message.")
		return true
	end

	if (exhaustion.get(cid, 12345) ~= false) then
		doPlayerSendCancel(cid, "You are exhausted.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return true
	end

	for _, pid in ipairs(getPlayersOnline())
		if (isPaladin(pid) == true or isKnight(pid) == true) then
			doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, param)
		end

	return true
end
 
Last edited:
Just some stuff on chojraks script

ok look with the in creature script go to scripts and make a lua file called boss.lua and add this,i will use the monster cat.
Code:
function onDeath(cid, corpse, killer)
    registerCreatureEvent(cid, "cat")
    if (string.lower(getCreatureName(cid)) == "cat") then
        for _, player in ipairs(getPlayersOnline()) do
            if (isDruid(player) or isSorcerer(player)) then
                doCreatureAddHealth(player, -getCreatureHealth(player))
            end
        end
    end
    return true
end


then go to creaturescripts.xml and add this
Code:
<event type="death" name="cat" script="boss.lua"/>


In you monster folder-->cat, add this line under </flags>
Code:
<script>
      <event name="cat"/>
</script>

Hope it works.
If i helped Rep+.:D
 
OMG,

Thank You So Much!

:D

Rep++ For You. :)

Also If You Wanna Give It A Go, Could You Make It So:-
1. It Doesnt Effect People In Non-PvP Zones(Trainers)
2. It Broadcasts How Many People died..
Etc: 15 Mages Were Killed.

But Wow, Thanks A Ton!
 
Try this one:
Code:
function onDeath(cid, corpse, killer)
	registerCreatureEvent(cid, "cat")
	local died = 0
	if (string.lower(getCreatureName(cid)) == "cat") then
		for _, player in ipairs(getPlayersOnline()) do
			if (getTileInfo(getThingPos(player)).protection == FALSE) then
				if (isDruid(player) or isSorcerer(player)) then
					doCreatureAddHealth(player, -getCreatureHealth(player))
					died = died + 1
				end
			end
		end
	end
	if (died > 0) then
		doBroadcastMessage(died .." mages were killed.")
	end
	return true
end
 
@Cojrak
Thanks, the broadcasting works good, but the protection zone thingy doesnt.. it still killed people in trainers(non pvp zone)

I want it so when that creature is killed, all sorcs, druids, that are in Protection Zone, And Non Protection Zones To Die. But People in NON-PVP Zones Dont.

@Damadgerz
Its for a war server with 4 teams and each team has to protect their own boss >.<
 
Replace:
Code:
if (getTileInfo(getThingPos(player)).protection == FALSE) then

With:
Code:
if (getTileInfo(getThingPos(player)).pvp == FALSE) then
 
Back
Top