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

How to make action ids work with onStepIn?

ArkSeyonet

Chancho
Joined
Nov 11, 2008
Messages
201
Reaction score
11
Can anyone tell me the reason why my script won't work? I'm not posting the actual script, because I narrowed it down to something simple.

When I use
Code:
function onStepIn(cid, item, position, fromPosition)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,'You have been kicked from the enemy zone. You cannot stay in enemy territory for more than seconds.')
end

The script works perfectly.

But when I use

Code:
function onStepIn(cid, item, position, fromPosition)
	if getPlayerVocation(cid) == 8 then
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,'You have been kicked from the enemy zone. You cannot stay in enemy territory for more than seconds.')
	end
end

It doesn't show errors, but it just doesn't do anything. I've double checked that I'm vocation 8. And everything.

Using Shawak's War Server. SQL.

*UPDATE*

The above was solved, due to the excellent help from two users. Now, the last problem I ran into is making action ids work.

So instead of

Code:
[COLOR="RoyalBlue"]if[/COLOR] action.id == [COLOR="SandyBrown"]1500[/COLOR] [COLOR="RoyalBlue"]then[/COLOR]

How should I do it?
 
Last edited:
Code:
function onStepIn(cid, item, position, fromPosition)
	if(isKnight(cid) == TRUE and getPlayerPromotionLevel(cid) > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been kicked from the enemy zone. You cannot stay in enemy territory for more than seconds.")
	end
end
 
Can anyone tell me the reason why my script won't work?

Cyko already gave you a working script, but I think you're also asking for the "reason" of why didnt yours work, so Ill give it to you.

The reason is this:

Lua:
if getPlayerVocation(cid) == 8 then

So why doesnt it work like that? Well, when handling vocations like that, I think you can only do it with arrays! Example:

Lua:
local vocation = {1,4,7,8}

if isInArray(vocation, getPlayerVocation(cid)) then
(in your specific case it would be "local vocations = {8}")

Not sure if you can "only do it with arrays", but at least that's a problem I had earlier this year when I didnt know about arrays, but after using them I never had problems with it again! :)

So anyway in that script, it will take all the vocations specified on the "vocation" table and it will only let those players "step in".

You can also do:

Lua:
if not(isInArray(vocation, getPlayerVocation(cid))) then

And it will make it so only the vocations that are not specified on the table will be able to pass.

Hope you could understand me :)

PS: Remember to post your questions on the Support subforum, because this one is supposed to be only for releases.. :thumbup:
 
Last edited:
Okay, thanks for the replies everyone. I will try out what both of you said, and I really appreciate that you took the time to help me out.

@Guitar Freak
If I posted in wrong section, sorry. I didn't see where else to post. Thanks for the heads up, I'll remember from now on.

Not meaning to be a bother, but how would you make this also go along with, tile action ids?
 
Last edited:
Code:
function onStepIn(cid, item, position, fromPosition)
	if([B][COLOR="Red"]item.actionid == 1500 and [/COLOR][/B]isKnight(cid) == TRUE and getPlayerPromotionLevel(cid) > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been kicked from the enemy zone. You cannot stay in enemy territory for more than seconds.")
	end
end
Item tables look something like this:
Lua:
item = {
	uid = <auto increment number above 70000>,
	itemid = 2463,
	type = 0,
	actionid = 0
}
 
Back
Top