SA-MP Forums Archive
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)
+--- Thread: MySQL problem (/showthread.php?tid=396523)



MySQL problem - CONTROLA - 01.12.2012

pawn Код:
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
   
new qstr[100];
format(qstr,100,"SELECT * FROM `players` WHERE `username`='%s';",plname);
mysql_function_query(g_Handle, qstr, true, "OnPlayerCheckAccount", "s", playerid);
return 1;


forward OnPlayerCheckAccount(playerid);
public OnPlayerCheckAccount(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You're registered!");
        printf("Este inregistrat!");
        gPlayerAccount[playerid] = 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "You're not registered!");
        gPlayerAccount[playerid] = 0;
    }
}
I'm using this code(at OnPlayerConnect) but I'm getting this error from crashdetect when connecting:

pawn Код:
[11:52:17]: Script[gamemodes/redzmaxr7.amx]: During execution of OnPlayerCheckAccount():
[11:52:17]: Script[gamemodes/redzmaxr7.amx]: Run time error 4: "Array index out of bounds"
[11:52:17]: Additional information:
[11:52:17]:   Array max index is 250 but accessing an element at 35441308
[11:52:17]: Call stack (most recent call first):
[11:52:17]:   public OnPlayerCheckAccount()
Please, please help me!


Re: MySQL problem - CoDeZ - 01.12.2012

pawn Код:
new qstr[200];
format(qstr,200,"SELECT * FROM `players` WHERE `username`='%s';",plname);
mysql_function_query(g_Handle, qstr, true, "OnPlayerCheckAccount", "i", playerid);
return 1;
player id is an integer so it needs the integer place holder also increase your query string size.


Re: MySQL problem - CONTROLA - 01.12.2012

THANKS, YOU KIND SIR!!!