Jump to content

/command test


Annas

Recommended Posts

Hi , i have made this simple server side code

function onlineStaff(thePlayer) 
    local admins = {} 
    for _,player in ipairs(getElementsByType("player")) do 
    if(exports.CSTadmin:isPlayerStaff(player)) then 
        table.insert(admins,getPlayerName(player)) 
        end          
    end 
    if(#admins > 0) then 
        exports.CSTtexts:output("Online staff: "..table.concat(admins,", "),thePlayer, 0,255,0)  
    else 
        exports.CSTtexts:output("No Staff is currently online!",thePlayer,255,0,0) 
    end 
end 
addCommandHandler("onlinestaffs", onlineStaff) 

I must do ./onlinestaffs , to view currently online staffs .. , how can i make it "/online staffs" ?

Please help.

Link to comment
function onlineStaff(thePlayer, _, cmd) 
    local admins = {} 
    if (cmd == "staffs") then 
    for _,player in ipairs(getElementsByType("player")) do 
    if(exports.CSTadmin:isPlayerStaff(player)) then 
        table.insert(admins,getPlayerName(player)) 
        end         
    end 
    if(#admins > 0) then 
        exports.CSTtexts:output("Online staff: "..table.concat(admins,", "),thePlayer, 0,255,0) 
    else 
        exports.CSTtexts:output("No Staff is currently online!",thePlayer,255,0,0) 
    end 
    end 
end 
addCommandHandler("online", onlineStaff) 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...