SA-MP Forums Archive
MYSQL Problem AMX. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL Problem AMX. (/showthread.php?tid=327769)



MYSQL Problem AMX. - RicaNiel - 22.03.2012

Guys i have problem you see i only make this mysql script but problem is it wont load the amx.
bdw here is my code

pawn Код:
#include    <a_samp>
#include    <a_mysql>
#include    <sscanf2>

#define     DB_HOST         "LocalHost"
#define     DB_USER         "root"
#define     DB_BASE         "test"
#define     DB_PASSWORD     ""

#define     D_REGISTER      1
#define     D_LOGIN         2

#define     CWHITE         "{FFFFFF}"
#define     CRED           "{ARWRWR}"
#define     C_SERVER        0xFFF255AA

#define     PASSWORD        DIALOG_STYLE_PASSWORD
#define     INPUT           DIALOG_STYLE_INPUT

enum pFile
{
    pUserName[34],
    pPassWord[34],
    pScore,
    pMoney,
    pAdmin
}
new pI[MAX_PLAYERS][pFile];

main()
{
    print("\n----------------------------------");
    print(" RicaNiel Property ");
    print("----------------------------------\n");
}

stock playername(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    return pName;
}

public OnGameModeInit()
{
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    mysql_debug(1);
    mysql_connect(DB_HOST,DB_USER,DB_BASE,DB_PASSWORD);

    return 1;
}

