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

[REQUEST] Talkaction script

Yaze

Well-Known Member
Joined
Sep 15, 2014
Messages
382
Reaction score
61
Hello dear otlanders, i have a question,


can someone script for me a script like this

A admin should be able to write a talkaction and all players in the screen will get + random levels,
like

/addlevel 300

everyone in my screen gets + MAX 300 levels, means
someone get 20 levels, someone gets 210 levels, someone gets 90 levels.. etc

Thanks who ever will help :p

Kind regards,
 
Don´t know if this works on tfs 0.3.6 but it works on tfs 0.4
Code:
function onSay(cid, words, param, channel)
    t = string.explode(param, ",", 2)
    pid = getPlayerByName(t[1])
    level = tonumber(t[2])
    doPlayerAddLevel(pid, level)
    return true
end
 
In talcation.xml
Code:
talkaction words="/addlevel" access="5" case-sensitive="no" event="script" value="addlevel.lua"/>
 
He wants to get all the players that are visible on his screen (15x11 area), then for each player, he wants to add a random number of levels between 0 and 300. I can do this in 1.X, but I don't know what's available in 0.3. I haven't touched 0.3 in years, so I don't know what functions are readily available. Is there something similar to getSpectators()?
 
Code:
    local rangeX, rangeY = 7, 7
    local spectators = getSpectators(getCreaturePosition(cid), rangeX, rangeY, false)
    if spectators then
        for _, spectator in ipairs(spectators) do
            if isPlayer(spectator) and spectator ~= cid then
                doPlayerAddLevel(spectator, math.random(0, 300), true)
            end
        end
    end
 
If i understood him correctly he wants to add a total of 300 levels to all players around him, like 30 to one then there's 270 levels left to add.
No idea if this works just edited Ninjas script
Code:
local rangeX, rangeY = 7, 7
local spectators = getSpectators(getCreaturePosition(cid), rangeX, rangeY, false)
local levelAmount = param
local addlevel = 0
if spectators then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) and spectator ~= cid then
addlevel = math.random(0,levelAmount)
doPlayerAddLevel(spectator, addlevel, true)
levelAmount = levelAmount-addlevel
end
end
end
 
Got this error with ninjas script,

@up

Sorry for my bad english , but its like
20 players are in my screen, and all are level 20.
If i type /addlevel , then all 20 players in my screen should get levels random, like , random levels.

/addskill name1,lvl,300
/addskill name2,lvl,212
/addskill name3,lvl,81


[Error - TalkAction Interface]
data/talkactions/scripts/addlevel.lua
Description:
(luaGetThingPosition) Thing not found
[Warning - Event::loadScript] Event onSay not found (data/talkactions/scripts/addlevel.lua)
 
Got this error with ninjas script,

@up

Sorry for my bad english , but its like
20 players are in my screen, and all are level 20.
If i type /addlevel , then all 20 players in my screen should get levels random, like , random levels.

/addskill name1,lvl,300
/addskill name2,lvl,212
/addskill name3,lvl,81


[Error - TalkAction Interface]
data/talkactions/scripts/addlevel.lua
Description:
(luaGetThingPosition) Thing not found
[Warning - Event::loadScript] Event onSay not found (data/talkactions/scripts/addlevel.lua)
You still have to add the main function for talkactions scripts.
Code:
function onSay(cid, words, param)
Also functions have to close with end, so add that at the bottom of the script.
 
[Error - LuaScriptInterface::loadFile] data/talkactions/scripts/addlevel.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>'
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/addlevel.lua)
data/talkactions/scripts/addlevel.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>'


the script:
Code:
function onSay(cid, words, param)
local rangeX, rangeY = 7, 7
local spectators = getSpectators(getCreaturePosition(cid), rangeX, rangeY, false)
local levelAmount = param
local addlevel = 0
if spectators then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) and spectator ~= cid then
addlevel = math.random(0,levelAmount)
doPlayerAddLevel(spectator, addlevel, true)
levelAmount = levelAmount-addlevel
end
end
end
 
Iam sorry Limos, i dont really understand much..
This is my script now, i dont get errors when i reload talkactions anymore but when i use /addlevel
Code:
function onSay(cid, words, param)

local rangeX, rangeY = 7, 7
local spectators = getSpectators(getCreaturePosition(cid), rangeX, rangeY, false)
local levelAmount = param
local addlevel = 0
if spectators then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) and spectator ~= cid then
addlevel = math.random(0,levelAmount)
doPlayerAddLevel(spectator, addlevel, true)
levelAmount = levelAmount-addlevel
end
end
end
end

[Error - TalkAction Interface]
data/talkactions/scripts/addlevel.lua:eek:nSay
Description:
data/talkactions/scripts/addlevel.lua:10: bad argument #2 to 'random' (number expected, got string)
stack traceback:
[C]: in function 'random'
data/talkactions/scripts/addlevel.lua:10: in function <data/talkactions/scripts/addlevel.lua:1>
 
now i got this error

[Error - TalkAction Interface]
data/talkactions/scripts/addlevel.lua:eek:nSay
Description:
data/talkactions/scripts/addlevel.lua:10: bad argument #2 to 'random' (number expected, got nil)
stack traceback:
[C]: in function 'random'
data/talkactions/scripts/addlevel.lua:10: in function <data/talkactions/scripts/addlevel.lua:1>
 
Back
Top