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