Hello there,
I started scripted a register/ login system from scratch using MySQL R41-2. This is the first time that I've done MySQL based work from scratch and with least to none help from others. However, I've a few problems with some queries and thought of creating a thread, even after I don't like to create one :p
Problem: Query not being called?
Status: UNSOLVED
Code:
OnPlayerConnect
OnBanCheck
+ My Sublime Text 3 doesn't show the 'updated' natives from includes such as MySQL r41 and Streamer 2.9+.
Thanks.
I started scripted a register/ login system from scratch using MySQL R41-2. This is the first time that I've done MySQL based work from scratch and with least to none help from others. However, I've a few problems with some queries and thought of creating a thread, even after I don't like to create one :p
Problem: Query not being called?
Status: UNSOLVED
Code:
OnPlayerConnect
PHP Code:
new query[95];
mysql_format(gSQL, query, sizeof query, "SELECT * FROM `Bans` WHERE `Name` = %e OR `IP` = %e LIMIT 1", pName(playerid), IP);
mysql_tquery(gSQL, query, "OnBanCheck", "i", playerid);
PHP Code:
forward OnBanCheck(playerid);
public OnBanCheck(playerid)
{
if(cache_num_rows() >= 1)
{
new By[MAX_PLAYER_NAME], Reason[50], Name[MAX_PLAYER_NAME], str[130], ID, ExpireDate;
cache_get_value_int(0, "ID", ID);
cache_get_value_int(0, "ExpireDate", ExpireDate);
cache_get_value_name(0, "BanBy", By);
cache_get_value_name(0, "Name", Name);
cache_get_value_name(0, "Reason", Reason);
format(str, sizeof str, "* Account name: %s | Ban ID: %d | Expire date: %s | Banned by: %s", Name, ID, (ExpireDate == 0) ? ("Permanent") : (ReturnDate(ExpireDate)), By);
SendClientMessage(playerid, COLOR_RED, str);
if(ExpireDate >= 1 && ExpireDate < gettime())
{
new query[65], IP[16];
cache_get_value_name(0, "IP", IP);
SendClientMessage(playerid, COLOR_RED, "* Your account is now unbanned.");
mysql_format(gSQL, query, sizeof query, "REMOVE * FROM `Bans` WHERE `Name` = %e OR `IP` = %e", pName(playerid), IP);
mysql_tquery(gSQL, query);
}
}
else
{
new query[65];
mysql_format(gSQL, query, sizeof query, "SELECT * FROM `Users` WHERE `Name`= %e LIMIT 1", pName(playerid));
mysql_tquery(gSQL, query, "OnAccountCheck", "d", playerid);
}
return 1;
}
Thanks.