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

[TFS 0.3.6] Paid exp(similar to pvparena)

wesoly136

Member
Joined
Jul 30, 2009
Messages
562
Reaction score
9
Hi!
I have made a script which is teleporting you to an exp:
1. There can be only 1 person - you.
2. You can't logout there.
3. To get there you have to pay 50cc and use the switch.

And I want to make there a timer - after 60 minutes it teleports you to temple. Is that possible?

(Bad topic :S)
 
Last edited:
PHP:
function onThink(interval, lastExecution, thinkInterval)
--config
local storage = 1111
local timekick = 3600
local posout = {x=1000,y=1000,z=7}

for i, tid in ipairs(getPlayersOnline()) do
	timespend = getPlayerStorageValue(tid, storage)
	if(timespend>=timekick-1)then
		doTeleportThing(tid, pos, TRUE)
	else
	setPlayerStorageValue(tid, storage, timespend+1)
	end

end


PHP:
<globalevent name="tp" interval="1000" event="script" value="tp.lua"/>



rep ++ plx
 
Ok but now, can someone match this script to my, or make it in other way to work with my script?

This is mine:
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.uid == 1313 and item.itemid == 1945 or item.itemid == 1946 then
		kasapos = {x=970, y=740, z=7, stackpos=255}
		kasa = getThingfromPos(kasapos)
		player1pos = {x=969, y=740, z=7, stackpos=253}
		player1 = getThingfromPos(player1pos)

		if player1.itemid < 1 then
		doPlayerSendCancel(cid,"You must stay on right tile.")
		return 0
	end			
		for arenax = 1685, 1690 do
			for arenay = 1190, 1192 do
			local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
			local arenaCreature = getThingFromPos(arenaPosition)
				if(isPlayer(arenaCreature.uid) == TRUE) then
				doPlayerSendCancel(cid,"Exp is busy...")
				return 0
				end
			end	
		end
				
		if kasa.itemid == 2160 then
			if kasa.type >= 50 then			
				
				nplayer1pos = {x=1687, y=1191, z=7}

				doSendMagicEffect(player1pos,2)
				
				doRemoveItem(kasa.uid,kasa.type)

				doTeleportThing(player1.uid,nplayer1pos)

				doSendMagicEffect(nplayer1pos,10)

				doPlayerSendTextMessage(player1.uid,18,"Hi, you can exp now! :D")
			else
				doPlayerSendCancel(cid,"Musisz stac we wlasciwym miejscu.")
			end
		else
			doPlayerSendCancel(cid,"You have to pay 50cc.")
		end
	else
		return 0
   	end
end
 
PHP:
function onUse(cid, item, frompos, item2, topos)
        if item.uid == 1313 and item.itemid == 1945 or item.itemid == 1946 then
                kasapos = {x=970, y=740, z=7, stackpos=255}
                kasa = getThingfromPos(kasapos)
                player1pos = {x=969, y=740, z=7, stackpos=253}
                player1 = getThingfromPos(player1pos)

                if player1.itemid < 1 then
                doPlayerSendCancel(cid,"You must stay on right tile.")
                return 0
        end                     
                for arenax = 1685, 1690 do
                        for arenay = 1190, 1192 do
                        local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
                        local arenaCreature = getThingFromPos(arenaPosition)
                                if(isPlayer(arenaCreature.uid) == TRUE) then
                                doPlayerSendCancel(cid,"Exp is busy...")
                                return 0
                                end
                        end     
                end
                                
                if kasa.itemid == 2160 then
                        if kasa.type >= 50 then                 
                                
                                nplayer1pos = {x=1687, y=1191, z=7}

                                doSendMagicEffect(player1pos,2)
                                
                                doRemoveItem(kasa.uid,kasa.type)

                                doTeleportThing(player1.uid,nplayer1pos)

                                doSendMagicEffect(nplayer1pos,10)

  setPlayerStorageValue(tid, 11111, 1)                            doPlayerSendTextMessage(player1.uid,18,"Hi, you can exp now! :D")
                        else
                                doPlayerSendCancel(cid,"Musisz stac we wlasciwym miejscu.")
                        end
                else
                        doPlayerSendCancel(cid,"You have to pay 50cc.")
                end
        else
                return 0
        end
end


PHP:
function onThink(interval, lastExecution, thinkInterval) 
--config 
local storage = 1111 
local posout = {x=1000,y=1000,z=7} 

for i, tid in ipairs(getPlayersOnline()) do 
    timespend = getPlayerStorageValue(tid, storage) 
    if(timespend>=3600)then 
        doTeleportThing(tid, pos, TRUE)
setPlayerStorageValue(tid, storage, -1) 
 
    elseif(timespend=<1)
    setPlayerStorageValue(tid, storage, timespend+1) 
    end 

end
 
