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

Use Item Force Logout TFS 0.4

TomBartezz

Member
Joined
May 29, 2016
Messages
159
Reaction score
17
Hi I tried some scripts but it did not work how would i fix it and which one would be the best?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doRemoveCreature(cid[, forceLogout = true])
end

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if pz == true or getCreatureSkullType(cid) == SKULL_WHITE then
doRemoveCreature(cid)
end

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if pz == true or getCreatureSkullType(cid) == SKULL_WHITE then
doRemoveCreature(cid[, forceLogout = true])
end

Code:
[Error - LuaScriptInterface::loadFile] data/actions/scripts/logout.lua:3: unexpected symbol near ','
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/logout.lua)
data/actions/scripts/logout.lua:3: unexpected symbol near ','
Most of them end in this error ^
Code:
    <action itemid="10305" event="script" value="logout.lua"/>
 
Last edited:
Solution
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getTilePzInfo(getPlayerPosition(cid)) == FALSE then
        doRemoveCreature(cid)
    end
    return true
end
because the arguments between [] are optional, they aren't meant to be taken EXACTLY like that
you can just do doRemoveCreature(cid)
 
because the arguments between [] are optional, they aren't meant to be taken EXACTLY like that
you can just do doRemoveCreature(cid)
this?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if pz == true or getCreatureSkullType(cid) == SKULL_WHITE then
    doRemoveCreature(cid)
end
 
this?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if pz == true or getCreatureSkullType(cid) == SKULL_WHITE then
    doRemoveCreature(cid)
end
that wont work because pz isnt a variable anywhere in your code
if getTilePzInfo(getCreaturePosition(cid)) or getCreatureSkullType(cid) == SKULL_WHITE then
 
You'd also want to return the function..
Code:
function onUse(args)
    -- code
    return true
end
Code:
local pos = getPlayerPosition(cid)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getTilePzInfo(pos) == FALSE then
    doRemoveCreature(cid)
return true
end
I used this but it has this error now
Code:
[Error - Action Interface]
data/actions/scripts/logout.lua:onUse
Description:
(luaGetTileInfo) Tile not found

[Error - Action Interface]
data/actions/scripts/logout.lua:onUse
Description:
data/lib/050-function.lua:283: attempt to index a boolean value
stack traceback:
        data/lib/050-function.lua:283: in function 'getTilePzInfo'
        data/actions/scripts/logout.lua:3: in function <data/actions/scripts/logout.lua:2>
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getTilePzInfo(getPlayerPosition(cid)) == FALSE then
        doRemoveCreature(cid)
    end
    return true
end
 
Solution
Code:
local pos = getPlayerPosition(cid)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getTilePzInfo(pos) == FALSE then
    doRemoveCreature(cid)
return true
end
I used this but it has this error now
Code:
[Error - Action Interface]
data/actions/scripts/logout.lua:onUse
Description:
(luaGetTileInfo) Tile not found

[Error - Action Interface]
data/actions/scripts/logout.lua:onUse
Description:
data/lib/050-function.lua:283: attempt to index a boolean value
stack traceback:
        data/lib/050-function.lua:283: in function 'getTilePzInfo'
        data/actions/scripts/logout.lua:3: in function <data/actions/scripts/logout.lua:2>
you cant throw the position variable outside of the function
cid isn't defined anywhere other than inside the function
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = getPlayerPosition(cid)
    if not getTilePzInfo(pos) then
       doRemoveCreature(cid)
    end
    return true
end
 
you cant throw the position variable outside of the function
cid isn't defined anywhere other than inside the function
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = getPlayerPosition(cid)
    if not getTilePzInfo(pos) then
       doRemoveCreature(cid)
    end
    return true
end
I have a follow up question. :p
When you use "if not -- then", does it automatically return a boolean value?
 
I have a follow up question. :p
When you use "if not -- then", does it automatically return a boolean value?
not will work for false and nil, as checking for false only wont work if something returns nil
if expects the following condition to be true, but if not will expect it to be false OR nil, that's the difference
either way that shouldnt happen it's just my personal preference and it's shorter than having to check for a value
 
Back
Top