• 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 Door for speial vocations!

ghettobird

LUA newbie
Joined
Aug 17, 2013
Messages
679
Reaction score
132
Location
OTland
Hello otlanders, today i present you a script i saw in a server and i thought why not make one just like it?

so let's go


actions/scripts
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local voc = getPlayerVocation(cid)
	if item.actionid == actionidofdoor and item.itemid == itemidofdoor then
	if voc == 3 then
		doTransformItem(item.uid,item.itemid+1)
		doTeleportThing(cid,toPosition)
		doPlayerSendTextMessage(cid,"You are a paladin, you passed this door!", TALKTYPE_RED)
	else
		doPlayerSendTextMessage(cid,"You cant pass this door, you are not a paladin!", TALKTYPE_ORANGE)
	end
	return 1
	end
end

i hope you guys like it!,

@printer: i did like u said and i used "talktype" instead of numbers, thanks for your advice :peace:
 
Keep on the good work ^^
 
Lua:
local config = {
	vocID = 3,
	vocName = 'Paladin',
	actionID = 1,
	itemID = 2
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local voc = getPlayerVocation(cid)
	if item.actionid == config.actionID and item.itemid == config.itemID then
		if voc == config.vocID then
			doTransformItem(item.uid, item.itemid+1)
			doTeleportThing(cid, toPosition)
			doPlayerSendTextMessage(cid,'You are a '..config.vocName..', you passed this door!', TALKTYPE_RED)
		else
			doPlayerSendTextMessage(cid,'You cant pass this door, you are not a '..config.vocName, TALKTYPE_ORANGE)
		end
	return 1
	end
end

Oh and is this really correct? (item.itemid) I haven't read up on tfs' functions yet
 
Last edited:
Hello otlanders, today i present you a script i saw in a server and i thought why not make one just like it?

so let's go


actions/scripts
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local voc = getPlayerVocation(cid)
	if item.actionid == actionidofdoor and item.itemid == itemidofdoor then
	if voc == 3 then
		doTransformItem(item.uid,item.itemid+1)
		doTeleportThing(cid,toPosition)
		doPlayerSendTextMessage(cid,"You are a paladin, you passed this door!", TALKTYPE_RED)
	else
		doPlayerSendTextMessage(cid,"You cant pass this door, you are not a paladin!", TALKTYPE_ORANGE)
	end
	return 1
	end
end

i hope you guys like it!,

@printer: i did like u said and i used "talktype" instead of numbers, thanks for your advice :peace:

Why not just use
Code:
if isPaladin = True then
or whatever it is instead of declaring a new variable and using said declared variable? It makes whatever you're scripting get done a lot faster :p
 
Why not just use
Code:
if isPaladin = True then
or whatever it is instead of declaring a new variable and using said declared variable? It makes whatever you're scripting get done a lot faster :p


Because of custom vocations(I guess?) and your one-liner is completely wrong. :/
 
Last edited:
I forgot exactly what the boolean was, I was just giving a rough idea :p
isPaladin(cid) does exactly the same thing he's currently doing, it doesn't cache or whatsoever you were thinking of.

getPlayerVocation() does not do much of stuff that would cause performance issues, it just queries the player id to get an instance of the player then returns his vocation. Querying player everytime is actually the performance issue.
 
isPaladin(cid) does exactly the same thing he's currently doing, it doesn't cache or whatsoever you were thinking of.

getPlayerVocation() does not do much of stuff that would cause performance issues, it just queries the player id to get an instance of the player then returns his vocation. Querying player everytime is actually the performance issue.

I don't have any of my scripts in front of me so I forgot how to use it too, but again, isPaladin(cid) would take less time to script with. I haven't really had problems with using it for my little EQ box (gives different eq for each vocation using 1 box). It was just a thought :p
 
@poopsiedoodle: i understand what you mean but it's easier for me to just make vocation 3 instead of vocation = paladin so i don't get any errors.
 
My Scripts
function onUse(cid, item, fromPosition, itemEx, toPosition)
local tilepos1 = {x=32023, y=32831, z=4}
local tilepos2 = {x=32025, y=32831, z=4}
if(itemEx.uid == 16102) and (itemEx.itemid == 5659) then
if getPlayerStorageValue(cid, 1824) == -1 then
doPlayerRemoveItem(cid, 4869, 1)
doPlayerAddItem(cid, 5937, 1)
doSendMagicEffect(tilepos1,45)
doSendMagicEffect(tilepos2,45)
setPlayerStorageValue(cid, 1824, 1)
doCreatureSay(cid, 'You succesfully took a sample of the rare griffinclaw flower', TALKTYPE_ORANGE_1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already took a sample of the rare griffinclaw flower.")
end
return TRUE
end
end
 
Back
Top