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

ZelOT

New Member
Joined
Sep 13, 2010
Messages
85
Reaction score
1
Location
Sweden
Hello!

I was wondering if someone could help me script this talkaction command!

It should work like this; If a player say a special word, a special item he have should disappear and he will get another item.

Did I explain it good enough?

Thanks in advance.
 
data/talkactions/scripts/exchange.lua
LUA:
local cfg = {
special item = xxxx, ----- ID OF "Special item" you must have
item = xxxx ----- Item you get
}
function onSay(cid, words, param)
if getPlayerItemCount(cid,cfg.specialitem) > 0 then
   doPlayerRemoveItem(cid,cfg.specialitem,1)
   doPlayerAddItem(cid,cfg.item,1)
else
    doPlayerSendCancel(cid, "You need to have " .. getItemNameById(cfg.specialitem) .. " to do an exchange")
end
return true
end

data/talkactions/talkactions.xml
XML:
<talkaction words="!exchange" event="script" value="exchange.lua"/>[/XMl]

Down: Fixed lol.
 
Last edited:
one mistake use this one:

LUA:
local cfg = {
special item = xxxx, ----- ID OF "Special item" you must have
item = xxxx ----- Item you get
}
function onSay(cid, words, param)
if getPlayerItemCount(cid,cfg.specialitem) > 0 then
   doPlayerRemoveItem(cid,cfg.specialitem,1)
   doPlayerAddItem(cid,cfg.item,1)
else
    doPlayerSendCancel(cid, "You need to have " .. getItemNameById(cfg.specialitem) .. " to do an exchange")
end
return true
end
 
Try
XML:
<talkaction words="!exchange" script="exchange.lua"/>
LUA:
local ID_TO_REMOVE = X
local NEW_ID = X

function onSay(cid, words, param)
	if doPlayerRemoveItem(cid, ID_TO_REMOVE, 1) == TRUE then
		doPlayerAddItem(cid, NEW_ID, 1)
	else
		doPlayerSendCancel(cid, "You need to have a " .. getItemName(ID_TO_REMOVE) .. " to do an exchange.")
	end
	return TRUE
end
 
Last edited:
Ok it works, love!

Edit: Is it possible to do so other people don't see when this command is being typed?
 
Last edited:
Back
Top