Jump to content

Which one saving fine


Hero192

Recommended Posts

Yes bonus I know how to Script with SQL language and use it in MTA but, I want to know how to control MySQL to my server? to see player's data

if ( tostring ( get ( "CONNECTION_TYPE" ) ):lower() == "mysql" ) then  
    outputConsole ( "Attempting to connect as MySQL... Please wait") 
    db = dbConnect( "sqlite","data.db" ); 
elseif ( tostring ( get ( "CONNECTION_TYPE" ) ):lower() == "sqlite" ) then  
    db = dbConnect ( "sqlite", tostring(get("DATABASE_NAME")) .. ".sql" ); 
else  
    error ( tostring(get("CONNECTION_TYPE")) .. " is an invalid SQL connection -- valid: mysql, sqlite" ); 
end  
  
if not db then 
    print ( "The database has failed to connect") 
    return  
else 
    print ( "Database has been connected") 
end 
  
function db_query ( ... )  
    local data = { ... } 
    return dbPoll ( dbQuery ( db, ... ), - 1 ) 
end 
  
function db_exec ( ... ) 
    return dbExec ( db, ... ); 
end 

thats not all of it, but i gave you little bit of mine continue if you know how. if not try to find one in the community.

Link to comment
  
local weapStats_ = {  
    ['9mm'] = 0, ['silenced'] = 0, ['deagle'] = 0, ['shotgun'] = 0, ['combat_shotgun'] = 0,  
    ['micro_smg'] = 0, ['mp5'] = 0, ['ak47'] = 0, ['m4'] = 0, ['tec-9'] = 0, ['sniper_rifle'] = 0 } 
  
function createAccount ( account ) 
    if ( account and type ( account ) == 'string' ) then 
        local plr = getPlayerFromAccount ( account ) 
        local autoIP = "unknown" 
        local autoSerial = "unknown" 
        local weapStats = toJSON ( weapStats_ ) 
        if plr and isElement ( plr ) then 
            autoSerial = getPlayerSerial ( plr ) 
            autoIP = getPlayerIP ( plr ) 
            outputDebugString ( "NGSQL: Creating account "..account.." for player "..getPlayerName ( plr ).." (Serial: "..autoSerial.." || IP: "..autoIP..")" ) 
        else 
            outputDebugString ( "NGSQL: Creating account "..account.." for player N/A (Serial: None || IP: None)" ); 
        end 
        local today = exports['SAEGPlayerFunctions']:getToday ( ) 
        return db_exec (  
[[INSERT INTO `accountdata` (`Username`, `Money`, `Armour`, `Health`, `x`, `y`, `z`,  
`Skin`, `Interior`, `Dimension`, `Team`, `Job`, `Playtime_mins`, `JailTime`, `WL`, `Weapons`, `JobRank`,  
`GroupName`, `GroupRank`, `LastOnline`, `LastSerial`, `LastIP`, `Kills`, `Deaths`, `weapstats`, `items`,  
`unemployedskin`, `vip`, `vipexp`, `plrtosrvrsettings` )  
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );]],  
            account, '0', '0', '100', '0', '0', '0', '0', '0', '0', 'UnEmployed', 'UnEmployed', '0', '0', '0',  
            '[ [ ] ]', 'None', 'None', 'None', today, autoSerial, autoIP, '0', '0', weapStats, toJSON ( { } ), '28', 'None', nil, toJSON ( { } ) ) 
    end 

When you finish this you go to DATA and open it with Note pad you will find every thing

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