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

Solved Problem with script

Panduh

Panduh Approves.
Joined
Jun 9, 2013
Messages
111
Reaction score
1
Location
Panda Land ofc
It says it for every player that is online. I say it once and it lag's server and spams Server Log.

AmNVGc0.png


Script.
Code:
function onSay(cid, words, param, channel) -- Script by Dubler, written for megaevo.net
local t = string.explode(param, ",")
if t[1] ~= nil and t[2] ~= nil then
local list = {}
for i, tid in ipairs(getPlayersOnline()) do -- Script by Dubler, written for megaevo.net
	list[i] = tid
end
for i = 1, #list do
doPlayerAddItem(list[i],t[1],t[2])
doBroadcastMessage(getPlayerName(cid) .. " has given reward: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players!")
end -- Script by Dubler, written for megaevo.net
else
doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
end
return true
end -- Script by Dubler, written for megaevo.net

What do i add to make it only show it once?
 
Add the broadcast line under the loop, the loop repeats everything inside it to an amount same as the amount of online players, if you add it under the end, so outside the loop, it will only do it 1x.
Like this.
LUA:
function onSay(cid, words, param, channel) -- Script by Dubler, written for megaevo.net
	local t = string.explode(param, ",")
	if t[1] ~= nil and t[2] ~= nil then
		local list = {}
		for i, tid in ipairs(getPlayersOnline()) do -- Script by Dubler, written for megaevo.net
			list[i] = tid
		end
		for i = 1, #list do
			doPlayerAddItem(list[i],t[1],t[2])
		end -- Script by Dubler, written for megaevo.net
		doBroadcastMessage(getPlayerName(cid) .. " has given reward: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players!")
	else
		doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
	end
	return true
end -- Script by Dubler, written for megaevo.net
 
Add the broadcast line under the loop, the loop repeats everything inside it to an amount same as the amount of online players, if you add it under the end, so outside the loop, it will only do it 1x.
Like this.
LUA:
function onSay(cid, words, param, channel) -- Script by Dubler, written for megaevo.net
	local t = string.explode(param, ",")
	if t[1] ~= nil and t[2] ~= nil then
		local list = {}
		for i, tid in ipairs(getPlayersOnline()) do -- Script by Dubler, written for megaevo.net
			list[i] = tid
		end
		for i = 1, #list do
			doPlayerAddItem(list[i],t[1],t[2])
		end -- Script by Dubler, written for megaevo.net
		doBroadcastMessage(getPlayerName(cid) .. " has given reward: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players!")
	else
		doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
	end
	return true
end -- Script by Dubler, written for megaevo.net

Thanks works great now.
 
Back
Top