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

Lua TFS 0.4 | talkactions

Hernest

New Member
Joined
Jul 26, 2010
Messages
152
Reaction score
3
Location
poland
Hello, i want to create command like, hmm "!arena x" when x is monster name, for example !arena Demon, and after it it will by change variable.

Example:
before
Code:
local monster =
!arena Demon

after
Code:
local monster = Demon

code;
Code:
function onSay(cid, words, param)   
    local monster =
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
    setPlayerStorageValue(cid, 1526347, 1)
   
    ....
end

I don't have any idea how to change that variable via command.
 
Code:
    if monsterarena == pandora then
        monsterarena = husky
        doCreatureSay(cid, "Pandora is not allowed", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    end

Why it's didn not work? ^^

Code:
function onSay(cid, words, param)   
    monsterarena = param
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
    if monsterarena == pandora then
        monsterarena = husky
        doCreatureSay(cid, "Pandora is not allowed", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    end
end

Just magic effect after !arena pandora
 
Code:
function onSay(cid, words, param)  
    monsterarena = param
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
    if monsterarena == "pandora" then
        monsterarena = husky
        local aret = monsterarena
        doCreatureSay(cid, "Pandora is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    end
    doCreatureSay(cid, "You choose:" .. aret .. " monsters.", TALKTYPE_ORANGE_1)

       
end

Code:
2/07/2014 23:31:57] data/talkactions/scripts/arena.lua:onSay
[12/07/2014 23:31:57] Description:
[12/07/2014 23:31:57] data/talkactions/scripts/arena.lua:11: attempt to concatenate global 'aret' (a nil value)
[12/07/2014 23:31:57] stack traceback:
[12/07/2014 23:31:57]     data/talkactions/scripts/arena.lua:11: in function <data/talkactions/scripts/arena.lua:1>
 
How to add this:
Code:
function onSay(cid, words, param)
    monsterarena = param
    local aret = monsterarena
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
    if monsterarena == "pandora" then
        local aret = "husky"
        doCreatureSay(cid, "Pandora is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    elseif monsterarena == "ice demon" then
        local aret = "husky"
        doCreatureSay(cid, "Ice Demon is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    elseif monsterarena == "ice guard" then
      local aret = "husky"
        doCreatureSay(cid, "Ice Guard is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    elseif monsterarena == "black hero" then
        local aret = "husky"
        doCreatureSay(cid, "Black Hero is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    elseif monsterarena == "gorlic" then
        local aret = "husky"
        doCreatureSay(cid, "Gorlic is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    elseif monsterarena == "grim" then
        monsterarena = "husky"
        doCreatureSay(cid, "Grim is not allowed!", TALKTYPE_ORANGE_1)
        doCreatureSay(cid, "Changed to husky!", TALKTYPE_ORANGE_1)
        print(monsterarena)
    else
        doCreatureSay(cid, "You choose: " .. aret .. ".", TALKTYPE_ORANGE_1)
    end
       
end

To that mod:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="HuntArea System" version="Tested only on 0.4" author="Hugq" contact="[email protected]" enabled="yes">
<config name="HuntAreaFunctions"><![CDATA[
config = {
    -- Teleport AID = v[1], v[2], v[3], v[4], v[5], v[6], v[7] ;]
    [10001] = {{x = 2406, y = 987, z = 7}, {x = 2406, y = 984, z = 7}, {x = 2400, y = 984, z = 6}, 15, 800, 4, 4},
    [10002] = {{x = 1165, y = 1034, z = 7}, {x = 1166, y = 1030, z = 7}, {x = 1160, y = 1031, z = 6}, 15, 800, 4, 4},
    [10003] = {{x = 2406, y = 1025, z = 7}, {x = 2406, y = 1022, z = 7}, {x = 2400, y = 1022, z = 6}, 15, 800, 4, 4},
    [10004] = {{x = 2426, y = 1006, z = 7}, {x = 2426, y = 1003, z = 7}, {x = 2420, y = 1003, z = 6}, 15, 800, 4, 4}

}
monsters1 = {
    -- Tile AID = b[1], b[2] ;]
    [10201] = {"test", {x = 2406, y = 987, z = 7}},
    [10202] = {"Crosspatch", {x = 1165, y = 1032, z = 7}},
    [10203] = {"Crosspatch", {x = 2406, y = 1025, z = 7}},
    [10204] = {"Crosspatch", {x = 2426, y = 1006, z = 7}}

}

function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
                if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end
    local creature = getTopCreature(position)
    if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
        if not(table.find(creaturesList, creature.uid)) then
            table.insert(creaturesList, creature.uid)
        end
    end
        return creaturesList
end
]]></config>
<movevent type="StepIn" actionid="10001-10004" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
local v = config[item.actionid]
function kickEvent(cid, item, position, fromPosition)
    if (getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE) ~= 0 and getCreatureStorage(cid, 654321) > 0) then
            doTeleportThing(cid, v[3])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        doCreatureSay(cid, "You have been kicked out from hunting room.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
    end
end
    if getPlayerLevel(cid) >= v[5] then
        if(getPlayerItemCount(cid, 11230) > 0) then
        local players = getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE)
            if #players == 0 then
            local creatures = getCreaturesInRange(v[2], v[6], v[7], TRUE, FALSE)
                for i = 1, #creatures do
                    doRemoveCreature(creatures[i])
                end
                doSendMagicEffect(position, CONST_ME_TELEPORT)
                doTeleportThing(cid, v[1])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doPlayerRemoveItem(cid, 11230, 1)
                doCreatureSay(cid, "Now you have " .. v[4] .. " minutes for hunting monsters, else you will be kicked out.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
                pauseKick = addEvent(kickEvent, v[4] * 60 * 1000, cid)
                doCreatureSetStorage(cid, 654321, 1)
                return TRUE
            else
                doCreatureSay(cid, "There is someone else in the room.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
            end
        else
            doCreatureSay(cid, "You don't have enough ivory bones.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
        end
        else
            doCreatureSay(cid, "You must be at least level " .. v[5] .. " or higher to enter.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
    end
    doTeleportThing(cid, fromPosition)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    return TRUE
end
]]></movevent>
<movevent type="StepIn" actionid="10101-10104" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        stopEvent(pauseKick)
    end
end]]></movevent>
<movevent type="StepIn" actionid="10201-10204" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    local b = monsters[item.actionid]
    if(isPlayer(cid) and exhaustion.check(cid, item.actionid)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You should wait " .. exhaustion.get(cid, item.actionid) .. " seconds.")
    elseif (isPlayer(cid)) then
        exhaustion.set(cid, item.actionid, 0)
            doSummonCreature(b[1], b[2])
        doSendMagicEffect(b[2], CONST_ME_TELEPORT)
    end
end]]></movevent>
</mod>
 
Do it the same way as the movement, but then instead of the movevent line, one for talkactions (<talkaction words=".. etc) and end with
Code:
]]></talkaction>
Instead of ]]></movevent>
 
Back
Top