MySQL problem
#1

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!
Reply
#2

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.
Reply
#3

THANKS, YOU KIND SIR!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)