SA-MP Forums Archive
Little Mysql Problem :) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little Mysql Problem :) (/showthread.php?tid=106666)



Little Mysql Problem :) - mirkoiz - 04.11.2009

Hello,
i have a Problem with mysql.

i want to check if the Account name already is registred in the Database.

pawn Код:
public IsAccountRegistred(sqlplayersname[])
{
    new escstr[MAX_PLAYER_NAME];
    mysql_real_escape_string(sqlplayersname, escstr);
    format(query, sizeof(query), "SELECT Name FROM Accounts WHERE Name = '%s'", escstr);
    mysql_query(query);
    mysql_store_result();
    if (/*If nickname dosent exists in the Table*/)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
i know that i could use strmatch or something like this.. but i dunno how to solve it 100%...


wich function will help me out?

Friendly Greetings:
Cookie

Edit:
i thought about this code
pawn Код:
//TOP OF GM
new currentname[MAX_PLAYERS];
//Onplayerconnect
currentname[playerid] = plname;

// onplayerconnect after nickname check
if(currentname[playerid] == None)
{
gPlayerAccountRegistred[playerid] = 0;
}
public IsAccountRegistred(sqlplayersname[])
{
    new escstr[MAX_PLAYER_NAME];
    mysql_real_escape_string(sqlplayersname, escstr);
    format(query, sizeof(query), "SELECT Name FROM Accounts WHERE Name = '%s'", escstr);
    mysql_query(query);
    mysql_store_result();
    if ( strcmp( escstr , "None" , true ) == 0 )
    {
        currentname[playerid] = None;
    }
    else
    {
        currentname[playerid] = escstr;
    }
}

would this work to 100% or is there a better way?


Re: Little Mysql Problem :) - mirkoiz - 05.11.2009

cant someone help me?