Jump to content

[Help] Online Players


HUNGRY:3

Recommended Posts

Posted

hello every body

i'm trying to make a window....

with 1 button and a grid list

in the grid list

i want it to show online players nicks that has an elementData

getElementData(source,"RUN") == true  

can some body tell me how to do it?

2vjs7it.jpg
Posted

Get all the players using getElementsByType. Then loop through the player and get their data using getElementData. If the data is true, you can either add them to a new table - or just add it directly to the gridlist.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted (edited)

i did it but it shows all the players how to make it for the players who has the data of "RUN"

code:

setTimer(  
function( )  
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN:   '..  #getElementsByType('player') )  
end, 100, 0  
)  

Edited by Guest
2vjs7it.jpg
Posted
i did it but it shows all the players how to make it for the players who has the data of "RUN"

code:

setTimer(  
function( )  
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN:   '.. if #getElementsByType('player') )  
end, 100, 0  
)  

for i,v in ipairs(getElementsByType("player")) 
    if getElementData(v,"RUN") then 
        --Here is your code 
    end 
end 

Posted
i did it but it shows all the players how to make it for the players who has the data of "RUN"

code:

setTimer(  
function( )  
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN:   '.. if #getElementsByType('player') )  
end, 100, 0  
)  

for i,v in ipairs(getElementsByType("player")) 
    if getElementData(v,"RUN") then 
        --Here is your code 
    end 
end 

not working

2vjs7it.jpg
Posted
i did it but it shows all the players how to make it for the players who has the data of "RUN"

code:

setTimer(  
function( )  
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN:   '.. if #getElementsByType('player') )  
end, 100, 0  
)  

for i,v in ipairs(getElementsByType("player")) 
    if getElementData(v,"RUN") then 
        --Here is your code 
    end 
end 

Show me your code

not working

Posted
  
for i,v in ipairs(getElementsByType("player")) 
    if getElementData(v,"RUN") then 
setTimer( 
function( ) 
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN:   '.. #getElementsByType('player') ) 
end, 100, 0 
) 
end 

2vjs7it.jpg
Posted
  
function getPlayers() 
    playersInRun = {} 
        for index, players in ipairs ( getElementsByType("player") ) do 
            if getElementData(players, "RUN") then 
                table.insert(playersInRun, players) 
            end 
        end 
end 
  
setTimer(getPlayers, 2500, 0) 
  
  
  
guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #playersInRun) 
  

Currently developing for International Gaming Community - Join us!

Posted
  
function getPlayers() 
    local playersInRun = {} 
    for index, players in pairs ( getElementsByType("player") ) do 
       if getElementData(players, "RUN") then 
            table.insert(playersInRun, players) 
        end 
    end 
  
    guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #playersInRun) 
end 
  
setTimer(getPlayers, 2500, 0) 
  

Head Developer of SeeMTA

Founder and Head Developer of SAS-Network

560x95_FFFFFF_FF9900_000000_000000.png]
Posted (edited)

Try this it should :

-- Server side

function getPlayers() 
    local playersInRun = {} 
        for index, players in ipairs (getElementsByType("player")) do 
            if getElementData(players, "RUN") then 
            table.insert(playersInRun, players) 
        end 
    end 
    return playersInRun 
end 
  
function hijackerDC () 
    if getElementData(source, "RUN") then  
        table.removevalue( readyPlayerList, source ) 
    end  
end 
addEventHandler("onPlayerQuit",root, hijackerDC) 
  
-- table.removevalue function, in case you don't already have it 
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 
  
-- use triggerClientEvent then send the whole table to the client side 

-- Client side

function addRunPlayer(table) 
    local playerGrid = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true )  
    local column = guiGridListAddColumn( playerGrid, "Player", 0.85 )  
    if column then  
       for id, player in ipairs(table) do 
        local row = guiGridListAddRow ( playerGrid ) 
        guiGridListSetItemText ( playerGrid, row, column, getPlayerName ( player ), false, false ) 
    end 
end 
end  
  
-- Add you event handler here 

Edited by Guest

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Try this it should :
function getPlayers() 
    local playersInRun = {} 
        for index, players in ipairs (getElementsByType("player")) do 
            if getElementData(players, "RUN") then 
            table.insert(playersInRun, players) 
        end 
    end 
    return playersInRun 
end 
  
function hijackerDC () 
    if getElementData(players, "RUN") then  
        table.removevalue( readyPlayerList, source ) 
    end  
end 
addEventHandler("onPlayerQuit",root, hijackerDC) 
  
-- table.removevalue function, in case you don't already have it 
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 

12.  if getElementData(players, "RUN") then  

players = nil

My E-mails:

" Manners Maketh Man "

" الأخلاق تصنع الرجل "

░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM !

▂▄▅█████████▅▄▃▂

███████████████████].

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

if getElementData(players, "RUN") then  

players = ?

What ??? open your eyes I didn't finish the code.

for index, players in ipairs (getElementsByType("player")) do 
  
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

if getElementData(players, "RUN") then  

players = ?

What ??? open your eyes I didn't finish the code.

for index, players in ipairs (getElementsByType("player")) do 
  
end 

:D

i was mean line 12 , but you edit it :)

My E-mails:

" Manners Maketh Man "

" الأخلاق تصنع الرجل "

░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM !

▂▄▅█████████▅▄▃▂

███████████████████].

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

did i do some thing wrong?

client:

function addRunPlayer(table) 
    GUIEditor.gridlist[8] = guiCreateGridList(9, 104, 589, 273, false, GUIEditor.window[8]) 
    column = guiGridListAddColumn( GUIEditor.gridlist[8], "Players", 0.85 ) 
    if column then 
       for id, player in ipairs(table) do 
        row = guiGridListAddRow ( GUIEditor.gridlist[8] ) 
        guiGridListSetItemText ( GUIEditor.gridlist[8], row, column, getPlayerName ( player ), false, false ) 
    end 
end 
end 
addEvent( "RUN3", true ) 
addEventHandler( "RUN3", root, addRunPlayer ) 

server:

function getPlayers() 
    local playersInRun = {} 
        for index, players in ipairs (getElementsByType("player")) do 
            if getElementData(players, "RUN") then 
            table.insert(playersInRun, players) 
        end 
    end 
    return playersInRun 
end 
  
function hijackerDC () 
    if getElementData(source, "RUN") then 
        table.removevalue( readyPlayerList, source ) 
    end 
end 
addEventHandler("onPlayerQuit",root, hijackerDC) 
  
  
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 
triggerClientEvent (source,"RUN3",source)  
  

2vjs7it.jpg
Posted

:3 Wrong ,many things wrong.

Example using button

-- Client

function open() 
    triggerServerEvent("EventNameHere",localPlayer) 
end  
bindKey("F2", "down",open) 

-- Server

function YourFunction () 
    local table = getPlayers() 
    triggerClientEvent(source, "RUN3",source,table) 
end  
addEvent("EventNameHere",true) 
addEventHandler("EventNameHere",root,YourFunction) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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...