Jump to content

Problem with addAccount and callServerFunction


Spawn*

Recommended Posts

  
addEventHandler("onClientGUIClick", rGUI_BtnCat, EventGUICat, false) 
  
function EventGUICat(button) 
  
    -- some noob code 
  
        if((callServerFunction("addAccount", Acct, Pass)) ~= false) 
        then     
            showCursor(false) 
            guiSetVisible(rGUI_theBox, not guiGetVisible(rGUI_theBox)) 
            guiSetVisible(rGUI_LbLCon, not guiGetVisible(rGUI_LbLCon)) 
            guiSetVisible(rGUI_LbLSen, not guiGetVisible(rGUI_LbLSen)) 
            guiSetVisible(rGUI_EdtCon, not guiGetVisible(rGUI_EdtCon)) 
            guiSetVisible(rGUI_EdtSen, not guiGetVisible(rGUI_EdtSen)) 
            guiSetVisible(rGUI_BtnLog, not guiGetVisible(rGUI_BtnLog)) 
            guiSetVisible(rGUI_BtnCat, not guiGetVisible(rGUI_BtnCat)) 
            guiSetVisible(rGUI_ImgGUI, not guiGetVisible(rGUI_ImgGUI)) 
        else 
            outputChatBox("Essa conta já existe.", 255, 0, 0) 
            return 
        end  
end 
  

