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

Yusuf El-Shora

Herizona-Ots
Joined
Jul 19, 2015
Messages
170
Reaction score
6
Location
Lala-Land
Well I can't get this functions (Silence / Paralyze) to work .. (using tfs 0.4 / 8.6 client).
I gonna start with explanation for both (Silence / Paralyze) ..

(Silence) : It's an item (You see a fire bug.) player can you on another player for specified times, and it does silence the player for like 5 second, during the 5 second he can't use atk spells but can heal and use atk weapon, player can use it every 120 second or something.

(Paralyze) : It's an item (You see a tear of daraman.) the player can use on another player by dropping the item on him and he get paralyzed like the paralyze rune, player can use this item about 10 times.

Both Silence and Paralyze have effect saying (SILENCED-PARALYZED).

This was the explanation of the functions, now let me show you the errors :

1. when Movements is loading

PgUCnuP.png


2. when i use paralyze

WD9gbn3.png


3. when i use silence

3y9bR2F.png


And here is the Scripts for the above errors:

*grenade7.lua:
Lua:
-- Set up this line in movements.xml, with itemid matching grenade
-- <movevent type="AddItem" tileitem="0" itemid="5468" event="script" value="grenade.lua"/>
function check(cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end

function set (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end
local grenadeConfig = {
        exhaustionType = 0,        -- Type of exhaustion: 1 (same that for spells), 0 - exhaustion only for grenades
        exhaustionTime = 1,    -- Time in seconds
        exhaustionSV = 1237,    -- Storage value for exhaustion (if exhaustionType = 0 choosen)
        grenade = {                -- Grenade basic spell options
            combatArea = {{1}},
            attackType = COMBAT_PHYSICALDAMAGE,
            attackEffect = 6,
            charges = 15, -- how many times one granade can be used
        },
        disabledPositions = {     -- List of disabled positions
            {x = 100, y = 100, z = 7},
            {x = 2064, y = 835, z = 7},
            {x = 2065, y = 835, z = 7},
            {x = 2066, y = 835, z = 7},
            {x = 2067, y = 835, z = 7},
            {x = 2068, y = 835, z = 7},
            {x = 2069, y = 835, z = 7},
            {x = 2070, y = 835, z = 7}
        },
    }


local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, EXHAUST_COMBAT)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, grenadeConfig.exhaustionTime * 750)
setCombatCondition(combat, exhaustion)

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 750)
setConditionFormula(condition, -1, 40, -1, 40)
setCombatCondition(combat, condition)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, 750)
setCombatCondition(combat2, exhaustion)
local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, 750)
setCombatCondition(combat2, exhaustion)

function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    local newItem = doPlayerAddItem(cid, item.itemid)  
    doItemSetAttribute(newItem, "grenade", useCount)
    doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
end

local function sendEffect(cid)
  if not isPlayer(cid) then return end
  doSendMagicEffect(getThingPos(cid), 34)
  doSendAnimatedText(getThingPos(cid), 'Protected', COLOR_GREY)
end

local function unregister(cid)
  if not isPlayer(cid) then return end
  unregisterCreatureEvent(cid, 'ImmunitySpell')
end

