Jump to content

Admins problem


Blinker.

Recommended Posts

Hello Folks , i've made a gui which shows online Admins ,smods and mods. the problem is not all admins,smods and mods are showing in the gui , not even in the chatbox(for test).

here's my script (server side):

  
local onlineplayers = getElementsByType("player") 
  
  
  
function checkadmins() 
Admins  = "" 
for i ,v in ipairs (onlineplayers) do 
if isObjectInACLGroup("user.".. getAccountName(getPlayerAccount(v)),aclGetGroup'Admin') then 
Admins = getPlayerName(v):gsub("#%x%x%x%x%x%x", "").." - Admin\n" 
end 
end 
return Admins 
end 
  
  
  
  
function checksmod() 
smod = "" 
for i ,v in ipairs (onlineplayers) do 
if isObjectInACLGroup("user.".. getAccountName(getPlayerAccount(v)),aclGetGroup'SuperModerator') then 
smod = getPlayerName(v):gsub("#%x%x%x%x%x%x", "").." - Supermoderator\n" 
end 
end 
return smod 
end 
  
  
function checkmod() 
mod = "" 
for i ,v in ipairs (onlineplayers) do 
if isObjectInACLGroup("user.".. getAccountName(getPlayerAccount(v)),aclGetGroup'Moderator') then 
mod = getPlayerName(v):gsub("#%x%x%x%x%x%x", "").." - Moderator\n" 
end 
end 
return mod 
end 
  
function checkall () 
admins = checkadmins() 
smod = checksmod() 
mod = checkmod() 
outputChatBox(mod..smod..admins) 
triggerClientEvent("Triggered:data",root,admins,smod,mod) 
end 
addEvent("checkall",true) 
addEventHandler("checkall",root,checkall) 

edit : forgot to mention , checkall is triggered by the client side when the player opens the gui.

Link to comment
  • MTA Team
mod = getPlayerName(v):gsub("#%x%x%x%x%x%x", "").." - Moderator\n" 

You are replacing the variable with a fresh content. You have to append the content to the variable:

mod = mod .. getPlayerName(v):gsub("#%x%x%x%x%x%x", "").." - Moderator\n" 

You have to do it for SMod and Admin too.

Link to comment

Hello , i've got another problem , when i start the script , i can see online admins,smods and mods , but when i reconnect , i can't see them and get erros , i need to restart the script in order to make it work.

errors :bad argument at 'getPlayerAccount' (expected element at argument 1 )

bad argument at 'getAccountName' [expected element at argument 1 got boolean]

both at this line

if isObjectInACLGroup("user.".. getAccountName(getPlayerAccount(v)),aclGetGroup'Admin') then 

Thanks in advance.

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