Jump to content

getElementsByType


TorNix~|nR

Recommended Posts

Posted (edited)

hello guys, please I'm wondering why isn't this working

for index,thisPlayer in pairs(getElementsByType("player") or getElementsByType("ped")) do

nothing found on debug, but only ped works but player not

help please?

Edited by TorNix~|nR
  • 3 months later...
Posted
On 22/03/2019 at 01:39, IIYAMA said:

@TorNix~|nR

That is not how this works. A table is a thing, it is something even if it is empty.


if {} then
	outputChatBox("Always true")
end

 


local players = getElementsByType("player") 


for index,thisPlayer in pairs(#players > 0 and players or getElementsByType("ped")) do

 

Note, this does not merge the tables. Just uses peds when there are no players.

I have "edixBox" from which I get the result (variable - result), how to check if there is such a player on the server (with the same name)?
 

Posted (edited)
37 minutes ago, Hugos said:

I have "edixBox" from which I get the result (variable - result), how to check if there is such a player on the server (with the same name)?
  

addEventHandler ( "onClientGUIChanged" , guiRoot , function ( )
    if source == yourEditBox then
        local Name = guiGetText ( source )
        if Name and Name ~= "" then
            for _ , Player in pairs( getElementsByType ( "player" ) ) do
                if getPlayerName ( Player ):lower ( ):find ( Name:lower ( ) , 1 , true) then
                    outputChatBox ( "Player Exists" , 255 , 255 , 255 , true )
                    break
                end
            end
        end
    end
end )

Edit : forget ( break )

Edited by #x1AhMeD-09
  • Like 1

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