Hi, how can I add a loop in this script to make it not so big ?
i use tfs 0.3.6
i use tfs 0.3.6
Code:
function onSay(cid, words, param, channel)
local pos = getPlayerPosition(cid)
local players2 = getPlayersOnline()
local strings = {""}
local str2 = ""
local str3 = ""
for _, pid2 in ipairs(players2) do
if getPlayerStorageValue(pid2, 8000) == 1 then
str2 = str2 .. getCreatureName(pid2) ..", "
end
end
for _, pid3 in ipairs(players2) do
if getPlayerStorageValue(pid3, 8000) == 2 then
str3 = str3 .. getCreatureName(pid3) ..", "
end
end
if getPlayerStorageValue(cid,8000) == 1 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Bring me sword")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str2)
elseif getPlayerStorageValue(cid,8000) == 2 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Bring me shield")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str3)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Nothing")
end
return true
end