Jump to content

function


Agon

Recommended Posts

Hi i made this but how can i use it? (and is this code true? I cannot test it i've written this on my mobile phone)

function whoAreYou(thePlayer) 
  
local accName=getAccountName(getPlayerAccount(thePlayer)) 
if isObjectInACLGroup("user." ..accName, aclGetGroup("Admin")) then 
isPlayerAdmin == "true" 
else 
isPlayerAdmin == "false" 
end 
end 
  

can i use it like this?

function justTest(thePlayer) 
if isPlayerAdmin then 
outputChatBox("TRUE", thePlayer, 0, 255, 0) 
else outputChatBox("FALSE", thePlayer, 255, 0, 0) 
end 
end 
addCommandHandler("amiadmin", justTest) 
  

btw what is the difference between "thePlayer" and "source" ?

Link to comment

you can check if the player is admin by this way

function justTest(thePlayer) 
     if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
          outputChatBox("TRUE", thePlayer, 0, 255, 0) 
     else 
          outputChatBox("FALSE", thePlayer, 255, 0, 0) 
     end 
end 
addCommandHandler("amiadmin", justTest) 

 

also this work too

 

function isPlayerAdmin(thePlayer) 
     local accName=getAccountName(getPlayerAccount(thePlayer)) 
     if isObjectInACLGroup("user." ..accName, aclGetGroup("Admin")) then 
          return true 
     end 
end 
  
function justTest(thePlayer) 
     if isPlayerAdmin(thePlayer) then 
          outputChatBox("TRUE", thePlayer, 0, 255, 0) 
     else 
          outputChatBox("FALSE", thePlayer, 255, 0, 0) 
     end 
end 
addCommandHandler("amiadmin", justTest) 

Link to comment
btw what is the difference between "thePlayer" and "source" ?

source use only in event, in command handler function you can use too if you define it in arguments ( server side ).

Source examples:

Client

  
triggerServerEvent( 'onDownload',localPlayer ) -- We trigger to server , source is localPlayer 
-- I think you know, if script download then this event triggered to server. 
  

Server

addEvent( 'onDownload', true ) 
  
addEventHandler( 'onDownload', root, 
    function( ) 
        outputChatBox(  
            string.format(  
                '* %s download requested files.', 
                getPlayerName( source ) 
            )  
        ) 
    end 
)    

Output like this: * Kenix download requested files.

P.S If you not understand say me.

Also you can read here: viewtopic.php?f=91&t=39678

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