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

Linux Addon Doll , talkaction

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hello!

I dont know why my script arent working. When you try to use the command to get the addon, like: !addon norseman or !addon norsewoman / !addon nobleman or !addon noblewoman.

All others addons when you use the command !addon assassin !addon mage etc.

Sorry if someone dont understand something. I really dunno how explain that.

Script:
PHP:
function onSay(cid, words, param) 
local femaleOutfits = { ["citizen"]={136}, ["hunter"]={137}, ["mage"]={138}, ["knight"]={139}, ["noblewoman"]={140}, ["summoner"]={141}, ["warrior"]={142}, ["barbarian"]={147}, ["druid"]={148}, ["wizard"]={149}, ["oriental"]={150}, ["pirate"]={155}, ["assassin"]={156}, ["beggar"]={157}, ["shaman"]={158}, ["norsewoman"]={252}, ["nightmare"]={269}, ["jester"]={270}, ["brotherhood"]={279}, ["demonhunter"]={288}, ["yalaharian"]={324}, ["warmaster"]={336} } 
local maleOutfits = { ["citizen"]={128}, ["hunter"]={129}, ["mage"]={130}, ["knight"]={131}, ["nobleman"]={132},["summoner"]={133}, ["warrior"]={134}, ["barbarian"]={143}, ["druid"]={144}, ["wizard"]={145}, ["oriental"]={146}, ["pirate"]={151}, ["assassin"]={152}, ["beggar"]={153}, ["shaman"]={154}, ["norsewoman"]={251}, ["nightmare"]={268}, ["jester"]={273}, ["brotherhood"]={278}, ["demonhunter"]={289}, ["yalaharian"]={325}, ["warmaster"]={335} } 
local msg = {"Você precisa dizer: !addon e o nome do outfit que deseja. Ex.: !addon mage", "Você não tem um addon doll. Compre o seu no NPC Merchant.", "Bad param!", "Full outfit adicionado!"} 
local param = string.lower(param) 

if(getPlayerItemCount(cid, 9693) > 0) then 
if(param ~= "" and maleOutfits[param] and femaleOutfits[param]) then 
doPlayerRemoveItem(cid, 9693, 1) 
doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[4]) 
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS) 
if(getPlayerSex(cid) == 0)then 
doPlayerAddOutfit(cid, femaleOutfits[param][1], 3) 
else 
doPlayerAddOutfit(cid, maleOutfits[param][1], 3) 
end 
else 
doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[1]) 
end 
else 
doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[2]) 
end 
end

tks
 
Ok starting off with:
Code:
local femaleOutfits = { ["citizen"]={136}, ["hunter"]={137}, ["mage"]={138}, ["knight"]={139}, ["noblewoman"]={140}, ["summoner"]={141}, ["warrior"]={142}, ["barbarian"]={147}, ["druid"]={148}, ["wizard"]={149}, ["oriental"]={150}, ["pirate"]={155}, ["assassin"]={156}, ["beggar"]={157}, ["shaman"]={158}, ["norsewoman"]={252}, ["nightmare"]={269}, ["jester"]={270}, ["brotherhood"]={279}, ["demonhunter"]={288}, ["yalaharian"]={324}, ["warmaster"]={336} } 
    local maleOutfits = { ["citizen"]={128}, ["hunter"]={129}, ["mage"]={130}, ["knight"]={131}, ["nobleman"]={132},["summoner"]={133}, ["warrior"]={134}, ["barbarian"]={143}, ["druid"]={144}, ["wizard"]={145}, ["oriental"]={146}, ["pirate"]={151}, ["assassin"]={152}, ["beggar"]={153}, ["shaman"]={154}, ["norsewoman"]={251}, ["nightmare"]={268}, ["jester"]={273}, ["brotherhood"]={278}, ["demonhunter"]={289}, ["yalaharian"]={325}, ["warmaster"]={335} } 
    local msg = {"Você precisa dizer: !addon e o nome do outfit que deseja. Ex.: !addon mage", "Você não tem um addon doll. Compre o seu no NPC Merchant.", "Bad param!", "Full outfit adicionado!"}
