Hello, sorry this is my first thread for asking something about how to get specific elements data for all players
i've tried some of code like getElementsByType, getElementData, but still i dont know how, and im new in Lua programming, but experience in code like C, and website programming such as php, jvscript.
addCommandHandler( "check", function(player)
local checkplayerid = getElementsByType("playerid",below)
local first = 1
local found = false
local i =0
while(found == false) do
local yes = isValueInTable(checkplayerid,first,i)
if yes then
outputChatBox(first .. 'and' .. i .. 'is same',player,255,100,100)
else
outputChatBox(first .. 'is found!',player,255,100,100)
setElementData(player,'playerid',first)
found = true
end
first = first + 1
i = i + 1
end
end)
function isValueInTable(theTable,value,columnID)
assert(theTable, "Bad argument 1 @ isValueInTable (table expected, got " .. type(theTable) .. ")")
local checkIsTable = type(theTable)
assert(checkIsTable == "table", "Invalid value type @ isValueInTable (table expected, got " .. checkIsTable .. ")")
assert(value, "Bad argument 2 @ isValueInTable (value expected, got " .. type(value) .. ")")
assert(columnID, "Bad argument 3 @ isValueInTable (number expected, got " .. type(columnID) .. ")")
local checkIsID = type(columnID)
assert(checkIsID == "number", "Invalid value type @ isValueInTable (number expected, got " ..checkIsID .. ")")
for i,v in ipairs (theTable) do
if v[columnID] == value then
return true,i
end
end
return false
end
im using isValueInTable from wiki mta for check the value in table
im just a new scripter in Lua, im sorry for ugly code.
sorry bad english