yusufbali Posted April 27, 2016 Share Posted April 27, 2016 (edited) Note:Sıra mean rank (maybe it helpful) , please help guys last warning in my server. client.lua:16: Bad argument @'setElementData'[Expected element at agument 1,got nil] Client; function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function siramiayarla(name, i) local player = getPlayerFromPartialName(name) setElementData(player,"Sıra",i) end addEvent("siraayarla", true) addEventHandler("siraayarla", root, siramiayarla) And server event; function createTopSystem( player ) if not isElement( player ) then return end local Top = {} local CreatTop = executeSQLQuery( "SELECT * FROM stats6" ) for i = 1, #CreatTop do table.insert(Top,{nickim = CreatTop[i].nickim,puan = CreatTop[i].puan}) end if #CreatTop >0 then table.sort(Top, function(a,b) return (tonumber(a.puan)or 0) > (tonumber(b.puan)or 0) end) setTimer( function() for k, data in ipairs(Top) do triggerClientEvent (player,"siraayarla",player,tostring(data.nickim),tonumber(k)) end end, 50, 1 ) end end Edited April 27, 2016 by Guest Link to comment
Tekken Posted April 27, 2016 Share Posted April 27, 2016 You did not passed the player in timer. Server function createTopSystem(player) if not isElement(player) then return false; end local Top = {} local CreatTop = executeSQLQuery("SELECT * FROM stats6"); for i = 1, #CreatTop do table.insert(Top, {nickim = CreatTop[i].nickim,puan = CreatTop[i].puan}); end if (#CreatTop > 0) then table.sort(Top, function(a, b) return (tonumber(a.puan) or 0) > (tonumber(b.puan) or 0) end ); setTimer(function(player) for k, data in ipairs(Top) do triggerClientEvent(player, "siraayarla", player, tostring(data.nickim), tonumber(k)) end end, 50, 1, player); end end Client function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil; if (name) then for _,v in ipairs(getElementsByType("player")) do local name_ = getPlayerName(v):gsub("#%x%x%x%x%x%x", ""):lower(); if name_:find(name, 1, true) then return v; end end end end addEvent("siraayarla", true); addEventHandler("siraayarla", getRootElement(), function(name, i) local player = getPlayerFromNamePart(name); if isElement(player) then setElementData(player, "Sıra", i); end end); Link to comment
yusufbali Posted April 27, 2016 Author Share Posted April 27, 2016 It works thanks boss you are the best for me Link to comment
Tekken Posted April 27, 2016 Share Posted April 27, 2016 It works thanks boss you are the best for me No problem dude glad I can help. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now