Jump to content

[Help] Online Players


HUNGRY:3

Recommended Posts

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
Link to comment
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 

Link to comment
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

Link to comment
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

Link to comment
  
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) 
  

Link to comment
  
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) 
  

Link to comment

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
Link to comment
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

Link to comment

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)  
  

Link to comment

: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) 

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