Hello! How do I check which one to check if the account exists in the database?
PHP код:
mysql_format(mysql, szQuery, 128, "SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1;", banname);
mysql_query(mysql, szQuery);
if(cache_get_row_count(mysql) > 0)
{
SendClientMessage(playerid, COLOR_GENERAL2, "Acest cont (%s) nu exsista in baza de date.", banname);
return 1;
}
but does not work.
pawn Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1;", banname);
new Cache:result = mysql_query(mysql, query);
if(cache_get_row_count() > 0)
{
//if the user exists in database
}
else {
//If it doesnt exists
}
cache_delete(result);
ban offline command.
PHP код:
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new tmp2[64];
while ((idx < length) && ((idx - offset) < (sizeof(tmp2) - 1)))
{
tmp2[idx - offset] = cmdtext[idx];
idx++;
}
tmp2[idx - offset] = EOS;
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_SERVER, "Foloseste: {FFFFFF}/ban [playerid] [motiv]");
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_SERVER, "Foloseste: {FFFFFF}/ban [playerid] [motiv]");
new name[256];
mysql_format(mysql, szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1;", name);
new Cache:ez = mysql_query(mysql, szQuery);
if(cache_get_row_count() > 0)
{
format(szQuery, sizeof(szQuery),"UPDATE `users` SET `Banned` = '1' WHERE `Name` = '%s'", giveplayer);
mysql_tquery(mysql, szQuery, "" , "" );
if(PlayerInfo[playerid][pLanguage] == 1) { format(string, sizeof(string), "%s(offline) a primit ban de la adminul %s, motiv: %s.", name, sendername, (result)); }
else if(PlayerInfo[playerid][pLanguage] == 2) { format(string, sizeof(string), "%s(offline) was banned from admin %s, reason: %s.", name, sendername, (result)); }
SendClientMessageToAll(COLOR_CMD, string);
}
else
{
SendClientMessage(playerid, COLOR_GENERAL2, "Acest cont (%s) nu exista in baza de date.", name);
}
cache_delete(ez);
Use strcmp.