28.08.2014, 06:06
So, I finally created a searchban command, but I can't get the "like" to work, or some other stuff :l
Here's the code;
It does show me the result if I fully type the name, but It doesn't show me the next results.
Example;
I ban "Train" and "Train_Super"
If I type /searchban Train, It will only show me the result for "Train", but not "Train_Super".
I've used LIKE '%%s%", but then it didn't work at all d:
Here's the code;
pawn Код:
CMD:searchban(playerid, params[]) {
new Query[240], string[128], NameOrIP[40], DBResult:Result;
if(!PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid, COLOR_ORANGE, "NOTE: You need to be an admin!");
if(sscanf(params, "s[40]", NameOrIP)) return SendClientMessage(playerid, COLOR_NOTES, "USAGE: /searchban PLAYERNAME/PLAYERIP");
format(Query, sizeof(Query), "SELECT * FROM `BANNED` WHERE `NAME` LIKE '%s' OR `IP` LIKE '%s' ORDER BY `DATE` DESC LIMIT 6", NameOrIP, NameOrIP);
Result = db_query(HDF, Query);
if(db_num_rows(Result))
{
new BannedBy[24], BannedName[24], BannedIP[24], BannedReason[50];
do
{
db_get_field_assoc(Result, "NAME", BannedName, sizeof(BannedName));
db_get_field_assoc(Result, "IP", BannedIP, sizeof(BannedIP));
db_get_field_assoc(Result, "ADMIN", BannedBy, sizeof(BannedBy));
db_get_field_assoc(Result, "REASON", BannedReason, sizeof(BannedReason));
format(string, sizeof(string), "- %s(IP: %s) - banned by %s - due to %s", BannedName, BannedIP, BannedBy, BannedReason);
SendClientMessage(playerid, COLOR_NOTES2, string);
}
}
else SendClientMessage(playerid, COLOR_ORANGE, "NOTE: No bans found!");
db_free_result(Result); string = "\0", Query = "\0", NameOrIP = "\0";
return 1;
}
Example;
I ban "Train" and "Train_Super"
If I type /searchban Train, It will only show me the result for "Train", but not "Train_Super".
I've used LIKE '%%s%", but then it didn't work at all d: