Jump to content
  • 0

Permissions


Benevolence

Question

Posted

Alright so I have a Roleplay server and you don't register by /register like you do in default server that comes when you install MTA. I wanted to know, how I can create an account like the default server lets you so that you can make it admin and add resources to acl only if your logged in with that account. I use mySQL.

Because I try adding some resources and when I try to use them it tells me "You don't have permission to use ... " and I can't seem to get around this, I tried some stuff in acl.xml file (probly not correct) but it keeps telling me that.

Recommended Posts

  • 0
Posted

Lol, because there is no code, for SYNTAX message.

addCommandHandler("register", 
function(player, cmd, name, password) 
if not name or not password then outputChatBox ( "SYNTAX: /register " , player ) return end 
local account = addAccount(name, password) 
if account then 
outputChatBox("Thank you " .. getPlayerName(player) .. ", you're now registed, you can login with /login",player) 
else 
outputChatBox("The account already exists" , player ) 
end 
end) 

  • 0
Posted
Lol, because there is no code, for SYNTAX message.
addCommandHandler("register", 
function(player, cmd, name, password) 
if not name or not password then outputChatBox ( "SYNTAX: /register " , player ) return end 
local account = addAccount(name, password) 
if account then 
outputChatBox("Thank you " .. getPlayerName(player) .. ", you're now registed, you can login with /login",player) 
else 
outputChatBox("The account already exists" , player ) 
end 
end) 

It works. One question, if I forget my info for this, how can I find it? Like if I forget my password. Where does the info save?

  • 0
Posted

If you mean, how to retrieve the password, you can do it with setAccountData(account, "password", password).

And then use getAccountData.

  • 0
Posted
If you mean, how to retrieve the password, you can do it with setAccountData(account, "password", password).

And then use getAccountData.

And how can I see which accounts exist?

  • 0
Posted
You mean checking if an account exists?
if getAccount ( "accountName" ) then 

No, I want to see all of the accounts that already exist. Perhaps if I want to do a wipe or remove a certain account.

  • 0
  • Discord Moderators
Posted

For wiping all accounts?

for i,account in ipairs(getAccounts()) do 
    removeAccount (account) 
end 

I suppose if you want to remove an account by name:

function removeAccountByName (strName, bPrtName) 
    if not strName or (type(strName) ~= 'string') then return end 
  
    for i,account in ipairs(getAccounts()) do 
        local accountName = getAccountName (account) 
     
        if (not bPrtName) then 
            if not (accountName:lower() == strName:lower()) then 
                return 
            end 
             
            removeAccount (account) 
            return 
        end 
         
        if accountName:find(strName, 0, true) then 
            removeAccount(account) 
        end 
    end 
end 

bPrtName is a boolean specifying whether to search for an account name containing the given string, or whether it has to be matching.

  • 0
Posted
For wiping all accounts?
for i,account in ipairs(getAccounts()) do 
    removeAccount (account) 
end 

I suppose if you want to remove an account by name:

function removeAccountByName (strName, bPrtName) 
    if not strName or (type(strName) ~= 'string') then return end 
  
    for i,account in ipairs(getAccounts()) do 
        local accountName = getAccountName (account) 
     
        if (not bPrtName) then 
            if not (accountName:lower() == strName:lower()) then 
                return 
            end 
             
            removeAccount (account) 
            return 
        end 
         
        if accountName:find(strName, 0, true) then 
            removeAccount(account) 
        end 
    end 
end 

bPrtName is a boolean specifying whether to search for an account name containing the given string, or whether it has to be matching.

Can you give me the proper Meta.xml for it? Thanks.

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