function onAddItem(moveItem, tileItem, position, cid)

    local voc = getPlayerVocation(cid)
    if voc == 3 or voc == 7 or voc == 9 then
            returnPlayerItem(cid, moveItem)
        return false
    end
 
    if getTilePzInfo(position) == true or getTilePzInfo(getThingPosition(cid)) then
        returnPlayerItem(cid, moveItem)
        return false
    end
 
    local useCount = getItemAttribute(moveItem.uid, "grenade")
    if useCount == nil or useCount < 0 then
        useCount = 0
    end
  
    if grenadeConfig.exhaustionType == 0 then
        local exhaust = getPlayerStorageValue(cid, grenadeConfig.exhaustionSV)
        if  exhaust >= os.time() then
            returnPlayerItem(cid, moveItem)
            return false
        end
    elseif grenadeConfig.exhaustionType == 1 then
        if getCreatureCondition(cid, CONDITION_EXHAUST, EXHAUST_COMBAT) == true then
            returnPlayerItem(cid, moveItem)
            return false
        end
    else
        returnPlayerItem(cid, moveItem)
        return false
    end
 
    if #grenadeConfig.disabledPositions > 0 then
        for _, disabled in pairs(grenadeConfig.disabledPositions) do
            if disabled.x == position.x and disabled.y == position.y and disabled.z == position.z then
                returnPlayerItem(cid, moveItem)
                return false
            end
        end
    end
 
    local var = {pos = position, type = 2}
    local pos = variantToPosition(var)
    local pid = getTopCreature(pos).uid
    local speed = getCreatureSpeed(pid)
    if isPlayer(pid) then
        if not isPaladin(pid) then
            doCombat(cid, combat2, pos)
        end
        doSendAnimatedText(pos, "PARALYZED", TEXTCOLOR_PURPLE)
        doChangeSpeed(pid, -speed + 150)
        doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
        addEvent(function()
            if isPlayer(pid) then
                doChangeSpeed(pid, speed)
            end
        end, isKnight(pid) and 750 or 1000)
    end
 
    if not isPlayer(pid) then
        doPlayerSetStorageValue(cid,7925,getPlayerStorageValue(cid,7925) + 1)
        doPlayerSetStorageValue(cid,7927,0)
    else
        if check(cid, 9024) then
            for i = 7923,7924 do
                doPlayerSetStorageValue(cid,i,getPlayerStorageValue(cid,i) + 1)
            end
            doPlayerSetStorageValue(cid,7927,getPlayerStorageValue(cid,7927) + 1)
        else
            set(cid, 9024,7*24*60*60)
            for i = 7923,7925 do
                doPlayerSetStorageValue(cid,i,0)
            end
        end
    end
 
    if getPlayerStorageValue(cid ,7924) > getPlayerStorageValue(cid,7926) then
        doPlayerSetStorageValue(cid,7926,getPlayerStorageValue(cid,7924))
    else
        doPlayerSetStorageValue(cid,7926,getPlayerStorageValue(cid,7926))
    end
 
          

 
    if (useCount + 1) >= grenadeConfig.grenade.charges then
        doRemoveItem(moveItem.uid)
    else
        doItemSetAttribute(moveItem.uid, "grenade", (useCount + 1))
        doItemSetAttribute(moveItem.uid, "description", "You have " .. (grenadeConfig.grenade.charges - useCount - 1) .. " charges left.")
        returnPlayerItem(cid, moveItem)
    end
 
    if grenadeConfig.exhaustionType == 0 then
        setPlayerStorageValue(cid, grenadeConfig.exhaustionSV, (os.time() + grenadeConfig.exhaustionTime))
    else
        doAddCondition(cid, exhaustion)
    end

    return true
end
*silence.lua:
Lua:
local config = {
    cooldown = { storage = 3994, duration = 40 },
    duration = 6,
    ignoreCooldownGroup = 3,
    uses = 10
}

local function sendEffect(cid)
  if not isPlayer(cid) then return end
  doSendMagicEffect(getThingPos(cid), 66)
  doSendAnimatedText(getThingPos(cid), 'Silenced', COLOR_RED)
end

local function unregister(cid)
  if not isPlayer(cid) then return end
  doPlayerSetSilenced(cid, false)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local target = itemEx.uid
    if not isPlayer(target) or target == cid then
      doPlayerSendCancel(cid, "You can only use this ability on other players.")
      return true
    end

    local uses = getItemAttribute(item.uid, 'uses')
    if not uses then
      doItemSetAttribute(item.uid, 'uses', config.uses)
      uses = config.uses
    end
 
    uses = uses - 1

    if getCreatureStorage(cid, config.cooldown.storage) > os.time() and getPlayerGroupId(cid) < config.ignoreCooldownGroup then
      doPlayerTextMessage(cid,27, string.format('You can only use this ability each %d seconds.', config.cooldown.duration))
      doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
      return true
    end
  
    doCreatureSetStorage(cid, config.cooldown.storage, os.time() + config.cooldown.duration)
    doPlayerSetSilenced(target, true)
    for i = 0, config.duration - 1 do
      addEvent(sendEffect, i * 1000, target)
    end
    addEvent(unregister, config.duration * 1000, target)
 
    doItemSetAttribute(item.uid, 'uses', uses)
 
    if uses <= 0 then
      doRemoveItem(item.uid)
      doPlayerSendTextMessage(cid,27, 'You used the last charge, your item is gone.')
    else
      doPlayerSendTextMessage(cid,27, string.format('You used a charge, you have %d charges left.', uses))
    end
    return true
