H3LPM3 Posted June 3, 2018 Share Posted June 3, 2018 EN: I NEED HELP WITH THIS, SORRY FOR MY BAD ENGLISH. I NEED ADD ONLY WANTED PLAYERS IN GRIDLIST RESUME: ADD : PLAYERS WITH STAR >= 1 IN GRIDLIST ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ PT: EU PRECISO DE AJUDA COM ISSO, QUERO ADICIONAR APENAS JOGADORES PROCURADOS NA GRIDLIST Quote function AtualizarListaDeNicks() guiGridListClear(ListaDeProcurados) for index, player in ipairs(getElementsByType("player")) do FILA = guiGridListAddRow(ListaDeProcurados) guiGridListSetItemText ( ListaDeProcurados, FILA, ColunaPlayers, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) guiGridListSetItemData ( ListaDeProcurados, FILA, ColunaPlayers, getPlayerName(player)) end end addEventHandler ( "onClientResourceStart", getRootElement(), AtualizarListaDeNicks ) addEventHandler ( "onClientPlayerChangeNick", getRootElement(), AtualizarListaDeNicks ) Link to comment
Skully Posted June 3, 2018 Share Posted June 3, 2018 function AtualizarListaDeNicks() guiGridListClear(ListaDeProcurados) for index, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) >= 1) then -- Get the current player's wanted level, and proceed if it is greater than or equal to 1. FILA = guiGridListAddRow(ListaDeProcurados) guiGridListSetItemText ( ListaDeProcurados, FILA, ColunaPlayers, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) guiGridListSetItemData ( ListaDeProcurados, FILA, ColunaPlayers, getPlayerName(player)) end end end addEventHandler( "onClientResourceStart", getRootElement(), AtualizarListaDeNicks ) addEventHandler( "onClientPlayerChangeNick", getRootElement(), AtualizarListaDeNicks ) getPlayerWantedLevel is used to get a player's wanted level. Link to comment
DNL291 Posted June 4, 2018 Share Posted June 4, 2018 In addition, you can use onClientPlayerQuit event to refresh the list, a timer will also be useful for that. Link to comment
H3LPM3 Posted June 5, 2018 Author Share Posted June 5, 2018 On 03/06/2018 at 20:31, Skully said: function AtualizarListaDeNicks() guiGridListClear(ListaDeProcurados) for index, player in ipairs(getElementsByType("player")) do if (getPlayerWantedLevel(player) >= 1) then -- Get the current player's wanted level, and proceed if it is greater than or equal to 1. FILA = guiGridListAddRow(ListaDeProcurados) guiGridListSetItemText ( ListaDeProcurados, FILA, ColunaPlayers, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) guiGridListSetItemData ( ListaDeProcurados, FILA, ColunaPlayers, getPlayerName(player)) end end end addEventHandler( "onClientResourceStart", getRootElement(), AtualizarListaDeNicks ) addEventHandler( "onClientPlayerChangeNick", getRootElement(), AtualizarListaDeNicks ) getPlayerWantedLevel is used to get a player's wanted level. I tried this, but when I open the wanted panel without being wanted by the police no player appears. And when I'm wanted, it shows up who's not wanted by the police. On 04/06/2018 at 00:32, DNL291 said: In addition, you can use onClientPlayerQuit event to refresh the list, a timer will also be useful for that. Added! Link to comment
Addlibs Posted June 5, 2018 Share Posted June 5, 2018 getPlayerWantedLevel, when used on clientside, only returns the local player's wanted level. You would need to either store other players' wanted levels in element data, sync the data yourself or trigger a server event to list wanted players into a table and send it back to client by triggering a client event. 1 Link to comment
H3LPM3 Posted June 6, 2018 Author Share Posted June 6, 2018 7 hours ago, MrTasty said: getPlayerWantedLevel, when used on clientside, only returns the local player's wanted level. You would need to either store other players' wanted levels in element data, sync the data yourself or trigger a server event to list wanted players into a table and send it back to client by triggering a client event. Can you help me with this? I had no idea how to do it; Link to comment
Skully Posted June 6, 2018 Share Posted June 6, 2018 On the server side where you use setPlayerWantedLevel, just below that add element data and sync it to the client with setElementData. setElementData(player, "wantedlevel", level, true) Replace the variables for player and level for whatever you have. Then in line 4 in the code I provided earlier, replace: if (getPlayerWantedLevel(player) >= 1) then With: if (getElementData(player, "wantedlevel") >= 1) then 1 Link to comment
H3LPM3 Posted June 6, 2018 Author Share Posted June 6, 2018 11 hours ago, Skully said: On the server side where you use setPlayerWantedLevel, just below that add element data and sync it to the client with setElementData. setElementData(player, "wantedlevel", level, true) Replace the variables for player and level for whatever you have. Then in line 4 in the code I provided earlier, replace: if (getPlayerWantedLevel(player) >= 1) then With: if (getElementData(player, "wantedlevel") >= 1) then i will try. Link to comment
H3LPM3 Posted June 6, 2018 Author Share Posted June 6, 2018 12 hours ago, Skully said: On the server side where you use setPlayerWantedLevel, just below that add element data and sync it to the client with setElementData. setElementData(player, "wantedlevel", level, true) Replace the variables for player and level for whatever you have. Then in line 4 in the code I provided earlier, replace: if (getPlayerWantedLevel(player) >= 1) then With: if (getElementData(player, "wantedlevel") >= 1) then WORKING! THANK YOU BRO -- Client.lua function AtualizarListaDeNicks() guiGridListClear(ListaDeProcurados) for index, player in ipairs(getElementsByType("player")) do if (getElementData(player, "Procurado") == true ) then FILA = guiGridListAddRow(ListaDeProcurados) guiGridListSetItemText ( ListaDeProcurados, FILA, ColunaPlayers, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) guiGridListSetItemData ( ListaDeProcurados, FILA, ColunaPlayers, getPlayerName(player)) end end end addEventHandler ( "onClientPlayerQuit", getRootElement(), AtualizarListaDeNicks ) addEventHandler ( "onClientResourceStart", getRootElement(), AtualizarListaDeNicks ) addEventHandler ( "onClientPlayerChangeNick", getRootElement(), AtualizarListaDeNicks ) -- Server.lua function VerNivelDeProcurado (player) if player then acc = getPlayerAccount ( player ) if isGuestAccount ( acc ) then return end local Procurado = getPlayerWantedLevel ( player ) if Procurado == 0 then setElementData ( player, "Procurado", false ) end if Procurado > 0 then setElementData ( player, "Procurado", true ) end end end setTimer( function() for i, pl in pairs(getElementsByType("player")) do if pl ~= (false or nil) then VerNivelDeProcurado(pl) end end end, 3000,0) 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