Jump to content

HELP LOGIN SCRIPT URGENT!


Recommended Posts

I would highly recommend making use of the account system built into MTA.

Using xml has massive pitfalls and can create errors not to mention is is a head f.uck.

Below is the code to an xml account info storage system I retired a while ago if you really want to use it.

local Loco = xmlLoadFile("regData.xml") 
--local Logs = fileOpen("oldData.txt") 
  
function checkXML () 
    if Loco then 
   --     if Logs then 
            return true 
        else 
            outputChatBox("FATIAL XML ERROR",root,255,0,0) 
            return 
        end 
--    end 
end 
checkXML () 
  
addEventHandler ( "onPlayerQuit", getRootElement(),  
function () 
local x,y,z = getElementPosition(source) 
local account = getPlayerAccount(source) 
local Name = getAccountName(account) 
local Cash = getPlayerMoney(source) 
local pos = xmlFindChild(Loco,Name,0) 
    if not pos then  
        xmlCreateChild(Loco,Name) 
        xmlSaveFile(Loco) 
        return true 
    else 
        xmlNodeSetAttribute(pos,Name,Name..","..tostring(Cash)..","..x .. "," .. y .. "," .. z) 
        xmlSaveFile(Loco) 
    end 
end) 
  
addEventHandler ( "onPlayerLogin", getRootElement(),  
function () 
local x,y,z = getElementPosition(source) 
local account = getPlayerAccount(source) 
local Name = getAccountName(account) 
local Cash = getPlayerMoney(source) 
local pos = xmlFindChild(Loco,Name,0) 
    if not pos then  
        xmlCreateChild(Loco,Name) 
        xmlSaveFile(Loco) 
        return true 
    else 
        return false  
    end 
end) 
  
addEventHandler("onPlayerLogout",getRootElement(), 
function () 
        cancelEvent() 
        outputChatBox("You cannot logout this is to prevent cheating!",source,255,0,0) 
        outputChatBox("Reconnect or disconnect if you want to logout.",source,255,0,0) 
end) 

It has been known to stop working once there are to many children on the root class.

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