03.11.2014, 12:25
I'm having some problems with my do-while loop..
I dunno how to explain it, but, It should do a loop trough the DB until a "free name" is found, but when a "free name" IS found, nothing happens D:
Code;
Yeah, I bet it's because of some brackets/doing stuff outside the do-while, but I'm new to this loop thing so I dunno how it exactly works ;_;
I dunno how to explain it, but, It should do a loop trough the DB until a "free name" is found, but when a "free name" IS found, nothing happens D:
Code;
pawn Код:
//Gets shown if player fails to login 3x
case DIALOG_FAIL_LOGIN:
{
if( !response ) return SetTimerEx("KickTimer", 50, false, "i", playerid);
if( response )
{
new Query[106], name[24], string[66], character = 1, DBResult:Result;
format(name, sizeof(name), "%s_%d", GetName(playerid), character);
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s'", name);
Result = db_query(HDF, Query);
if(db_num_rows(Result))
{
do
{
character++;
format(name, sizeof(name), "%s_%d", GetName(playerid), character);
format(string, sizeof(string), "Skipping name '%s' because is in use.", name), SendClientMessage(playerid, COLOR_NOTES2, string);
}
while(db_next_row(Result));
}
else
{
format(string, sizeof(string), "Found a valid name - '%s' - setting. . .", name), SendClientMessage(playerid, COLOR_NOTES, string);
SetPlayerName(playerid, name);
SendClientMessage(playerid, COLOR_NOTES, "INFO: You will need to register now to save your stats");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{64CC66}Registration.", "{FFFFFF}Welcome to the server!\nYour name is detected as {64CC66}unregistered{FFFFFF}.\nYou are required to register to proceed playing.\n{64CC66}Enter your password below to complete the registration.", "Register", "Leave");
}
db_free_result(Result);
}
}