end

I have a Protection item (immunity.lua) also which protect the player for 10sec against atk spells, you may notice it in the grenade7.lua but it's working fine.

Also for further information I have this in action.xml which may be related to the problem:
XML:
    <!-- Trinkets silence is the one you will fix throw on ground for no need to fix because you will fix it like paralyze immunity need fix -->
    <action itemid="5468" event="script" value="silence.lua"/>
    <action itemid="5809" event="script" value="immunity.lua"/>
As you notice in actions instructions saying I need to fix para and silence, but I really have no idea how to fix any of them.

Someone told me it's a source error, some other told me it's a script error.
I really don't know what is the problem, and hoping someone can help me if it was a source error or a script error.

& Thanks in advance.
 
Last edited:
You do some math in here in the last setAttribute call, but you don't verify that it successfully retrieves the useCount item attribute. What if it fails to fetch the grenade itemAttribute from the item?

Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    local newItem = doPlayerAddItem(cid, item.itemid)   
    doItemSetAttribute(newItem, "grenade", useCount)
    doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
end

Try:
Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    if useCount != nil and useCount > 0 then
        local newItem = doPlayerAddItem(cid, item.itemid)   
        doItemSetAttribute(newItem, "grenade", useCount)
        doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
    end
end

Silence.lua:
Where have you added the doPlayerSetSilenced(cid, bool) function? It does not appear to be in a global scope. (etc data/globals.lua)
 
You do some math in here in the last setAttribute call, but you don't verify that it successfully retrieves the useCount item attribute. What if it fails to fetch the grenade itemAttribute from the item?

Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    local newItem = doPlayerAddItem(cid, item.itemid) 
    doItemSetAttribute(newItem, "grenade", useCount)
    doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
end

Try:
Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    if useCount != nil and useCount > 0 then
        local newItem = doPlayerAddItem(cid, item.itemid) 
        doItemSetAttribute(newItem, "grenade", useCount)
        doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
    end
end

Silence.lua:
Where have you added the doPlayerSetSilenced(cid, bool) function? It does not appear to be in a global scope. (etc data/globals.lua)
same error while loading ..
wanna have a look throw team viewer ? I will Appreciate that

BUMP
 
Last edited by a moderator:
same error while loading ..
wanna have a look throw team viewer ? I will Appreciate that

BUMP

1.
Do you have any line error with the first error?

3.
Nil in Lua = does not exist, aka doPlayerSetSilenced can't be found.
Missing a lib file?

You do some math in here in the last setAttribute call, but you don't verify that it successfully retrieves the useCount item attribute. What if it fails to fetch the grenade itemAttribute from the item?

Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    local newItem = doPlayerAddItem(cid, item.itemid)  
    doItemSetAttribute(newItem, "grenade", useCount)
    doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
end

Try:
Lua:
function returnPlayerItem(cid, item)
    local useCount = getItemAttribute(item.uid, "grenade")
    doRemoveItem(item.uid)
    if useCount != nil and useCount > 0 then
        local newItem = doPlayerAddItem(cid, item.itemid)  
        doItemSetAttribute(newItem, "grenade", useCount)
        doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
    end
end

Silence.lua:
Where have you added the doPlayerSetSilenced(cid, bool) function? It does not appear to be in a global scope. (etc data/globals.lua)

You can also use if not useCount ... insted of ~= ... (note =! :p)
Looks abit cleaner and prevents writing =! insted of ~=
 
1.
Do you have any line error with the first error?

3.
Nil in Lua = does not exist, aka doPlayerSetSilenced can't be found.
Missing a lib file?



You can also use if not useCount ... insted of ~= ... (note =! :p)
Looks abit cleaner and prevents writing =! insted of ~=
or if useCount then
 
1.
Do you have any line error with the first error?

3.
Nil in Lua = does not exist, aka doPlayerSetSilenced can't be found.
Missing a lib file?



You can also use if not useCount ... insted of ~= ... (note =! :p)
Looks abit cleaner and prevents writing =! insted of ~=

have this :
PgUCnuP.png


