Jump to content

[SOLVED] Admin Command (chatbox)


Recommended Posts

Hey guys, i require some more assistance understanding lua, TAPL, can you explain why this won't work.

i have attempted to create a command which outputs to the chatbox, now, i am adding a language system, my meta file contains this setting btw. Its not done.

syntax:

/note hello

output:

(NOTE) Chris: Hello

meta:

<meta> 
    <info author="[EGL]Chris" version="0.5" type="script" name="Essentials" description="This script add's alot of features for admin's and players. Hope you like it." /> 
    <settings> 
    <!--We currently accept the languages of english, spanish, arabic.--> 
        <setting name="*language" value="spanish" /> 
        <setting name="*joinquitcolor" value="255,200,100" /> 
    </settings> 
    <script src="admintag.lua" type="server" /> 
    <script src="admincommands.lua" type="server" /> 
    <script src="ip+serial.lua" type="server" /> 
    <script src="outputs.lua" type="server" /> 
    <script src="joinquit.lua" type="server" /> 
</meta> 

Server ofc:

local root = getRootElement() 
local name = getPlayerName(source) 
local account = getPlayerAccount(source) 
local language = get('language') 
function note (text, msgtype) 
if language == "english" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
outputServerLog("NOTE: ".. name) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) 
end 
end 
elseif language == "spanish" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) 
end 
end 
elseif language == "arabic" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) 
end 
  
addCommandHandler("note", note) 

Edited by Guest
Link to comment
  
local root = getRootElement() -- root is global variable MTA 
local name = getPlayerName(source) -- you can`t use here source  
local account = getPlayerAccount(source) -- and here 
-- read wiki [url=https://wiki.multitheftauto.com/wiki/Event_system]https://wiki.multitheftauto.com/wiki/Event_system[/url] 
local language = get('language') 
function note (text, msgtype) -- you forgot variable in function "source" read wiki [url=https://wiki.multitheftauto.com/wiki/AddCommandHandler]https://wiki.multitheftauto.com/wiki/AddCommandHandler[/url] 
if language == "english" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
outputServerLog("NOTE: ".. name) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) 
end 
end 
elseif language == "spanish" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) 
end 
end 
elseif language == "arabic" then 
if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) 
end 
  
addCommandHandler("note", note) 

Correct:

local language = get('language') 
function note (source,cmd,text) 
    local name = getPlayerName(source) 
    local account = getAccountName(getPlayerAccount(source)) 
  
    if language == "english" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
            outputServerLog("NOTE: ".. name) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) 
        end 
    elseif language == "spanish" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) 
        end 
    elseif language == "arabic" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) 
        end 
    end 
end      
addCommandHandler("note", note) 

Use the tabulation to keep the code more viewed and you will immediately see where something is missing

Edited by Guest
Link to comment

wrong wrong wrong

look at this

local account = getPlayerAccount(source) 

should be

local account = getAccountName(getPlayerAccount(source)) 

also "true" needed in outputChatBox to enable colorCoded

msgtype: not needed because you aren't use event onPlayerChat you use addCommandHandler -_-

correct

local language = get('language') 
  
function note (source,cmd,text) 
    local name = getPlayerName(source) 
    local account = getAccountName(getPlayerAccount(source)) 
  
    if language == "english" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
            outputServerLog("NOTE: ".. name) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255, true) 
        end 
    elseif language == "spanish" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(NOTA)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255, true) 
        end 
    elseif language == "arabic" then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
            outputChatBox("#FF0000(ملاحظة)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 
        elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
            outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255, true) 
        end 
    end 
end     
addCommandHandler("note", note) 

Link to comment
wrong wrong wrong

look at this

local account = getPlayerAccount(source) 

should be

local account = getAccountName(getPlayerAccount(source)) 

Yes you right i forgot this ty :)

also "true" needed in outputChatBox to enable colorCoded

Read wiki:

bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] ) 

colorCoded Default: false

msgtype: not needed because you aren't use event onPlayerChat you use addCommandHandler -_-

Maybe he want to create in future for this variable to use it.

Link to comment
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 

outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 

What is the difference between them?

The first will be: #FF0000(NOTE) TAPL:#FFFFFF Hello

The second will be: (NOTE) TAPL: Hello

you see the difference? :lol:

Link to comment
outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255) 

outputChatBox("#FF0000(NOTE)  "..name..":#FFFFFF "..text,root,255, 255, 255, true) 

What is the difference between them?

The first will be: #FF0000(NOTE) TAPL:#FFFFFF Hello

The second will be: (NOTE) TAPL: Hello

you see the difference? :lol:

Yes you right i forgot it :D

I tired today.

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