GetGuestPlayers: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 24: Line 24:
     end
     end
</syntaxhighlight></section>
</syntaxhighlight></section>
==Example==
This example gets Player In Guest Account and show msg login or register
<syntaxhighlight lang="lua">
addCommandHandler ( "getGuestPlayers_" , function ( )
    local GuestPlayers = getGuestPlayers (  )
    if ( #GuestPlayers ~= 0 ) then
    for _ , v in ipairs ( GuestPlayers ) do
    outputChatBox (  getPlayerName ( v ) : gsub ( "#%x%x%x%x%x%x", "" ) .. "plz Login or Register" , v , 255 , 255 , 255 , true )
            end
        end
    end
    ) ;
 
-- F8 Say : getGuestPlayers_
</syntaxhighlight>

Revision as of 02:29, 20 August 2016

Syntax

table getGuestPlayers (  )

Returns

Returns All Players not Login or All Players Guest Account , And vice false

Code

Click to collapse [-]
Server
function getGuestPlayers (  )
 
    local Guest = { } ;
 
    for _ , players_ in ipairs ( getElementsByType ( "player" ) ) do
 
    local playerAcc = getPlayerAccount ( players_ )
 
    if isGuestAccount ( playerAcc ) then
 
    table.insert ( Guest , players_ )
 
                end
            end 
        return Guest
    end

Example

This example gets Player In Guest Account and show msg login or register

addCommandHandler ( "getGuestPlayers_" , function ( )
 
    local GuestPlayers = getGuestPlayers (  )
 
    if ( #GuestPlayers ~= 0 ) then
 
    for _ , v in ipairs ( GuestPlayers ) do
 
    outputChatBox (  getPlayerName ( v ) : gsub ( "#%x%x%x%x%x%x", "" ) .. "plz Login or Register" , v , 255 , 255 , 255 , true )
 
            end
        end
    end
    ) ;
   
-- F8 Say : getGuestPlayers_