• 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 Hmm Talkaction ?

Erikas Kontenis

Excellent OT User
Joined
Jul 3, 2009
Messages
1,935
Reaction score
680
Location
Lithuania
Is Possible Make That? Like In Your Bp (Container) You Got A Example: "Chrismas Token" And Then You Say: !Buyarmor, Ur Chrismas Token Gone But In Your Backpack Are A Donater Armor Example "leather Armor" Or With Same "Chismas Token" Say: !buyaddons And You Will Get All Addons. Can Someone Can Help Me How To Make IT?

I'm In Use Tfs 0.2.2

/Apsivaflines
 
Yes, it is possible.
I won't give you the ready-to-use script. Here are some hints:

1. Create a local array and use the keys as the itemid. Since you can have outfits as awards, use keys as the type and a sub-array of values as the male and female outfits.

2. Check using for ... ipairs(..) do for the keys, if they are items or not.

3. If they are, use the functions to give the item. If they aren't, iterate on those values of the respectives keys that are not items, those must be outfit types. So, use the function on that iterator to give the outfit.

4. Remember to remove the amount of "Chismas Token" using in each table a key-name value named "price" for example.

5. So I ask you: it is possible to YOU making that?
 
Not Tested But :D Ehm Is That Good ? And How Should I Make With Addons?

<talkaction words="!buyarmor" script="gaminys.lua"/>

LUA:
function onSay(cid, itemEx, words, param)
	if item.itemid == 6527 then
		if doRemoveItem(item.uid, 1) == TRUE then
			doPlayerAdditem(item.uid, 2160)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought Crystal Coin.")
		else
			doPlayerSendCancel(cid, "You don't have Lithuania Coin.")
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		end
	else
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end
 
Ok, That A Error

Code:
[13/10/2009 20:33:56] data/talkactions/scripts/gaminys.lua:2: attempt to index global 'item' (a nil value)
[13/10/2009 20:33:56] stack traceback:
[13/10/2009 20:33:56] 	data/talkactions/scripts/gaminys.lua:2: in function <data/talkactions/scripts/gaminys.lua:1>

But The Error Is Then I Said !buyarmor
 
Take this code piece:
Code:
local items = {
	["donator item"] = 2121,
	["donator item2]" = 2122
}

local now = items[param]
if (not now) then
	doPlayerSendCancel(cid, "Item not found in offer.")
	return true
end

if (getPlayerItemCount(cid, token id) >= 1) then
	doPlayerAddItem(cid, now, 1)
	doPlayerRemoveItem(cid, token id, 1)
else
	doPlayerSendCancel(cid, "you havent token")
end
 
Code:
Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/gaminys.lua
[13/10/2009 20:39:03] data/talkactions/scripts/gaminys.lua:3: ']' expected near '='
 
Just mistaken in table should be:
Code:
local items = {
	["donator item"] = 2121,
	["donator item2"] = 2122
}

Also you have to add talkaction header ;p
 
Code:
 Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/gaminys.lua
[13/10/2009 20:46:46] data/talkactions/scripts/gaminys.lua:12: ')' expected near 'id'


how to add talkaction headeR?
 
Hahaha man, you have to replace token id with token's id -,-. Header is function onSay(cid, words, param, channel). ;p
 
LUA:
local items = {
	["donator item"] = 6527,
	["donator item2"] = 9777
}

local now = items[param]
if (not now) then
	doPlayerSendCancel(cid, "Item not found in offer.")
	return true
end

if (getPlayerItemCount(cid, token id, 1)then
	doPlayerAddItem(cid, now, 1)
	doPlayerRemoveItem(cid, token id, 1)
else
	doPlayerSendCancel(cid, "you havent token")
end

Code:
 Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/gaminys.lua
[13/10/2009 21:29:42] data/talkactions/scripts/gaminys.lua:12: ')' expected near 'id'

Im Realy Uber Noober :D Need Learn Script :D
 
Back
Top