Jump to content

[Help]PolicePanel


aymeness81

Recommended Posts

Hey all, I wanted to create a police computer , but I have a problem on it, I want to show in the girdlist only the wanted players, as you see I made it showing all online players; Can someone help me?

Thanks :)

Client Side :

  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
  
        policeGUI = guiCreateWindow(186, 177, 532, 344, "Job Tools", false) 
        guiWindowSetSizable(policeGUI, false) 
        guiSetVisible(policeGUI, false) 
        playersGrid = guiCreateGridList(18, 62, 504, 225, false, policeGUI) 
        guiGridListAddColumn(playersGrid, "Wanted Players", 0.5) 
        guiGridListAddColumn(playersGrid, "Wanted Level", 0.5) 
        GUIEditor.button[1] = guiCreateButton(18, 301, 107, 33, "Track Player", false, policeGUI) 
        GUIEditor.button[2] = guiCreateButton(207, 301, 107, 33, "Refresh", false, policeGUI) 
        GUIEditor.button[3] = guiCreateButton(385, 301, 107, 33, "Cancel", false, policeGUI) 
        GUIEditor.label[1] = guiCreateLabel(124, 21, 295, 35, "Zone Gaming Police Panel", false, policeGUI) 
        guiSetFont(GUIEditor.label[1], "sa-header") 
        guiLabelSetColor(GUIEditor.label[1], 0, 11, 255)     
  
         for id, playeritem in ipairs(getElementsByType("player")) do  
         local row = guiGridListAddRow ( playersGrid ) 
         guiGridListSetItemText ( playersGrid, row, playcol, string.gsub ( getPlayerName (playeritem), '#%x%x%x%x%x%x','' ), false, false ) 
    end 

Link to comment

You should use setElementData() to set the players' wanted level and then loop trough all the players and check if they have a wanted level greater than 0 like so:

  
for _,player in ipairs (getElementsByType("player")) do 
    if getElementData(player,"wantedLevel") > 0 then 
        local row = guiGridListAddRow(playerGrid) 
        guiGridListSetItemText(playersGrid,row,playcol,string.gsub(getPlayerName(player),"#%x%x%x%x%x%x",""),false,false)      
    end 
end 
  

Link to comment
You should use setElementData() to set the players' wanted level and then loop trough all the players and check if they have a wanted level greater than 0 like so:
  
for _,player in ipairs (getElementsByType("player")) do 
    if getElementData(player,"wantedLevel") > 0 then 
        local row = guiGridListAddRow(playerGrid) 
        guiGridListSetItemText(playersGrid,row,playcol,string.gsub(getPlayerName(player),"#%x%x%x%x%x%x",""),false,false)      
    end 
end 
  

I can use like that instead of yours;

for _,player in ipairs (getElementsByType("player")) do 
 local wantedlvl = getPlayerWantedLevel(player)     
if  wantedlvl <= 0 then 
        local row = guiGridListAddRow(playerGrid) 
        guiGridListSetItemText(playersGrid,row,playcol,string.gsub(getPlayerName(player),"#%x%x%x%x%x%x",""),false,false)      
    end 
end 
  

Link to comment

Yes, you can create your wanted level system any way you want (using element data or the classic GTA Star wanted level).

You made a mistake in your code:

  
if wantedlvl <= 0 then 
  

You put < instead of > and there is now need to add the =.

What you wrote right there means that if the player's wanted level is smaller than or equal to 0 then he should be added to the wanted list which has no logic. Use > instead.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...