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

Lua (TFS 0.4) How to make player not able to cast spells?

marek12

Available for sprite works
Joined
Apr 8, 2020
Messages
398
Solutions
4
Reaction score
394
Anyone knows how to make player not able to use spells? It may be done with storage value or whatever
Is there a function for that?
 
Solution
looking more to make unable to cast just for the period of event is running OR for like 10 seconds. (maybe may be done with adding exhaust for all spells?)
and by event I mean the repeatable action, not like zombie event :D
So the easy way is to mute the player.. But then the player experience is lowered, since they literally cannot talk at all, in pm's / to npc's / et cetera

I'd recommend instead to create a function inside all of your spells to disable them.

so in data/lib/050-function.lua add this function
Lua:
-- if this returns true, then the player is exhausted
function spellExhausted(cid)
    if not isPlayer(cid) then
        return false
    end
    if getCreatureStorage(cid, 45001) == 1 then
        return true...
If the player doesn't own a spell, they can't cast it.

spells.xml
Lua:
needlearn="1"
Then use the below commands in order to add/remove their use to a player.
Lua:
doPlayerLearnInstantSpell(cid, name)
doPlayerUnlearnInstantSpell(cid, name)

Or, if it's for a gm/cm/god you could edit the player flags
PlayerFlag_CannotUseSpells

You'd have to go into const.h in order to find the value of that flag in your server though.
 
If the player doesn't own a spell, they can't cast it.

spells.xml
Lua:
needlearn="1"

Lua:
doPlayerLearnInstantSpell(cid, name)
doPlayerUnlearnInstantSpell(cid, name)

Or, if it's for a gm/cm/god you could edit the player flags
PlayerFlag_CannotUseSpells

You'd have to go into const.h in order to find the value of that flag in your server though.
looking more to make unable to cast just for the period of event is running OR for like 10 seconds. (maybe may be done with adding exhaust for all spells?)
and by event I mean the repeatable action, not like zombie event :D
 
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 3000)

function....
return doAddCondition(target, muted)
end
 
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 3000)

function....
return doAddCondition(target, muted)
end
I guess it will mute completely the person.
Looking to just make unable to cast spells. ^^
 
I guess it will mute completely the person.
Looking to just make unable to cast spells. ^^
if you dont want to edit sources or edit every spell's lua this is the only way


edit
below Xikini shown you what to do if you decide to go with editing spells
 
Last edited:
looking more to make unable to cast just for the period of event is running OR for like 10 seconds. (maybe may be done with adding exhaust for all spells?)
and by event I mean the repeatable action, not like zombie event :D
So the easy way is to mute the player.. But then the player experience is lowered, since they literally cannot talk at all, in pm's / to npc's / et cetera

I'd recommend instead to create a function inside all of your spells to disable them.

so in data/lib/050-function.lua add this function
Lua:
-- if this returns true, then the player is exhausted
function spellExhausted(cid)
    if not isPlayer(cid) then
        return false
    end
    if getCreatureStorage(cid, 45001) == 1 then
        return true
    end
    return false
end
and then under the function onCastSpell(cid, var) put this
Lua:
if spellExhausted(cid) then
    -- can add some text here if you want, telling the player they are spell exhausted.
    return false
end
 
Solution
So the easy way is to mute the player.. But then the player experience is lowered, since they literally cannot talk at all, in pm's / to npc's / et cetera

I'd recommend instead to create a function inside all of your spells to disable them.

so in data/lib/050-function.lua add this function
Lua:
-- if this returns true, then the player is exhausted
function spellExhausted(cid)
    if not isPlayer(cid) then
        return false
    end
    if getCreatureStorage(cid, 45001) == 1 then
        return true
    end
    return false
end
and then under the function onCastSpell(cid, var) put this
Lua:
if spellExhausted(cid) then
    -- can add some text here if you want, telling the player they are spell exhausted.
    return false
end
whew, that looks promising. Will give it a go, thanks! =D
 
I like Xikini
He still supports older tfs version users while other users telling us to use 1.2 or 1.3
thanks for your help xikini
yeah and as one person saying it's impossible, he's making the way to overcome it and make it possible.
This is what I am trying to do as well, so I really like him :D
Post automatically merged:

So the easy way is to mute the player.. But then the player experience is lowered, since they literally cannot talk at all, in pm's / to npc's / et cetera

I'd recommend instead to create a function inside all of your spells to disable them.

so in data/lib/050-function.lua add this function
Lua:
-- if this returns true, then the player is exhausted
function spellExhausted(cid)
    if not isPlayer(cid) then
        return false
    end
    if getCreatureStorage(cid, 45001) == 1 then
        return true
    end
    return false
end
and then under the function onCastSpell(cid, var) put this
Lua:
if spellExhausted(cid) then
    -- can add some text here if you want, telling the player they are spell exhausted.
    return false
end
I knew it's going to work.
Thanks dude ! :D
 
Last edited:
Back
Top