Jump to content

[HELP] Script


1LoL1

Recommended Posts

Please anyone help me :( i dont know how to add for only admins can used /ann. :(

function shoutAdmin(plr, cmd, ...) 
    local msg = table.concat({...}, " ") 
    outputChatBox("Admin"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
end 
addCommandHandler("ann", shoutAdmin) 

Link to comment
https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup

See the examples and try it for yourself.

So this?:

function shoutAdmin(plr, cmd, ...) 
    local msg = table.concat({...}, " ") 
    outputChatBox("Admin"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
end 
addCommandHandler("ann", shoutAdmin) 
  
players = getElementsByType ( "player" ) 
admins = "" 
for k,v in ipairs(players) do 
   local accountname = "" 
   if (isGuestAccount(getPlayerAccount(v)) == false) then 
      accountname = getAccountName (getPlayerAccount(v)) 
      if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
         if (admins == "") then 
            admins = getPlayerName(v) 
         else 
            admins = admins .. ", " .. getPlayerName(v) 
         end 
      end 
   end 
end 
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0) 
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0) 

Or how to? :( i am really noob in "isObjectInACLGroup" :(.

Link to comment

try this:

function shoutAdmin(thePlayer, cmd, ...) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
    local msg = table.concat({...}, " ") 
    outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
    end 
end 
addCommandHandler("ann", shoutAdmin) 

Link to comment
try this:
function shoutAdmin(thePlayer, cmd, ...) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
    local msg = table.concat({...}, " ") 
    outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
    end 
end 
addCommandHandler("ann", shoutAdmin) 

Errors:

ERROR: Loading script failed: ann/ann.lua:8: "" expected near "else"

Script:

function shoutAdmin(thePlayer, cmd, ...) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
    local msg = table.concat({...}, " ") 
    outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
    end 
end 
    else 
        outputChatBox ( "TesT", thePlayer, 255, 255, 255, true ) 
    end 
end 
addCommandHandler("ann", shoutAdmin) 

Link to comment
  
function shoutAdmin(thePlayer, cmd, ...) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
        local msg = table.concat({...}, " ") 
        outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
    else 
                outputChatBox ( "TesT", thePlayer, 255, 255, 255, true ) 
    end 
end 
addCommandHandler("ann", shoutAdmin) 
  

I guess this is what you're trying to do.

Link to comment
  
function shoutAdmin(thePlayer, cmd, ...) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
        local msg = table.concat({...}, " ") 
        outputChatBox("Admin"..getPlayerName(thePlayer):gsub("#%x%x%x%x%x%x","")..": "..msg, root, 255, 0, 0) 
    else 
                outputChatBox ( "TesT", thePlayer, 255, 255, 255, true ) 
    end 
end 
addCommandHandler("ann", shoutAdmin) 
  

I guess this is what you're trying to do.

Thanks. :D

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