The problem is Access denied @ addAccount in console. :(

Help me please :cry:

Link to comment

Sorry... I'm not understanding :cry:

my file acl.xml is in: MTA San Andreas 1.3\servers\mods\deathmatch\acl.xml

Ok... I add the lines:

  
        <group name="Admin"> 
        <acl name="Moderator"></acl> 
        <acl name="SuperModerator"></acl> 
        <acl name="Admin"></acl> 
        <acl name="RPC"></acl> 
        <object name="resource.admin"></object> 
        <object name="resource.webadmin"></object> 
        <object name="resource.ORP_s"></object> -- here 
        <object name="resource.ORP_c"></object> -- here 

but still giving that warning :cry:

Link to comment

Right, this problem was resolved :D

Now... the code is this:

  
function EventGUICat(button) 
  
    if button == "left"  
    then 
        local Acct = guiGetText(rGUI_EdtCon) 
        local Pass = guiGetText(rGUI_EdtSen) 
         
        if(#Acct == 0 or #Pass == 0) 
        then 
            outputChatBox("Digite um nome de Conta não registrado e sua respectiva Senha.", 255, 0, 0) 
            return 
        end  
        if((#Acct ~= 0 and #Acct < 4) or (#Pass ~= 0 and #Pass < 4)) 
        then 
            outputChatBox("O nome de Conta e a Senha devem conter no mínimo 4 caracteres.", 255, 0, 0) 
            return 
        end      
        if(callServerFunction("addAccount", Acct, Pass)) 
        then     
            outputChatBox("Registrado.", 255, 0, 0) 
            showCursor(false) 
            guiSetVisible(rGUI_theBox, not guiGetVisible(rGUI_theBox)) 
            guiSetVisible(rGUI_LbLCon, not guiGetVisible(rGUI_LbLCon)) 
            guiSetVisible(rGUI_LbLSen, not guiGetVisible(rGUI_LbLSen)) 
            guiSetVisible(rGUI_EdtCon, not guiGetVisible(rGUI_EdtCon)) 
            guiSetVisible(rGUI_EdtSen, not guiGetVisible(rGUI_EdtSen)) 
            guiSetVisible(rGUI_BtnLog, not guiGetVisible(rGUI_BtnLog)) 
            guiSetVisible(rGUI_BtnCat, not guiGetVisible(rGUI_BtnCat)) 
            guiSetVisible(rGUI_ImgGUI, not guiGetVisible(rGUI_ImgGUI)) 
        else if(callServerFunction("getAccount", Acct)) 
        then 
            outputChatBox("Conta já existente.", 255, 0, 0) 
        else 
            outputChatBox("Erro desconhecido.", 255, 0, 0) 
        end  
    end 
end 
  

but there is some error... the script is not loaded.

This is already becoming too complicated :cry:

Link to comment

an "end' was missing :)

      
    function EventGUICat(button) 
      
        if button == "left" 
        then 
            local Acct = guiGetText(rGUI_EdtCon) 
            local Pass = guiGetText(rGUI_EdtSen) 
            
            if(#Acct == 0 or #Pass == 0) 
            then 
                outputChatBox("Digite um nome de Conta não registrado e sua respectiva Senha.", 255, 0, 0) 
                return 
            end  
            if((#Acct ~= 0 and #Acct < 4) or (#Pass ~= 0 and #Pass < 4)) 
            then 
                outputChatBox("O nome de Conta e a Senha devem conter no mínimo 4 caracteres.", 255, 0, 0) 
                return 
            end     
            if(callServerFunction("addAccount", Acct, Pass)) 
            then    
                outputChatBox("Registrado.", 255, 0, 0) 
                showCursor(false) 
                guiSetVisible(rGUI_theBox, not guiGetVisible(rGUI_theBox)) 
                guiSetVisible(rGUI_LbLCon, not guiGetVisible(rGUI_LbLCon)) 
                guiSetVisible(rGUI_LbLSen, not guiGetVisible(rGUI_LbLSen)) 
                guiSetVisible(rGUI_EdtCon, not guiGetVisible(rGUI_EdtCon)) 
                guiSetVisible(rGUI_EdtSen, not guiGetVisible(rGUI_EdtSen)) 
                guiSetVisible(rGUI_BtnLog, not guiGetVisible(rGUI_BtnLog)) 
                guiSetVisible(rGUI_BtnCat, not guiGetVisible(rGUI_BtnCat)) 
                guiSetVisible(rGUI_ImgGUI, not guiGetVisible(rGUI_ImgGUI)) 
            else if(callServerFunction("getAccount", Acct)) 
            then 
                outputChatBox("Conta já existente.", 255, 0, 0) 
            else 
                outputChatBox("Erro desconhecido.", 255, 0, 0) 
            end  
        end 
    end 
end 
  

Link to comment

The code has not worked, only appeared the message "Erro desconhecido.". So I decided to do a test ... I took the command /register of the system administration and improvised to work on my script-client.

RESULT:

  
addCommandHandler ( "register2", function (command, arg1, arg2 ) 
    local username = getPlayerName ( getLocalPlayer() ) 
    local password = arg1 
    if ( arg2 ) then 
        username = arg1 
        password = arg2 
    end 
    if ( password ~= nil ) then 
        if ( string.len ( password ) < 4 ) then 
            outputChatBox ( "register: - Password should be at least 4 characters long",  255, 100, 70 ) 
        elseif ( callServerFunction("addAccount", username, password ) ) then 
            outputChatBox ( "You have successfully registered! Username: '"..username.."', Password: '"..password.."'(Remember it)", 255, 100, 70 ) 
            outputServerLog ( "ADMIN: "..getPlayerName ( getLocalPlayer() ).." registered account '"..username.."' (IP: "..getPlayerIP(getLocalPlayer()).."  Serial: "..getPlayerSerial(getLocalPlayer())..")" ) 
        elseif ( callServerFunction("getAccount", username ) ) then 
            outputChatBox ( "register: - Account with this name already exists.",  255, 100, 70 ) 
        else 
            outputChatBox ( "Unknown Error",  255, 100, 70 ) 
        end 
    else 
        outputChatBox ( "register: - Syntax is 'register [] '", 255, 100, 70 ) 
    end 
end ) 

The error was the same ... the only message displayed was "Unknown Error". Now instead of calling a native function with callServerFunction I'll create a function and call it, and inside it put addAccount.

Sorry for my bad english. Please help me if you have suggestions :P

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