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

Rewriting..

Ronaldino

Esso Eh
Joined
Dec 25, 2007
Messages
745
Reaction score
0
Hello, can someone rewrite this script for TFS standards?

function onUse(cid, item, topos, item2, topos)
local back = false
local czas = 0
local stopafk = 5 -- po ilu minutach wyrzuca z pokoju!

local np = {north=50001, south=50002, west=50003, east=50004} -- actionid pokoi, które teleportują na poszczególne strony.


npos = getThingfromPos(getPlayerPosition(cid))
if(item.actionid == np.north and npos.x==topos.x)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.y+2
else
npos = npos.y-2
back = true
end
setPlayerStorageValue(cid, 50000, 1)
elseif(item.actionid == np.south and npos.x==topos.x)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.y-2
else
npos = npos.y+2
back = true
end
setPlayerStorageValue(cid, 50000, 2)
elseif(item.actionid == np.west and npos.y==topos.y)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.x-2
else
npos = npos.x+2
back = true
end
setPlayerStorageValue(cid, 50000, 3)
elseif(item.actionid == np.east and npos.y==topos.y)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.x+2
else
npos = npos.x-2
back = true
end
setPlayerStorageValue(cid, 50000, 4)
end

if(back==true)then
setPlayerStorageValue(cid, 50000, -1)
end
npos.stackpos=253
local zajete = getThingfromPos(npos)
if(zajete == FALSE)then
doTeleportThing(cid, npos)
else
doPlayerSendTextMessage(cid, 19, 'Ten Pokoik jest aktualnie zajety.')
end
local function antyAFK(i)
if(getPlayerStorageValue(cid, 50000)==1)then
xpos = i.npos.y-2
elseif(getPlayerStorageValue(cid, 50000)==2)then
xpos = i.npos.y+2
elseif(getPlayerStorageValue(cid, 50000)==3)then
xpos = i.npos.x+2
elseif(getPlayerStorageValue(cid, 50000)==4)then
xpos = i.npos.x-2
end
doTeleportThing(i.cid, xpos)
end

if(czas == 0)then
addEvent(antyAFK, (stopafk*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
doPlayerSendTextMessage(cid, 19, 'Zostales wpuszczony do train roomu na '..stopafk..' Minut, aby przedluzyc czas kliknij po uplywie 10 minut na dzwignie!')
czas = os.time()
end

if(item.actionid == 64646)then
if(os.time() <= (czas+stopafk*30))then
stopEvent(antyAFK)
addEvent(antyAFK, (stopafk*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
doPlayerSendTextMessage(cid, 19, 'Czas treningu został przedluzony do '..stopafk..' minut!')
czas = os.time()
else
doPlayerSendTextMessage(cid, 19, 'Odczekaj '..(stopafk/2)..' min po kliknieciu w dzwignie')
end
end

if(item.itemid == 1945)then
doTransformItem(item.uid, 1946)
elseif(item.itemid == 1946)then
doTransformItem(item.uid, 1945)
end





end
 
change getPlayerPosition(cid) to getCreaturePosition(cid) only(?)

stopafk = 5 should be stopafk = 5 * 1000 * 60 if 5 minutes.
 
Ok, I changed it now;

[17/07/2008 18:47:38] luaGetThingfromPos(). Tile not found

&

[17/07/2008 18:35:52] attempt to index a nil value
[17/07/2008 18:35:52] stack traceback:
[17/07/2008 18:35:52] [C]: in function 'doTeleportThing'
[17/07/2008 18:35:52] data/actions/scripts/trainroom.lua:66: in function <data/actions/scripts/trainroom.lua:56>

Script at the moment;

function onUse(cid, item, topos, item2, topos)
local back = false
local czas = 0
stopafk = 5 * 1000 * 60 -- po ilu minutach wyrzuca z pokoju!

local np = {north=50001, south=50002, west=50003, east=50004} -- actionid pokoi, które teleportują na poszczególne strony.


npos = getThingfromPos(getCreaturePosition(cid))
if(item.actionid == np.north and npos.x==topos.x)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.y+2
else
npos = npos.y-2
back = true
end
setPlayerStorageValue(cid, 50000, 1)
elseif(item.actionid == np.south and npos.x==topos.x)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.y-2
else
npos = npos.y+2
back = true
end
setPlayerStorageValue(cid, 50000, 2)
elseif(item.actionid == np.west and npos.y==topos.y)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.x-2
else
npos = npos.x+2
back = true
end
setPlayerStorageValue(cid, 50000, 3)
elseif(item.actionid == np.east and npos.y==topos.y)then
if(getPlayerStorageValue(cid, 50000) == 0)then
npos = npos.x+2
else
npos = npos.x-2
back = true
end
setPlayerStorageValue(cid, 50000, 4)
end

if(back==true)then
setPlayerStorageValue(cid, 50000, -1)
end
npos.stackpos=253
local zajete = getThingfromPos(npos)
if(zajete == FALSE)then
doTeleportThing(cid, npos)
else
doPlayerSendTextMessage(cid, 19, 'Ten Pokoik jest aktualnie zajety.')
end
local function antyAFK(i)
if(getPlayerStorageValue(cid, 50000)==1)then
xpos = i.npos.y-2
elseif(getPlayerStorageValue(cid, 50000)==2)then
xpos = i.npos.y+2
elseif(getPlayerStorageValue(cid, 50000)==3)then
xpos = i.npos.x+2
elseif(getPlayerStorageValue(cid, 50000)==4)then
xpos = i.npos.x-2
end
doTeleportThing(i.cid, xpos)
end

if(czas == 0)then
addEvent(antyAFK, (stopafk*60000), {cid=cid, npos=getThingfromPos(getCreaturePosition(cid))})
doPlayerSendTextMessage(cid, 19, 'Zostales wpuszczony do train roomu na '..stopafk..' Minut, aby przedluzyc czas kliknij po uplywie 10 minut na dzwignie!')
czas = os.time()
end

if(item.actionid == 64646)then
if(os.time() <= (czas+stopafk*30))then
stopEvent(antyAFK)
addEvent(antyAFK, (stopafk*60000), {cid=cid, npos=getThingfromPos(getCreaturePosition(cid))})
doPlayerSendTextMessage(cid, 19, 'Czas treningu został przedluzony do '..stopafk..' minut!')
czas = os.time()
else
doPlayerSendTextMessage(cid, 19, 'Odczekaj '..(stopafk/2)..' min po kliknieciu w dzwignie')
end
end

if(item.itemid == 1945)then
doTransformItem(item.uid, 1946)
elseif(item.itemid == 1946)then
doTransformItem(item.uid, 1945)
end





end
 
In every doTeleportThing(cid, pos) add 0 or 1 (doesnt matter) at the end, eg:
doTeleportThing(cid, npos, 0)

About getThingfromPos()... idk, never used it, maybe it has to be like getThingfromPos(getCreaturePosition(cid).uid)
 
In every doTeleportThing(cid, pos) add 0 or 1 (doesnt matter) at the end, eg:
doTeleportThing(cid, npos, 0)

About getThingfromPos()... idk, never used it, maybe it has to be like getThingfromPos(getCreaturePosition(cid).uid)

About doTeleportThing.. when I change that then server crash at loading.
 
From where you have this code? I tried do fix it, but its done in wrong way, and im sure it will not work as it actually is.

Anyway, today I'll release my training system with code : D
 
From where you have this code? I tried do fix it, but its done in wrong way, and im sure it will not work as it actually is.

Anyway, today I'll release my training system with code : D

// Pl - To skrypt ersia nuba :p


It will be great if you'll release that :eek:
 
Back
Top