• 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 Error LUA, look here!

login12

void newbie scripter()
Joined
Feb 26, 2011
Messages
164
Reaction score
24
Location
Brazil
Well i try make one script check "lookfeet" on database, and change outifit with this "lookfeet".
He dont have error on console, but him just change outifit and is not checking lookfeet.


Script here:
Code:
function onSay(cid, words, param)
local lookhead = db.getResult("SELECT `lookhead` FROM `players` WHERE `id` =" ..cid)
local addon = {lookType = 257, lookHead = lookhead:getID()}

    if isPlayer(cid) == true then       
        doCreatureChangeOutfit(cid, addon)
    return false
    end
end

Someone can help with this? I am new to LUA yet ... :confused:

.
 
1. cid is a temporary creature id, if you get result you use getPlayerGUID(cid)
2. instead of getting a result anyways, you can use getPlayerOutfit(cid), this function will return a table with every attribute of the player's outfit (lookHead, body, type, etc), you can print tables with this: http://pastebin.com/bvZ53gH6 (just put this somewhere in your lib and reload, it's syntax is print_r(table)
3. you can just put if isPlayer(cid) then since isPlayer(cid) returns a bool (true/false), every condition inside an if statement will evaluate true or false
4. you can just do this doCreatureChangeOutfit(cid, {lookType = 257}), it only changes lookType and keeps everything else the same
5. learn how to properly indent your code here: lua-users.org/wiki/LuaStyleGuide
6. use a function documentation (here's one for 0.4: http://pastebin.com/pEE2LsaA)
 
Last edited:
1. cid is a temporary creature id, if you get result you use getPlayerGUID(cid)
2. instead of getting a result anyways, you can use getPlayerOutfit(cid), this function will return a table with every attribute of the player's outfit (lookHead, body, type, etc), you can print tables with this: http://pastebin.com/bvZ53gH6 (just put this somewhere in your lib and reload, it's syntax is print_r(table)
3. you can just put if isPlayer(cid) then since isPlayer(cid) returns a bool (true/false), every condition inside an if statement will evaluate true/false/nil
4. you can just do this doCreatureChangeOutfit(cid, {lookType = 257}), it only changes lookType and keeps everything else the same
5. learn how to properly indent your code here: lua-users.org/wiki/LuaStyleGuide
6. use a function documentation (here's one for 0.4: http://pastebin.com/pEE2LsaA)

OH ! Rly rly thank! I will try that
 
Back
Top