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

Simple talkaction

kalle303

New Member
Joined
Oct 13, 2007
Messages
108
Reaction score
4
Location
Sweden
Hello!

I need help with a simple talkaction ^_^

If you type "!citizen" your character will wear citizen outfit if you have StorageId: 123. ((128)Male outfit if male, and (136)female outfit if female) And text: blabla Citizen :D
Hope someone helps!
Thanks!
/Kalle303
 
Last edited:
data\talkactions\scripts\citizen.lua
Lua:
local config = {
	storagevalue = 123,
	outfit_female = {lookType = 136, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0},
	outfit_male = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, config.storagevalue) >= 1 then
                if getPlayerSex(cid) == 0 then
                        doSetCreatureOutfit(cid, config.outfit_female, -1)
                else
                        doSetCreatureOutfit(cid, config.outfit_male, -1)
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end

Add into data\talkactions\talkactions.xml;
If you're using TFS 0.2.x;
PHP:
	<talkaction words="!citizen" script="citizen.lua"/>
If you're using TFS 0.3.x;
PHP:
	<talkaction words="!citizen" event="script" value="citizen.lua"/>
 
Last edited:
I don't know why it doesen't work :S
When i type !citizen nothing happens even if the character got storage 123..

I get this error:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/citizen.lua:eek:nSay

attempt to index a nil value
stack traceback:
[C]: in function 'doSetCreatureOutfit'
data/talkactions/scripts/citizen.lua:11: in function <data/talkactions/scripts/citizen.lua:6>
 
Last edited:
Lua:
-- by Cykotitan, error fix by zonet.
local config = {
	storagevalue = 123,
	outfit_female = {lookType = 136, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0},
	outfit_male = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, storagevalue) >= 1 then
                if getPlayerSex(cid) == 0 then
                        doCreatureChangeOutfit(cid, outfit_female, -1)
                else
                        doCreatureChangeOutfit(cid, outfit_male, -1)
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end
 
Get this error:

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/citizen.lua:eek:nSay

attempt to index a number value
stack traceback:
[C]: in function 'doCreatureChangeOutfit'
data/talkactions/scripts/citizen.lua:12: in function <data/talkactions/scripts/citizen.lua:7>

BTW: I'm using TFS 0.3.4
 
It's because you're trying to access values which is contained inside of a variable which is inside of an array/table, while only using the variable name instead of directing the script to the table/array and THEN specifying the variable in said table/array.
Thus the script commands gets a "" instead of an actual number/value.

In this case its "outfit_female", "outfit_male" & "storagevalue".

Use this instead:

Lua:
-- by Cykotitan, error fix by zonet, tiny error-correction by Rexxar.
local config = {
        storagevalue = 123,
        outfit_female = {lookType = 136, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0},
        outfit_male = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, config.storagevalue) >= 1 then
                if getPlayerSex(cid) == 0 then
                        doCreatureChangeOutfit(cid, config.outfit_female, -1)
                else
                        doCreatureChangeOutfit(cid, config.outfit_male, -1)
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end
 
Dmn!
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/citizen.lua:eek:nSay

attempt to index a number value
stack traceback:
[C]: in function 'doCreatureChangeOutfit'
data/talkactions/scripts/citizen.lua:12: in function <data/talkactions/scripts/citizen.lua:7>
 
Oh esh, seems like the setOutfit function was mixed up with another function that requires more calling values.

This one should work better:

Lua:
-- by Cykotitan, error fix by zonet, tiny error-correction by Rexxar.
local config = {
        storagevalue = 123,
        outfit_female = {lookType = 136, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0},
        outfit_male = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, config.storagevalue) >= 1 then
                if getPlayerSex(cid) == 0 then
                        doCreatureChangeOutfit(cid, config.outfit_female)
                else
                        doCreatureChangeOutfit(cid, config.outfit_male)
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end
 
Thanks everyone!

But can you please help me with one more thing? ^_^

If the player is wearing "hunter outfit" with some random colors, and writes "!citizen" that player will wear citizen outfit with the previous colors. And not all white...

Thanks again! :D:D:D
 
Last edited:
Yeah, sorry for that..
I scripted that pretty late last night, so I didn't pay attention to such bugs (I didn't use array config in the first place)

New script:
Lua:
local config = {
	storagevalue = 123
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, config.storagevalue) >= 0 then
		local lookHead_old = getCreatureOutfit(cid).lookHead
		local lookBody_old = getCreatureOutfit(cid).lookBody
		local lookLegs_old = getCreatureOutfit(cid).lookLegs
		local lookFeet_old = getCreatureOutfit(cid).lookfeet
                if getPlayerSex(cid) == 0 then
                        doCreatureChangeOutfit(cid, {lookType = 136, lookHead = lookHead_old, lookBody = lookBody_old, lookLegs = lookLegs_old, lookFeet = lookFeet_old, lookTypeEx = 0, lookAddons = 0})
                else
                        doCreatureChangeOutfit(cid, {lookType = 128, lookHead = lookHead_old, lookBody = lookBody_old, lookLegs = lookLegs_old, lookFeet = lookFeet_old, lookTypeEx = 0, lookAddons = 0})
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end
 
Last edited:
This should work:

Lua:
  local config = {
        storagevalue = 123
}
function onSay(cid, words, param)
        if getPlayerStorageValue(cid, config.storagevalue) >= 1 then
                local lookHead_old = getCreatureOutfit(cid).lookHead
                local lookBody_old = getCreatureOutfit(cid).lookBody
                local lookLegs_old = getCreatureOutfit(cid).lookLegs
                local lookFeet_old = getCreatureOutfit(cid).lookfeet
                if getPlayerSex(cid) == 0 then
                        doCreatureChangeOutfit(cid, {lookType = 136, lookHead = lookHead_old, lookBody = lookBody_old, lookLegs = lookLegs_old, lookFeet = lookFeet_old, lookTypeEx = 0, lookAddons = 0})
                else
                        doCreatureChangeOutfit(cid, {lookType = 128, lookHead = lookHead_old, lookBody = lookBody_old, lookLegs = lookLegs_old, lookFeet = lookFeet_old, lookTypeEx = 0, lookAddons = 0})
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now wearing a citizen outfit.")
        end
        return TRUE
end
 
Back
Top