• 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 Talkactions Help

BBFalcon89

Member
Joined
Jul 1, 2010
Messages
51
Reaction score
10
Hi,

I would like to know how talkaction params work. I've been trying to look through talkaction scripts and I can't quite get how you specify the amount of params you put in and where you would then proceed to filter them into doing different things. I'm not going to request the script itself because i assume it would take a LONG time to write the quantity I want but maybe if you could show me an example script of taking 2 parameters and then if param1 = a return false or if param1 = b return true and the same for param2 maybe?

Thankyou.
 
Here is an example with the talkaction: /looktype Player_name, Monster_id

The first param is Player_name: /looktype Dude, 24
The second is the monster Id: /looktype Dude, 24

local d = string.split(param, ",")
this assigns d as the variable for the different params:
d[1] = Player_name/Dude
d[2] = Monster id/24

You can make d anything you want.

Code:
function onSay(cid, words, param)
           local player = Player(cid)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
        return false
    end

 
local d = string.split(param, ",")

if d[2] == nil then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Insufficient parameters. It should be writtin like this: /looktype Player_name, looktype_id")
        return false
    end
if d[1] == nil then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Insufficient parameters. It should be writtin like this: /looktype Player_name, looktype_id")
        return false
    end

    local lookType = tonumber(d[2])
    if lookType >= 0 and lookType ~= 1 and lookType ~= 135 and lookType ~= 411 and lookType ~= 415 and lookType ~= 424 and (lookType <= 160 or lookType >= 192) and lookType ~= 439 and lookType ~= 440 and lookType ~= 468 and lookType ~= 469 and (lookType < 474 or lookType > 485) and lookType ~= 501 and lookType ~= 518 and lookType ~= 519 and lookType ~= 520 and lookType ~= 524 and lookType ~= 525 and lookType ~= 536 and lookType ~= 543 and lookType ~= 549 and lookType ~= 576 and lookType ~= 581 and lookType ~= 582 and lookType <= 595 then
        local player = Player(d[1])
        local playerOutfit = player:getOutfit()
        playerOutfit.lookType = lookType
        player:setOutfit(playerOutfit)
    else
        player:sendCancelMessage("A look type with that id does not exist.")
    end
    return false
end
 
Back
Top