yusufbali Posted April 25, 2016 Share Posted April 25, 2016 Please help me, i try but i can't fix this. Im newbie client.lua:16: Bad argument @'setElementData'[Expected element at agument 1,got nil] 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) Link to comment
yusufbali Posted April 25, 2016 Author Share Posted April 25, 2016 Anyone help , please Link to comment
Simple0x47 Posted April 25, 2016 Share Posted April 25, 2016 Try to use another variable and be sure that the function you call has a valid name. Because if it returns nil it's because your function doesn't have the paremeter name. Link to comment
Anubhav Posted April 25, 2016 Share Posted April 25, 2016 Can we see when do you trigger the server event? I'm just thinking you probably are putting in a player element which causes a error either the player never is there by that partial name. Link to comment
Saml1er Posted April 25, 2016 Share Posted April 25, 2016 Replace the function with this: function siramiayarla(name, i) local player = getPlayerFromPartialName(name) if not player then outputChatBox ( "Player not found. Name" ..name.. "/ i: "..i ) else outputChatBox("player found") end setElementData(player,"Sıra",i) end After running the code let me know what it outputs. Link to comment
yusufbali Posted April 25, 2016 Author Share Posted April 25, 2016 Can we see when do you trigger the server event?I'm just thinking you probably are putting in a player element which causes a error either the player never is there by that partial name. 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 Replace the function with this: function siramiayarla(name, i) local player = getPlayerFromPartialName(name) if not player then outputChatBox ( "Player not found. Name" ..name.. "/ i: "..i ) else outputChatBox("player found") end setElementData(player,"Sıra",i) end After running the code let me know what it outputs. Same warning, @1 player found @2 player not found . NameCrysler /i:2 Link to comment
Saml1er Posted April 28, 2016 Share Posted April 28, 2016 Help pleasee!! Instead of finding the player, why don't you simply send the player element using triggerClientEvent. Currently you are sending name which is not the right way to do it. 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