31.10.2014, 11:02
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_format
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_pquery
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_get_row_int
A little example[Not totally sure if this is correct or not, I don't script PAWN for ages]
By the way, change the "COUNT(*)" for "COUNT(<primary key>)"
I hope this helps you out!
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_pquery
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_get_row_int
A little example[Not totally sure if this is correct or not, I don't script PAWN for ages]
pawn Код:
forward Query_IPBanned();
stock CheckBan(ban[]) {
new query[128], ip[16]; // IPV4 max size is 15 chars, so 16chars with the null('\0') in the end, IPV6 is not supported yet on SA-MP
mysql_real_escape_string(ban, ip);
mysql_format(connection_handle, query, 128, "SELECT COUNT(*) FROM `bans` WHERE `IP` = '%s'", ip);
mysql_pquery(connection_handle, query, "Query_IPBanned");
}
public Query_IPBanned() {
new count = cache_get_row_int(0,0); // get the row 0, field 0, which contains the output of COUNT.
if(count >= 1) {
// ip banned
} else {
// ip not banned
}
}
I hope this helps you out!