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

Action Guild Doors

Fyruz

★★★★★
Joined
Feb 7, 2009
Messages
556
Reaction score
19
Location
127.0.0.1
Working on TFS 8.54

Okay this will be my first tuorial and I'm going to teach you how to add my script to your server / explain what I did in the script.
This is going to be a Guild Door so every member of a guild can enter it, others can't. (Maybe nice idea make a room with small rooms with those guild doors in with TP's leading to guild halls?)
Well lets get started

Here is the script:
(Add this to Data/actions/others)

Code :
function onUse(cid, item, fromPosition, itemEx, toPosition)
local guildId = getPlayerGuildId(cid)
if guildId == 10 then
local cidPosition = getCreaturePosition(cid)
if cidPosition.x < toPosition.x then
doTeleportThing(cid, {x=1002,y=1036,z=5}, TRUE)
doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)
else
doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)
doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, but you're not in this guild.")
return TRUE
end
return FALSE
end

I'll explaing what I'm doing here:

This line is the function of what is going to happen

Code :
local guildId = getPlayerGuildId(cid)

Here it says that it will only work when players have guildId 10 (Change this to the guildId you want, look that up in your database)

Code :
if guildId == 10 then

This line gets the player position (needed because you will be teleported trough the door

Code :
local cidPosition = getCreaturePosition(cid)

This line should be pretty clear, it teleports the player with the right guildId to a specific place (Edit the X, Y, Z coördinates!)

Code :
doTeleportThing(cid, {x=1002,y=1036,z=5}, TRUE)

This is what the player will say when he is teleported to the specific place.

Code :
doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)

Exact same thing as 2 steps back but backwards, so it goes outside the door.

Code :
doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)

Exact same thing as 2 steps back but now it says it while going out.

Code :
doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)

Player will get this textmessage if he does not have the right guildId.

Code :
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, but you're not in this guild.")

Now for the XML code in actions.xml
go to Data/actions/actions.xml and add this line:

PHP Code:
<action actionid="5788" script="other/guild door.lua" />
actionid="5788" = the action ID you need to put on the door (Not unique ID!)

Now just map a door in your mapeditor, give it action ID 5788 ,<= is Changable, and enjoy

Credits Chaozas
 
Last edited:
you can use [.lua] [./lua] for .LUA scripts, you know
 
jajojei
Working on TFS 8.54

Okay this will be my first tuorial and I'm going to teach you how to add my script to your server / explain what I did in the script.
This is going to be a Guild Door so every member of a guild can enter it, others can't. (Maybe nice idea make a room with small rooms with those guild doors in with TP's leading to guild halls?)
Well lets get started

Here is the script:
(Add this to Data/actions/others)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local guildId = getPlayerGuildId(cid)
		if guildId == 10 then
		local cidPosition = getCreaturePosition(cid)
			if cidPosition.x < toPosition.x then
				doTeleportThing(cid, {x=1002,y=1036,z=5}, TRUE)
								doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)
		else
				doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)
								doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)
			end
			return TRUE
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, but you're not in this guild.")
			return TRUE
	end
	return FALSE
end

I'll explaing what I'm doing here:

This line is the function of what is going to happen

Code:
	local guildId = getPlayerGuildId(cid)

Here it says that it will only work when players have guildId 10 (Change this to the guildId you want, look that up in your database)

Code:
		if guildId == 10 then

This line gets the player position (needed because you will be teleported trough the door

Code:
		local cidPosition = getCreaturePosition(cid)

This line should be pretty clear, it teleports the player with the right guildId to a specific place (Edit the X, Y, Z coördinates!)

Code:
				doTeleportThing(cid, {x=1002,y=1036,z=5}, TRUE)

This is what the player will say when he is teleported to the specific place.

Code:
								doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)

Exact same thing as 2 steps back but backwards, so it goes outside the door.

Code:
				doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)

Exact same thing as 2 steps back but now it says it while going out.

Code:
								doCreatureSay(cid, "Welcome Guildmember!", TALKTYPE_ORANGE_1)

Player will get this textmessage if he does not have the right guildId.

Code:
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, but you're not in this guild.")

Now for the XML code in actions.xml
go to Data/actions/actions.xml and add this line:

PHP:
	<action actionid="5788" script="other/guild door.lua" />

actionid="5788" = the action ID you need to put on the door (Not unique ID!)

Now just map a door in your mapeditor, give it action ID 5788 ,<= is Changable, and enjoy

Greetz,
Chaosaz
 
i know :p but it'll be more helpful if you put the codes into code or lua tags :p
 
Back
Top