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

MoveEvent go through teleport you pay x crystal coins.

ghettobird

LUA newbie
Joined
Aug 17, 2013
Messages
679
Reaction score
132
Location
OTland
Hello Otlanders, sorry i've been inactive i was reading a lot of tutorials about lua, so i came up with this and i really hope it's useful :)


Lua:
 function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 2160) >= 50) then
doPlayerRemoveItem(cid, 2160, 50)
else
doPlayerSendCancel(cid, "You need 50 Crystal Coins To Go IN!")
end
doTeleportThing(cid, {x=994,y=1003,z=7}, true)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "TELEPORTED")
return true
end

Ok so how does this work? let's say i have 100cc and i want to go through a teleport (maybe it has special monsters) when i go inside the teleport 50cc will be removed, if i don't have 50cc it will say "YOU NEED 50 crystal coins to go in!

hope you guys like it =)
 
Hiho Ghetto,

You remind me of me, when i first time started to script ^^

Well, just to help you to make bit more quality to your scripts, you can also do like this:

Lua:
function onStepIn(cid, item, position, fromPosition)
	if (isPlayer(cid) and doPlayerRemoveItem(cid, 2160, 50)) then
		doTeleportThing(cid, {x=994,y=1003,z=7}, true)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "TELEPORTED")
	else
		doPlayerSendCancel(cid, "You need 50 Crystal Coins To Go IN!")
		doTeleportThing(cid, fromPosition)
	end
	return true
end

When they enter the teleport on your script, they wont be pushed from the teleport, they will be able to stand on it, also never forgot to check if its a player which enter the teleport, since a monster can cause a error.
 
Last edited:
Lua:
function onStepIn(cid, item, position, lastPosition)
	if (isPlayer(cid) and doPlayerRemoveItem(cid, 2160, 50)) then
		doTeleportThing(cid, {x=994,y=1003,z=7}, true)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "TELEPORTED")
	else
		doPlayerSendCancel(cid, "You need 50 Crystal Coins To Go IN!")
		doTeleportThing(cid, fromPosition)
	end
	return true
end

line 7
 
Better use getPlayerMoney() instead.

Lua:
function onStepIn(cid, item, position, fromPosition)
	if (isPlayer(cid) and getPlayerMoney(cid) >= 50000) then
		doTeleportThing(cid, {x = 994, y = 1003, z = 7}, true)
		doPlayerRemoveMoney(cid, 50000)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "TELEPORTED")
	else
		doPlayerSendCancel(cid, "You need 50 Crystal Coins To Go IN!")
		doTeleportThing(cid, fromPosition)
	end
	return true
end
 
no because maybe they want to do it for another item, like a token or something :)

We are thinking the same ^^ I thougt about use the money function, but as you stated. Maybe they want to use item instead of cash
 
Try not to use "doPlayerRemoveItem()" in if statements. You can always use "getPlayerItemCount()" and then call "doPlayerRemoveItem()". Simple situation in which your method is bugged:

Lua:
if(doPlayerRemoveMoney(cid, 2160, 50) and getPlayerLevel(cid) > 100) then

If player has lesser level than 100 but has 50 crystal coins, then it will return true but still remove player's money. :p
 
When i enter the Teleporter he take 50cc but when i want to enter the Teleporter without Money i get teleportet anyway...
 
Back
Top