Should be outside of function onSay becuase they never change so its wasteful to have them inside of the script.
Like this:
Code:
local femaleOutfits = { ["citizen"]={136}, ["hunter"]={137}, ["mage"]={138}, ["knight"]={139}, ["noblewoman"]={140}, ["summoner"]={141}, ["warrior"]={142}, ["barbarian"]={147}, ["druid"]={148}, ["wizard"]={149}, ["oriental"]={150}, ["pirate"]={155}, ["assassin"]={156}, ["beggar"]={157}, ["shaman"]={158}, ["norsewoman"]={252}, ["nightmare"]={269}, ["jester"]={270}, ["brotherhood"]={279}, ["demonhunter"]={288}, ["yalaharian"]={324}, ["warmaster"]={336} } 
local maleOutfits = { ["citizen"]={128}, ["hunter"]={129}, ["mage"]={130}, ["knight"]={131}, ["nobleman"]={132},["summoner"]={133}, ["warrior"]={134}, ["barbarian"]={143}, ["druid"]={144}, ["wizard"]={145}, ["oriental"]={146}, ["pirate"]={151}, ["assassin"]={152}, ["beggar"]={153}, ["shaman"]={154}, ["norsewoman"]={251}, ["nightmare"]={268}, ["jester"]={273}, ["brotherhood"]={278}, ["demonhunter"]={289}, ["yalaharian"]={325}, ["warmaster"]={335} } 
local msg = {"Você precisa dizer: !addon e o nome do outfit que deseja. Ex.: !addon mage", "Você não tem um addon doll. Compre o seu no NPC Merchant.", "Bad param!", "Full outfit adicionado!"} 

function onSay(cid, words, param)
    local param = string.lower(param)

Next:
Code:
["citizen"]={136}
136 does not need to be inside a table/array because it is the only value. Does it hurt? No. But wait! It could be useful to make this script much easier to read. Rather than have femaleOutfits AND maleOutfits why not just combine both?
Like this:
Code:
["citizen"]={[0]=136,[1]=128}
Now you might be asking, why [0] and [1].
The answer is simple, now we can do this:
Code:
outfits[param][getPlayerSex(cid)]

Now, when testing this script I noticed I could accidentally buy the same addon twice. This can be avoided by adding something such as:
Code:
    if(canPlayerWearOutfit(cid, outfit, 3)) then
        doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[5]) 
        return true
    end

The second most important thing you missed in your script is
Code:
return true
At the bottom of your talkaction. This means any time a player types the command it is going to do this:
RZNOIev.png

And we don't want that, because it's ugly!

And last but not least, actually THE MOST IMPORTANT thing you missed in your script, TABBING. So here is the final product complete with all the changes I talked about in this post, and of course... it is tabbed so people can read it:
Code:
local outfits = {
    ["citizen"]={[0]=136,[1]=128}, ["hunter"]={[0]=137,[1]=129}, ["mage"]={[0]=138,[1]=130}, ["knight"]={[0]=139,[1]=131}, ["noblewoman"]={[0]=140,[1]=132}, ["nobleman"]={[0]=140,[1]=132}, ["summoner"]={[0]=141,[1]=133},
    ["warrior"]={[0]=142,[1]=134}, ["barbarian"]={[0]=147,[1]=143}, ["druid"]={[0]=148,[1]=144}, ["wizard"]={[0]=149,[1]=145}, ["oriental"]={[0]=150,[1]=146}, ["pirate"]={[0]=155,[1]=151},
    ["assassin"]={[0]=156,[1]=152}, ["beggar"]={[0]=157,[1]=153}, ["shaman"]={[0]=158,[1]=154}, ["norsewoman"]={[0]=252, [1]=251}, ["norseman"]={[0]=252,[1]=251}, ["nightmare"]={[0]=269,[1]=268}, ["jester"]={[0]=270,[1]=273},
    ["brotherhood"]={[0]=279,[1]=278}, ["demonhunter"]={[0]=288,[1]=289}, ["yalaharian"]={[0]=324,[1]=325}, ["warmaster"]={[0]=336,[1]=335}
}

local msg = {
    "Você precisa dizer: !addon e o nome do outfit que deseja. Ex.: !addon mage",
    "Você não tem um addon doll. Compre o seu no NPC Merchant.",
    "Full outfit adicionado!",
    "You already own this outfit!"
} 

function onSay(cid, words, param)
    local outfit = outfits[string.lower(param)]
    if(not outfit) then -- check if param exists in table
        doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[1]) -- I used your msg[3] for "bad param" but if you want to be more specific for players, just change it to say "outfit does not exist"
        return true
    end
   
    outfit = outfit[getPlayerSex(cid)] -- re-define outfit variable with the players sex included (makes life easier later on)
    if(canPlayerWearOutfit(cid, outfit, 3)) then -- check if player can wear the outfit
        doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[4]) -- added this msg for you so players know they already own that addon
        return true
    end
   
    if(doPlayerRemoveItem(cid, 9693, 1)) then -- check to make sure addon doll was removed from player inventory
        doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[3])
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
        doPlayerAddOutfit(cid, outfit, 3)
    else
        doPlayerSendTextMessage(cid,  MESSAGE_STATUS_WARNING, msg[2]) 
    end
    return true
end

Now to answer your original question...
The reason norseman did not work before was because you had it set to norsewoman in the table.
Not sure why your nobleman/woman didn't work before but it should now :)
 
Back
Top