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

[talkactions] need command

Chiracle

New Member
Joined
Jun 3, 2010
Messages
23
Reaction score
0
Hello,
I need command to give for all players one item. For example: i said /additem crystal coin 1(or id), and all players will receive 1 cc.

thanks,
chiracle
 
Ok , this works with id or name of item , the default amount is 1 unless you wrote the amount.maybe you will find a typing mistakes (from mobile :( )
Code:
<talkaction words="/add" hide="yes" event="script" value="aloot.lua"/>

make new aloot.lua then
Lua:
function onSay(cid, words, param)
if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end

	local t = string.explode(param, ",")
	
local id = tonumber(t[1])
	if(not id) then
		id = getItemIdByName(t[1], false)
		if(not id) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
			return true
		end
	end

	local amount = 1
	if(t[2]) then
		amount = t[2]
	end
	
	doPlayerSendTextMessage(cid, 25, "All players have recieved "..amount.." "..getItemNameById(id)..".")
 for _, cid in ipairs(getPlayersOnline()) do
   doPlayerAddItem(cid,id,amount)
     doPlayerSendTextMessage(cid, 25, "You have recived "..amount.." "..getItemNameById(id)..".")
 end
 return true
 end
 
Back
Top