Help me in my MySql
#1

pawn Код:
//=======================================================================================
stock Connect_To_Database(){
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
    if(mysql_ping() != 0){
        print("[DayZ - MySQL] Connect to MySQL Database successfully !");
    }
    else
    {
        print("[DayZ - MySQL] Can't connect to MySQL Database | Trying Again !");
        mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
        if(mysql_ping() != 1){
            print("[DayZ - MySQL] Connect to MySQL Database successfully !");
        }
        else{
            print("[DayZ - MySQL] Can't connect to MySQL Database | Server Closed !");
            SendRconCommand("exit");
        }
    }
    return true;
}
//=======================================================================================
stock mysql_CheckAccount(playerid){
    new Query[128],Name[MAX_PLAYER_NAME],count;
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name, Name);
    format(Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(Query);
    mysql_store_result();
    count = mysql_num_rows();
    mysql_free_result();
    return count;
}
//=======================================================================================
stock CreateAccount(playerid, pass[]){
    new query[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name,Name);
    mysql_real_escape_string(pass,pass);
    format(query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`) VALUES ('%s', '%s')", Name, pass);
    mysql_query(query);
    return true;
}
//=======================================================================================
stock mysql_ReturnPassword(Name[]){
    new query[130], Get[130];
    mysql_real_escape_string(Name, Name);
    format(query, 128, "SELECT `password` FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
}
//=======================================================================================
stock mysql_GetInt(Table[], Field[], Where[], Is[]){
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    new sqlint = mysql_fetch_int();
    mysql_free_result();
    return sqlint;
}
//=======================================================================================
stock mysql_GetString(Table[], Field[], Where[], Is[]){
    new query[128], Get[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
}

This is the MYSQL logs
Код:
[16:12:25] ---------------------------

[16:12:25] MySQL Debugging activated (10/26/14)

[16:12:25] ---------------------------

[16:12:25]  

[16:12:25] >> mysql_connect( )

[16:12:25] CMySQLHandler::CMySQLHandler() - constructor called.

[16:12:25] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.1.39" | DB: "dayz.db" | Username: "root" ...

[16:12:25] CMySQLHandler::Connect() - Host '888-PC' is not allowed to connect to this MySQL server (Error ID: 1130)

[16:12:25] >> mysql_ping( Connection handle: 1 )

[16:12:25] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[16:14:12]  

[16:14:12] ---------------------------

[16:14:12] MySQL Debugging activated (10/26/14)

[16:14:12] ---------------------------

[16:14:12]  

[16:14:12] >> mysql_connect( )

[16:14:12] CMySQLHandler::CMySQLHandler() - constructor called.

[16:14:12] CMySQLHandler::CMySQLHandler() - Connecting to "888-PC" | DB: "dayz.db" | Username: "root" ...

[16:14:12] CMySQLHandler::Connect() - Host '888-PC' is not allowed to connect to this MySQL server (Error ID: 1130)

[16:14:12] >> mysql_ping( Connection handle: 1 )

[16:14:12] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[16:14:37] >> mysql_real_escape_string( Connection handle: 1 )
This is my MySql

pawn Код:
//====[ Defines // Enums // Forwards // ... ]====
//MySQL:
#define SQL_HOST   "888-PC"
#define SQL_USER   "root"
#define SQL_PASS   ""
#define SQL_DATA   "dayz.db"

Please help me
Reply
#2

I dont know what is DataBase i create my database and i put in filterscript and this is the code

pawn Код:
/*               * * * * INFO * * * *               */
/*
    Date started:   17-11-2013
    Time:           10:20 AM
    Creator:        Voxel
    Server Name:    SQLBASE
    Database:       SQLite
    Version:        0.1
    Website:        http://www.sa-mp.com
*/

/*             * * * * INCLUDES * * * *             */
#include <a_samp>
/*             * * * * DEFINES * * * *              */
#define MAX_INI_ENTRY_TEXT 80
//INFO
#define Web "www.lotd.forumtl.com"
#define Version "v1.1"
#define Creator "Lloyde"
#define Name "SQL BASE""
#define CName "SQLB"
#define chat "{FFFFFF}*"
//COLORS
#define COL_WHITE          "{FFFFFF}"
#define COL_GREY           "{C3C3C3}"
#define COL_GREEN          "{37DB45}"
#define COL_RED            "{F81414}"
#define COL_YELLOW         "{F3FF02}"
#define COL_ORANGE         "{F9B857}"
#define COL_BLUE           "{0049FF}"
#define COL_PINK           "{FF00EA}"
#define COL_LIGHTBLUE      "{00C0FF}"
#define COL_LGREEN         "{C9FFAB}"
/*             * * * * NATIVES * * * *             */
native WP_Hash(buffer[], len, const str[]);
/*           * * * * ENUMERATORS * * * *           */
enum USER_DATA
{
    USER_ID,
    USER_NAME[MAX_PLAYER_NAME],
    USER_PASSWORD[129],
    USER_ADMIN,
    USER_VIP,
    USER_MONEY,
    USER_SCORE,
    USER_KILLS,
    USER_DEATHS,
    USER_KD,

    bool: USER_LOGGED_IN
};
/*         * * * * GLOBAL VARIABLES * * * *        */
new User[MAX_PLAYERS][USER_DATA];
new DB: Database;
/*              * * * * MAIN * * * *               */
main()
{
    print("=====================================");
    print("|             SQL BASE              |");
    print("|            *INITIATED*            |");
    print("|           Version: v0.1           |");
    print("|           Creator: Voxel          |");
    print("=====================================");
}

public OnFilterScriptInit()
{
    SetGameModeText("SQLBASE"Version"Dayz.LOTD v1.1");
    Database = db_open("dayz.db");
    db_query(Database, "CREATE TABLE IF NOT EXISTS users (userid INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR(24) COLLATE NOCASE, password VARCHAR(129), admin INTEGER DEFAULT 0 NOT NULL, vip INTEGER DEFAULT 0 NOT NULL, money INTEGER DEFAULT 0 NOT NULL, score INTEGER DEFAULT 0 NOT NULL, kills INTEGER DEFAULT 0 NOT NULL, deaths INTEGER DEFAULT 0 NOT NULL, kd INTEGER DEFAULT 0 NOT NULL)");
    AddPlayerClass(1, 2528.9143,-1667.7504,15.1689,91.2860,0,0,0,0,0,0);
    return 1;
}

public OnFilterScriptExit()
{
    db_close(Database);
    print("=====================================");
    print("|             SQL BASE              |");
    print("|            *SHUT DOWN*            |");
    print("|           Version: v0.1           |");
    print("|           Creator: Voxel          |");
    print("=====================================");
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    for(new i; i < _: USER_DATA; ++i) User[playerid][USER_DATA: i] = 0;

    GetPlayerName(playerid, User[playerid][USER_NAME], MAX_PLAYER_NAME);

    new Query[71], DBResult: Result;
    format(Query, sizeof(Query), "SELECT password FROM users WHERE username = '%s' LIMIT 0, 1", DB_Escape(User[playerid][USER_NAME]));
    Result = db_query(Database, Query);
    if(db_num_rows(Result))
    {
        db_get_field_assoc(Result, "password", User[playerid][USER_PASSWORD], 129);
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Login pannel", ""chat" Please login to play on "COL_BLUE"Survival Games Zombie Mode\n"COL_WHITE"Enter your "COL_BLUE"password"COL_WHITE":", "Login", "Exit");
    }
    else ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Register pannel", ""chat" Please register to play on "COL_BLUE"Survival Games Zombie Mode\n"COL_WHITE"Enter a "COL_BLUE"password"COL_WHITE":", "Register", "Exit");
    db_free_result(Result);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(User[playerid][USER_LOGGED_IN] == true)
    {
        new Query[128];
        format(Query, sizeof(Query), "UPDATE users SET admin = %d, vip = %d, money = %d, score = %d, kills = %d, deaths = %d, kd = %d WHERE username = '%s'", User[playerid][USER_ADMIN], User[playerid][USER_VIP], GetPlayerMoney(playerid), GetPlayerScore(playerid), User[playerid][USER_KILLS], User[playerid][USER_DEATHS], User[playerid][USER_KD], DB_Escape(User[playerid][USER_NAME]));
        db_query(Database, Query);
    }
    for(new i; i < _: USER_DATA; ++i) User[playerid][USER_DATA: i] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}
/*             * * * * DIALOGS * * * *           */
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0)
    {
        if(response)
        {
            if(!inputtext[0]) return ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Login pannel", ""chat" Please login to play on "COL_BLUE"Survival Games Zombie Mode\n "COL_WHITE"Enter your "COL_BLUE"password"COL_WHITE":", "Login", "Exit");
            new buf[129];
            WP_Hash(buf, 129, inputtext);
            if(!strcmp(buf, User[playerid][USER_PASSWORD], false))
            {
                new Query[75], DBResult: Result;
                format(Query, sizeof(Query), "SELECT * FROM users WHERE username = '%s' LIMIT 0, 1", DB_Escape(User[playerid][USER_NAME]));
                Result = db_query(Database, Query);
                if(db_num_rows(Result))
                {
                    db_get_field_assoc(Result, "userid", Query, 7);
                    User[playerid][USER_ID] = strval(Query);

                    db_get_field_assoc(Result, "admin", Query, 3);
                    User[playerid][USER_ADMIN] = strval(Query);

                    db_get_field_assoc(Result, "vip", Query, 3);
                    User[playerid][USER_VIP] = strval(Query);

                    db_get_field_assoc(Result, "money", Query, 10);
                    User[playerid][USER_MONEY] = strval(Query);

                    db_get_field_assoc(Result, "score", Query, 7);
                    User[playerid][USER_SCORE] = strval(Query);

                    db_get_field_assoc(Result, "kills", Query, 10);
                    User[playerid][USER_KILLS] = strval(Query);

                    db_get_field_assoc(Result, "deaths", Query, 10);
                    User[playerid][USER_DEATHS] = strval(Query);

                    db_get_field_assoc(Result, "kd", Query, 10);
                    User[playerid][USER_KD] = strval(Query);

                    User[playerid][USER_LOGGED_IN] = true;

                    GivePlayerMoney(playerid, User[playerid][USER_MONEY]);
                    SetPlayerScore(playerid, User[playerid][USER_SCORE]);

                    SendClientMessage(playerid, 0x00FF00FF, ""chat" "COL_LIGHTBLUE"You have successfully logged in to your account!");
                }
                db_free_result(Result);
            }
            else
            {
                SendClientMessage(playerid, -1, ""chat" "COL_RED"Incorrect password!");
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Login pannel", ""chat" Please login to play on "COL_BLUE"Survival Games Zombie Mode\n"COL_WHITE"Enter your "COL_BLUE"password"COL_WHITE":", "Login", "Exit");

            }
        }
        else Kick(playerid);
        return 1;
    }
    if(dialogid == 1)
    {
        if(response)
        {
            if(!IsValidPassword(inputtext))
            {
                SendClientMessage(playerid, -1, ""chat" "COL_RED"The password is invalid, Valid characters are: A-Z, a-z, 0-9");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SERVER NAME"COL_WHITE" Register pannel", ""chat" Please register to play on "COL_BLUE"SERVER NAME\n"COL_WHITE"Enter a "COL_BLUE"password"COL_WHITE":", "Register", "Exit");
                return 1;
            }
            if(strlen(inputtext) < 3 || strlen(inputtext) > 24)
            {
                SendClientMessage(playerid, -1, ""chat" "COL_RED"The password is invalid, Its lenght should be 3-24 characters");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SERVER NAME"COL_WHITE" Register pannel", ""chat" Please register to play on "COL_BLUE"SERVER NAME\n"COL_WHITE"Enter a "COL_BLUE"password"COL_WHITE":", "Register", "Exit");
                return 1;
            }
            new Query[208];
            WP_Hash(User[playerid][USER_PASSWORD], 129, inputtext);
            format(Query, sizeof(Query), "INSERT INTO users (username, password) VALUES ('%s', '%s')", DB_Escape(User[playerid][USER_NAME]), DB_Escape(User[playerid][USER_PASSWORD]));
            db_query(Database, Query);

            User[playerid][USER_LOGGED_IN] = true;
            SendClientMessage(playerid, 0x00FF00FF, ""chat" "COL_LIGHTBLUE"You have just registered to our server! You have been automatically logged in!");
        }
        else Kick(playerid);
        return 1;
    }
    return 1;
}
/*           * * * * STOCKS * * * *                */
/*          * * * * DB ESCAPE * * * *              */
stock DB_Escape(text[])
{
    new ret[ 80 * 2 ], ch, i, j;
    while((ch = text[i++]) && j < sizeof(ret))
    {
        if(ch == '\'')
        {
            if(j < sizeof(ret) - 2)
            {
                ret[j++] = '\'';
                ret[j++] = '\'';
            }
        }
        else if(j < sizeof(ret))
        {
            ret[j++] = ch;
        }
        else
        {
            j++;
        }
    }
    ret[sizeof(ret) - 1] = '\0';
    return ret;
}

stock IsValidPassword(const password[])
{
    for(new i = 0; password[i] != EOS; ++i)
    {
        switch(password[i])
        {
            case '0'..'9', 'A'..'Z', 'a'..'z': continue;
            default: return 0;
        }
    }
    return 1;
}
Reply
#3

Have you tried to put the SQL_HOST as localhost or 127.0.0.1, If it's uploaded directly over to a FTP Server, it could then be a localhost or 127.. Go ahead and try both of those, and see if it changes anything
Reply
#4

This is my Server.cfg

Код:
echo Executing Server Config...
lanmode 0
rcon_password **********
maxplayers 30
port 7777
hostname The Land Of The Dead v1.1 [0.3z]
gamemode0 Dayz
filterscripts dayz
announce 1
query 1
chatlogging 0
plugins streamer.so sscanf.so mysql.so
weburl www.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat [%H:%M:%S]
lagcomp true
Reply
#5

yes its already in the FTP and this is my ip server 198.100.144.190:2502 when i connect and i click play its making stuck. and i dont know what is the problem
Reply
#6

[/URL]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)