public OnGameModeExit()
{
    mysql_debug(0);
    mysql_close();
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new data[100],string[500];
    format(data,sizeof(data),"SELECT `test` FROM `User` WHERE `Username`='%s'",playername(playerid));
    mysql_query(data);
    if(mysql_num_rows()>0)
    {
        format(string,sizeof(string),""CWHITE"This account is already Registred\n\nUser:"CRED"%s"CWHITE"\n\nPlese Enter Your Password Bellow To Login",playername(playerid));
        ShowPlayerDialog(playerid,D_LOGIN,PASSWORD,""CWHITE"RicaNiel - Login System",string,"Login","Cancel");
    }
    else
    {
        ShowPlayerDialog(playerid,D_REGISTER,INPUT,""CWHITE"RicaNiel - Register System","That account is not registred\n\nPlease Type a password to register an account","Login","Cancel");
    }
    mysql_free_result();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case D_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(strlen(inputtext) == 0)  return ShowPlayerDialog(playerid,D_REGISTER,INPUT,""CWHITE"RicaNiel - Register System","That account is not registred\n\nPlease Type a password to register an account","Login","Cancel");
                new passwordtext[60];
                new data[100];
                mysql_real_escape_string(inputtext, passwordtext);
                format(data,sizeof(data),"INSERT INTO `Users` (Username,Password,Score,Money,Admin) VALUE ('$s','%s','0','0','0')",playername(playerid),passwordtext);
                mysql_query(data);
                SendClientMessage(playerid,C_SERVER,"SERVER:"CWHITE" You have succesfully registred a new account");
            }
        }
       
        case D_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid,D_LOGIN,PASSWORD,""CWHITE"RicaNiel - Login System","Please Enter The Account Password","Login","Cancel");
                new passwordtext[60];
                new data[100];
                mysql_real_escape_string(inputtext,passwordtext);
                format(data,sizeof(data),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",playername(playerid),passwordtext);
                mysql_query(data);
                mysql_free_result();
                if(mysql_num_rows() <0)
                {
                    new ldata[100];
                    format(ldata,sizeof(ldata),"SELECT * FROM `Users` WHERE `Username` = '%s' ",playername(playerid));
                    mysql_query(ldata);
                    mysql_store_result();
                    mysql_fetch_row_format(ldata,"|");
                    sscanf(ldata,"e<p<|>s[24]s[23]i>",pI[playerid]);
                    mysql_free_result();
                    GivePlayerMoney(playerid,pI[playerid][pMoney]);
                }
                else
                {
                    ShowPlayerDialog(playerid,D_LOGIN,PASSWORD,""CWHITE"RicaNiel - Login System","Please Enter The "CRED"CORREECT"CWHITE" Account Password","Login","Cancel");
                }
                mysql_free_result();
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

and here is my problem

Код:
SA-MP Dedicated Server
----------------------
v0.3d-R2, ©2005-2011 SA-MP Team

[22:20:16] filterscripts = ""  (string)
[22:20:16] 
[22:20:16] Server Plugins
[22:20:16] --------------
[22:20:16]  Loaded 0 plugins.

[22:20:16] 
[22:20:16] Filterscripts
[22:20:16] ---------------
[22:20:16]   Loaded 0 filterscripts.

[22:20:16] Script[gamemodes/dan.amx]: Run time error 19: "File or function is not found"
[22:20:16] Number of vehicle models: 0



Re: MYSQL Problem AMX. - SuperViper - 22.03.2012

You need the MySQL plugin and you need to add a plugins line to server.cfg:

pawn Код:
plugins mysql
for Windows

pawn Код:
plugins mysql.so
for Linux


Re: MYSQL Problem AMX. - Bogdan1992 - 22.03.2012

Btw use this.
pawn Код:
public OnPlayerConnect(playerid)
{
    new data[100],string[500];
    format(data,sizeof(data),"SELECT * FROM `User` WHERE `Username` = '%s' LIMIT 1", playername(playerid));
    mysql_query(data);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(rows == 1){
        format(string,sizeof(string),""CWHITE"This account is already Registred\n\nUser:"CRED"%s"CWHITE"\n\nPlese Enter Your Password Bellow To Login",playername(playerid));
        ShowPlayerDialog(playerid,D_LOGIN,PASSWORD,""CWHITE"RicaNiel - Login System",string,"Login","Cancel");
    }else{
        ShowPlayerDialog(playerid,D_REGISTER,INPUT,""CWHITE"RicaNiel - Register System","That account is not registred\n\nPlease Type a password to register an account","Login","Cancel");
    }
    mysql_free_result();
    return 1;
}



Re: MYSQL Problem AMX. - RicaNiel - 22.03.2012

Quote:
Originally Posted by Bogdan1992
Посмотреть сообщение
Btw use this.
pawn Код:
public OnPlayerConnect(playerid)
{
    new data[100],string[500];
    format(data,sizeof(data),"SELECT * FROM `User` WHERE `Username` = '%s' LIMIT 1", playername(playerid));
    mysql_query(data);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(rows == 1){
        format(string,sizeof(string),""CWHITE"This account is already Registred\n\nUser:"CRED"%s"CWHITE"\n\nPlese Enter Your Password Bellow To Login",playername(playerid));
        ShowPlayerDialog(playerid,D_LOGIN,PASSWORD,""CWHITE"RicaNiel - Login System",string,"Login","Cancel");
    }else{
        ShowPlayerDialog(playerid,D_REGISTER,INPUT,""CWHITE"RicaNiel - Register System","That account is not registred\n\nPlease Type a password to register an account","Login","Cancel");
    }
    mysql_free_result();
    return 1;
}
What is that?


Quote:

You need the MySQL plugin and you need to add a plugins line to server.cfg:

i already did but still same thing


Re: MYSQL Problem AMX. - Bogdan1992 - 22.03.2012

I've modified your code just little bit, its should be much better now. anyway what problem do u use for database? wamp?


Re: MYSQL Problem AMX. - TheArcher - 22.03.2012

Are you sure you have no errors in the compiler?


Re: MYSQL Problem AMX. - RicaNiel - 22.03.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Are you sure you have no errors in the compiler?
yes no errors

[img][/img]


AW: MYSQL Problem AMX. - Tigerkiller - 22.03.2012

you use a plugin which isnt compatible with the mysql.inc

if you use BlueGs mysql plugin, use R6!


Re: MYSQL Problem AMX. - RicaNiel - 22.03.2012

Quote:

you use a plugin which isnt compatible with the mysql.inc

if you use BlueGs mysql plugin, use R6!

yes i am using now the R6 fr0m R7

but still same btw i will give my whole file


Re: MYSQL Problem AMX. - RicaNiel - 22.03.2012

here it is

here