I Tried Znote solution but did not work ..
I don't know if i'm missing lib or no, where i should search?
and may you say specifically where and which lines to edit

or if useCount then
which lines to change this?
 
have this :
PgUCnuP.png


I Tried Znote solution but did not work ..
I don't know if i'm missing lib or no, where i should search?
and may you say specifically where and which lines to edit


which lines to change this?

Add this below;
Lua:
function onAddItem(moveItem, tileItem, position, cid)

Lua:
if not moveItem then
     return false
end

I gave you a notification to read the rules, this is your last warning.
Rules for the Support board
#2
 
Add this below;
Lua:
function onAddItem(moveItem, tileItem, position, cid)

Lua:
if not moveItem then
     return false
end

I gave you a notification to read the rules, this is your last warning.
Rules for the Support board
#2
I did not double post or something, It was a diffrent screen shot if you mean, and i edited and added in the thread after u asked about it, anyway thanks for notification i will read all now carefully.

You mean i add
Lua:
if not moveItem then

     return false

end
After line 78 in grenade.lua?
 
Last edited:
I did not double post or something, It was a diffrent screen shot if you mean, and i edited and added in the thread after u asked about it, anyway thanks for notification i will read all now carefully.

You mean i add
Lua:
if not moveItem then

     return false

end
After line 78 in grenade.lua?

Well you still double posted and didn't report it, it's fine if you aren't able to edit or w/e but you should in that case report your own post and ask a moderator to merge it.
And you did double post, even the logs says I merged a double post in this thread that links to your latest post.
Code:
WibbenZ    Post modified by merging posts (2456598)    19 minutes ago    View

Yes, you only have 1 onAddItem function.
 
Well you still double posted and didn't report it, it's fine if you aren't able to edit or w/e but you should in that case report your own post and ask a moderator to merge it.
And you did double post, even the logs says I merged a double post in this thread that links to your latest post.
Code:
WibbenZ    Post modified by merging posts (2456598)    19 minutes ago    View

Yes, you only have 1 onAddItem function.
all same errors bro, nothing changed
 
Yes i did

Try removing some parts of the code and see if the script runs if you remove a certain part, if it does run start re adding till you find a certain function, could be returnPlayerItem but it should throw an error related to that function in that case.

But try to comment out that function and add this insted;
Lua:
function returnPlayerItem()
     return true
end
 
Try removing some parts of the code and see if the script runs if you remove a certain part, if it does run start re adding till you find a certain function, could be returnPlayerItem but it should throw an error related to that function in that case.

But try to comment out that function and add this insted;
Lua:
function returnPlayerItem()
     return true
end
Okay i will try to do as you said, if there is something new i will post it here..
And about silence script? The nil value, how to solve this
I hoping any 0.4 scripter see this thread and be willing to help..
 
Okay i will try to do as you said, if there is something new i will post it here..
And about silence script? The nil value, how to solve this
I hoping any 0.4 scripter see this thread and be willing to help..



3.
Nil in Lua = does not exist, aka doPlayerSetSilenced can't be found.
Missing a lib file?
 
Oh sry did not notice that..

So i should search in lib folder about specific thing?

Well it could be that it hasn't been loaded in that case use dofile("data/..(path to file).lua")
But if you added that script from another server / OTLand etc you might have miseed to download / install that lib file.

And it's hard to know what the function should do, except silence the player.
 
Well it could be that it hasn't been loaded in that case use dofile("data/..(path to file).lua")
But if you added that script from another server / OTLand etc you might have miseed to download / install that lib file.

And it's hard to know what the function should do, except silence the player.
I think attempt to call global <a nil value>, means a missing function, the function as i told you prevent to cast atk spell for 5 sec when he is silenced

When i removed like 41 in silence.lua
The magic effect appeard and said silenced but the player was able to cast spell
 
Last edited:
I think attempt to call global <a nil value>, means a missing function, the function as i told you prevent to cast atk spell for 5 sec when he is silenced

When i removed like 41 in silence.lua
The magic effect appeard and said silenced but the player was able to cast spell

Not sure if TFS 1.x has any functions like that, you probbly have to do source edits or use the mute condition function.
Lua:
local mute = Condition(CONDITION_MUTED)
mute:setParameter(CONDITION_PARAM_TICKS, 5000)
 
Back
Top