So:
1. You wrote in actions(exp.lua) setstorage (tid....) and with 'tid' it didnt work. When I changed to 'cid' it works, but..
2. Ur globalevent sends in console (EDIT: when I wrote return true near end it doesn't send these errors)
Code:
[25/04/2010 09:32:22] [Error - GlobalEvents::think] Couldn't execute event: tp
[25/04/2010 09:32:28] [Error - GlobalEvents::think] Couldn't execute event: tp
[25/04/2010 09:32:34] [Error - GlobalEvents::think] Couldn't execute event: tp
every x seconds in
Code:
<globalevent name="tp" interval="x" event="script" value="tp.lua"/>

I tried these scripts on a few seconds :P

Another way
I saw on few OTS something like, when you wear a ring it takes 1 platinum coin per second. We can do something like :
When you have storage 1111 you will pay scarab coins per minute(or second) which you will receive in exp.lua...

PS
Pl? XD
 
Last edited:
1. I don't know if it will work, made it in a hurry, maybe forgot some things
2. Put no logout zone at the place you will get teleported
3. The script is made for the post above this(I think it's what you want)

ServerDirectory/mods/tp.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="tp" version="1.0" author="Slaktaren" contact="my ass" enabled="yes">

	<config name="TP_Config"><![CDATA[
	
		local cfg = {
			storage = 1234, -- Storage when you will lose coins
			item = 2345, -- Item you will lose every X minute
			minutes = 1, -- every X minutes it will remove 1 item
			newPos = {x = XXX, y = YYY, z = Z}
			}	
		
	]]></config>
	<action actionid="XXXX" event="script"><![CDATA[
	domodlib("TP_Config")
			setPlayerStorageValue(cid, cfg.storage, 1)
			doTeleportThing(cid, newPos)
			doSendMagicEffect(newPos, CONST_ME_TELEPORT)
			
	return TRUE
	]]></action>
	
	<globalevent name="ItemCheck" interval="1" event="script"><![CDATA[
	domodlib("TP_Config")
		for _, tid in ipairs(getPlayersOnline()) do
		
			if getPlayerStorageValue(tid, cfg.storage) == 1 then
				addEvent(removeItem, cfg.minutes * 1000 * 60)
			end
	
		function removeItem()
				if getPlayerItemCount(tid, cfg.item) >= 1 then
					if getPlayerStorageValue(tid, cfg.storage) == 1 then
						doPlayerTakeItem(tid, cfg.item, 1)
					else
						doTeleportThing(tid, getPlayerTown(tid))
						setPlayerStorageValue(tid, cfg.storage, 0)
					end
				end
			end
		end
		
	]]></globalevent>
</mod>
 
Last edited:
I made some small corrects and console shows
Code:
[25/04/2010 16:20:46] [Error - GlobalEvent Interface] 
[25/04/2010 16:20:46] buffer:onThink
[25/04/2010 16:20:46] Description: 
[25/04/2010 16:20:46] [string "loadBuffer"]:3: attempt to index global 'cfg' (a nil value)
[25/04/2010 16:20:46] stack traceback:
[25/04/2010 16:20:46] 	[string "loadBuffer"]:3: in function <[string "loadBuffer"]:1>
[25/04/2010 16:20:46] [Error - GlobalEvents::think] Couldn't execute event: ItemCheck

(before it was crashing my serw during the startup)
 
test it now, edited the post

EDIT;
First you have to use an item in game with XXXX action id, then the script will give you a storage value, and teleport you to "newPos"
The global event will check if you have that storage value, if you have the storage and the correct item id, the script will remove 1 of the items in the stack each minute, if you have the storage and no items left it will teleport you to your temple.

NOTE; it maybe will teleport all players that not have the items, so please check it and tell me xd
 
Last edited:
Every second(interval) it sends
Code:
[25/04/2010 20:48:51] [Error - GlobalEvent Interface] 
[25/04/2010 20:48:51] buffer:onThink
[25/04/2010 20:48:51] Description: 
[25/04/2010 20:48:51] (luaGetCreatureStorage) Creature not found
[25/04/2010 20:48:51] [Error - GlobalEvents::think] Couldn't execute event: ItemCheck

When I use switch
Code:
[25/04/2010 20:47:09] [Error - Action Interface] 
[25/04/2010 20:47:09] buffer:onUse
[25/04/2010 20:47:09] Description: 
[25/04/2010 20:47:09] [string "loadBuffer"]:3: attempt to index global 'config' (a nil value)
[25/04/2010 20:47:09] stack traceback:
[25/04/2010 20:47:09] 	[string "loadBuffer"]:3: in function <[string "loadBuffer"]:1>

PS
I changed word 'cfg' to 'config' because before it, it was showing every second "a nil value 'cfg'" :/
 
Ok, I will test it tomorrow
cu

edit
Code:
[26/04/2010 15:28:57] [Error - GlobalEvents::think] Couldn't execute event: ItemCheck
every second :/
 
Last edited:
Ok, fixed.

Solution:
function addEvent:
LUA:
local timed = 15
								local czas = 0
								 local function timer(i)
								 if(getPlayerStorageValue(cid, 11553)==1)then
									xpos = {x=1000, y=1000, z=7}
									npos = {x=1000, y=1000, z=7}
									   end
							doTeleportThing(i.cid, xpos)
							doPlayerSendTextMessage(cid, 19, 'Your time for exp has expired!')
						end
						if(czas == 0)then
						addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
						doPlayerSendTextMessage(cid, 19, 'You have 15 minutes for exp!')
					czas = os.time()
					end
					 if(os.time() <= (czas+timed*30))then
					stopEvent(timer)
					end
Thanks for trying :)
 
Back
Top