• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved How can I send name of player to function?

okurde

New Member
Joined
Jan 28, 2009
Messages
134
Reaction score
1
Hey, I have this function:
Code:
function zero()
    if getCreatureStorage(cid, storage) > 0 then
        doCreatureSetStorage(cid, storage, 0)
    end
end

and in main function:
Code:
addEvent(zero, 10 * 1000)

but I think that I have to type name of player in addEvent(and in function zero), how can I do that?
 
I do not know.. This script should works as:
when player did something then doCreatureSetStorage(cid, storage, 1) and after 10 seconds addEvent (I think) with doCreatureSetStorage(cid, storage, 0)
 
Code:
local function what()
    setPlayerStorageValue(cid, storage, 0)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.id == ????) then
        setPlayerStorageValue(cid, storage, 1)
        addEvent(what, 10 * 1000, cid)
    end
return true
end

Like that or?
 
Code:
local function zero()
    if getPlayerStorage(cid, storage) > 0 then
        setPlayerStorageValue(cid, storage, 0)
    end
end

in main function:
Code:
addEvent(zero, 10 * 1000, cid)


and error:
Code:
[8/1/2014 21:43:9] [Error - CreatureScript Interface] 
[8/1/2014 21:43:9] In a timer event called from: 
[8/1/2014 21:43:9] data/creaturescripts/scripts/dire.lua:onDirection
[8/1/2014 21:43:9] Description: 
[8/1/2014 21:43:9] data/creaturescripts/scripts/dire.lua:12: attempt to call global 'getPlayerStorage' (a nil value)
[8/1/2014 21:43:9] stack traceback:
[8/1/2014 21:43:9]     data/creaturescripts/scripts/dire.lua:12: in function <data/creaturescripts/scripts/dire.lua:11>
:(
 
Still same error. Lines 11 and 12 are of course here:
Code:
if getPlayerStorage(cid, storage) > 0 then
        setPlayerStorageValue(cid, storage, 0)
 
It's getPlayerStorageValue.
Code:
getPlayerStorageValue(cid, storage)

If you add parameters in the function addEvent, then you also have to add them in the function.
Code:
local function zero(cid)
       if getPlayerStorageValue(cid, storage) > 0 then
             setPlayerStorageValue(cid, storage, 0)
       end
end
Code:
addEvent(zero, 10 * 1000, cid)
 
Ah thanks! Now it works :)
Could anyone tell me what's the difference between setPlayerStorageValue and doCreatureSetStorage?
 
Ah thanks! Now it works :)
Could anyone tell me what's the difference between setPlayerStorageValue and doCreatureSetStorage?
first handles only players, second handles also creatures so you can set storage to NPC to determine his behavior when player brings him something or whatever.
 
setPlayerStorageValue is the name of the function in TFS 0.2/1.0.
doCreatureSetStorage is the name of the function in TFS 0.3/0.4.
TFS 0.3/0.4 and other servers based on that like OTX have a file 100-compat.lua and this sets setPlayerStorageValue to doCreatureSetStorage.
So setPlayerStorageValue will work on every server, doCreatureSetStorage won't work on TFS 0.2/1.0 unless you add doCreatureSetStorage = setPlayerStorageValue in global.lua.
 
Back
Top