Talk:Useful Functions: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
there i wrote isElementInPhotograph()
enjoy
[[User:Drline|Drline]] 04:44, 30 October 2012 (UTC)


== addAccountToConsole ==
{{Useful Function}}
__NOTOC__
This function center the window in any resolution.<br>
* '''NOTE:''' This is made to be used clientside!.
==Syntax==
<syntaxhighlight lang="lua">* accName addAccountToConsole ( thePlayer, accountName )</syntaxhighlight>
===Required Arguments===
* '''theElement''': The element you want to center it.
==Code==
<section name="Clientside script" class="client" show="true">
<syntaxhighlight lang="lua">
function centerWindow (center_window)
    local screenW, screenH = guiGetScreenSize()
    local windowW, windowH = guiGetSize(center_window, false)
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2
    guiSetPosition(center_window, x, y, false)
end
</syntaxhighlight>
</section>
==Example==
This example center the window.
<syntaxhighlight lang="lua">
    addAccountToConsole = function ( plr , name )
        if name and tostring ( name ) and plr and isElement ( plr ) and getElementType ( plr ) == 'player' then
            local acc = getPlayerAccount ( plr )
                if not acc or isGuestAccount ( acc ) then return end
                    if isObjectInACLGroup ( 'user.'.. getAccountName ( acc ) , aclGetGroup ( 'Console' ) ) then
                        if not isObjectInACLGroup ( 'user.'.. name , aclGetGroup ( 'Console' ) ) then
                            aclGroupAddObject ( aclGetGroup( 'Console' ), 'user.' .. name )
                else
                    return false
                end
            else 
                    return false
                end
        else
                return false
            end
        return name or false
    end
   
    addCommandHandler ( 'add_', function ( plr , _, name )
        local name = addAccountToConsole ( plr, name )
            if not name then return false end
                outputChatBox ( 'Warning ! the account : '.. name .. ' was added to console group !', root )
        end
    )</syntaxhighlight>
Author: The Best
==See Also==
{{Useful_Functions}}

Revision as of 22:15, 21 May 2018