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

Solved [Globalevents] Script error on distro, TFS 1.1

Hugofasima

Website: thenosegang.servegame.com
Joined
Jun 24, 2015
Messages
206
Reaction score
23
It's my first try on scripting. I read some tutorials but I can't figure it out what is happening with my low knowledge.

TFS 1.1

My error:
Code:
[Error - GlobalEvents::think] Failed to execute event: check

My tag:
Code:
<globalevent name="check" interval="1" script="events/checkDeaths.lua"/>

My script:
Code:
local items = {2557}

local eventTopxyz = {x = 1000, y = 1000, z = 7, stackpos = 253}
local eventBottomxyz = {x = 1000, y = 1000, z = 7, stackpos = 253}
local eventPosition = eventTopxyz, eventBottomxyz

local outOfEvent = {x = 1000, y = 1000, z = 7}
local players = getThingfromPos(eventPosition)

function onThink(intravel)
if Game.getStorageValue(cid, rushEvent) == 1 then
if Game.getStorageValue(cid, redDeaths) == 0 or Game.getStorageValue(cid, blueDeaths) == 0 then
for i, pid in ipairs(players) do
if (isPlayer(players)) then
setPlayerStorageValue(pid, rushPlayer, 0)
doTeleportThing(pid, outOfEvent)
doPlayerSetLossPercent(pid, 1, 100)
if getPlayerStorageValue(pid, rushTeam) == 1 or 2 then
setPlayerStorageValue(pid, rushTeam, 0)
end
if getPlayerStorageValue(pid, rushPlayer) == 1 or 2 then
setPlayerStorageValue(pid, rushPlayer, 0)
end
if getPlayerStorageValue(pid, rushWinner) then
setPlayerStorageValue(pid, rushWinner, 0)
doPlayerAddItem(pid, math.random(items), 1)
if math.random(item) == 1 then
doPlayerAddItem(pid, items[1], 1)
end
end
end
end
end
end
end


Thanks every one is helping me, I'm learning a lot and has started studying scripts. I need you guys help!

Thanks OT Land!
 
It's my first try on scripting. I read some tutorials but I can't figure it out what is happening with my low knowledge.

TFS 1.1

My error:
Code:
[Error - GlobalEvents::think] Failed to execute event: check

My tag:
Code:
<globalevent name="check" interval="1" script="events/checkDeaths.lua"/>

My script:
Code:
local items = {2557}

local eventTopxyz = {x = 1000, y = 1000, z = 7, stackpos = 253}
local eventBottomxyz = {x = 1000, y = 1000, z = 7, stackpos = 253}
local eventPosition = eventTopxyz, eventBottomxyz

local outOfEvent = {x = 1000, y = 1000, z = 7}
local players = getThingFromPos(eventPosition)

function onThink(interval)
  if Game.getStorageValue(cid, rushEvent) == 1 then
    if Game.getStorageValue(cid, redDeaths) == 0 or Game.getStorageValue(cid, blueDeaths) == 0 then
      for i, pid in pairs(players) do
         if (isPlayer(pid)) then
           setPlayerStorageValue(pid, rushPlayer, 0)
           doTeleportThing(pid, outOfEvent)
           doPlayerSetLossPercent(pid, 1, 100)
           if getPlayerStorageValue(pid, rushTeam) == 1 or 2 then
           setPlayerStorageValue(pid, rushTeam, 0)
        end
        if getPlayerStorageValue(pid, rushPlayer) == 1 or 2 then
          setPlayerStorageValue(pid, rushPlayer, 0)
       end
       if getPlayerStorageValue(pid, rushWinner) then
         setPlayerStorageValue(pid, rushWinner, 0)
         doPlayerAddItem(pid, math.random(items), 1)
         if math.random(item) == 1 then
            doPlayerAddItem(pid, items[1], 1)
         end
       end
     end
   end
end
end
end


Thanks every one is helping me.
I did changes on your code. Next time try to tab it please. You had some misspellings, Dunno if it will work yet. Consider to use proper 1.x functions and not compat one pid:IsPlayer() instead of isPlayer(pid)
 
I did changes on your code. Next time try to tab it please. You had some misspellings, Dunno if it will work yet. Consider to use proper 1.x functions and not compat one pid:IsPlayer() instead of isPlayer(pid)

Samco, it works!!! THANK YOU.

I'll follow what you said. Is there a better way to write scripts; with TFS functions I will have no problems. I got it.

100% SOLVED!
 
Last edited:
@samco

I can't find a list with TFS functions, did you have it for me?

I have oly this one:

https://github.com/DSpeichert/tfs/blob/master/doc/LUA_FUNCTIONS

And it seems to be like compat functions.




What did you mean with that? My english is bad...
With spoiler or something?
No sorry i dont have any list :/

About tabbing, i mean to add tabs or spaces on your code lines:
BAD
Code:
if blabla then
doBalBlalba(blo)
if not isBla() then
blo
end
end
OK
Code:
if blabla then
  doBalBlalba(blo)
  if not isBla() then
    blo
  end
end

EDIT: check https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L1803
 
No sorry i dont have any list :/

About tabbing, i mean to add tabs or spaces on your code lines:
BAD
Code:
if blabla then
doBalBlalba(blo)
if not isBla() then
blo
end
end
OK
Code:
if blabla then
  doBalBlalba(blo)
  if not isBla() then
    blo
  end
end

EDIT: check https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L1803

Use tabs insted, spaces are ment for when you write a text.
Tabs are ment for coding, don't say they look bad or smth like that... If you have a good enough program to script in you can change the look of a tab(2 spaces, 4 spaces, 99 spaces etc).
 
Back
Top