14.10.2018, 18:50
The script is good but needs a lot of tweaks.
You're using latest MySQL plugin but not foreach, the classic for(new i = 0; i < MAX_PLAYERS; i ++).
In the account check on OnPlayerConnect you don't need LIMIT 1.
Is enough.
Also why a loop to send a connect message? Just use SendClientMessageToAll! No need to loop everytime someone connects.
This:
Can be reduced to:
For timers, use y_timers instead of default SetTimer.
/ahelp can be reduced up to 30% of lines too.
Also you're using Whirlpool without salting the passwords. Use SALT and SHA-256 to encrypt them. Better for you and better for the security of who'll use this system
Basically, this is a good system, but as said already, needs a lot of tweaks.
Good job tho.
You're using latest MySQL plugin but not foreach, the classic for(new i = 0; i < MAX_PLAYERS; i ++).
In the account check on OnPlayerConnect you don't need LIMIT 1.
pawn Code:
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
Also why a loop to send a connect message? Just use SendClientMessageToAll! No need to loop everytime someone connects.
This:
pawn Code:
public OnPlayerConnect(playerid)
{
new query[140], string[50];
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e' LIMIT 0, 1", GetName(playerid));
mysql_tquery(db, query, "CheckPlayer", "i", playerid);
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i)) continue;
if (PlayerInfo[i][pAdmin] != 0) {
format(string, sizeof(string), "* %s (%d) has connected. Country: %s", GetName(playerid), playerid, GetPlayerCountry(playerid));
}
else
{
format(string, sizeof(string), "* %s (%d) has connected.", GetName(playerid), playerid);
}
SendClientMessage(i, COLOR_GRAY, string);
}
if(TAdmin_Debug == true)
{
printf("[%s - Debug]: Player %s (%d) from %s, %s with IP %s connected. - OnPlayerConnect", SYSTEMNAME, GetName(playerid), playerid, GetPlayerCity(playerid), GetPlayerCountry(playerid), returnIP(playerid));
}
ResetPlayerVariables(playerid);
TogglePlayerClock(playerid, 1);
return 1;
}
pawn Code:
public OnPlayerConnect(playerid)
{
new query[140], string[100];
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
mysql_tquery(db, query, "CheckPlayer", "i", playerid);
format(string, sizeof(string), "* %s (%d) has connected. Country: %s", GetName(playerid), playerid, GetPlayerCountry(playerid));
SendAdminMessage(COLOR_ADMINMSG, string);
format(string, sizeof(string), "* %s (%d) has connected.", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_GRAY, string);
if(TAdmin_Debug == true) printf("[%s - Debug]: Player %s (%d) from %s, %s with IP %s connected. - OnPlayerConnect", SYSTEMNAME, GetName(playerid), playerid, GetPlayerCity(playerid), GetPlayerCountry(playerid), returnIP(playerid));
ResetPlayerVariables(playerid); TogglePlayerClock(playerid, 1);
return 1;
}
/ahelp can be reduced up to 30% of lines too.
Also you're using Whirlpool without salting the passwords. Use SALT and SHA-256 to encrypt them. Better for you and better for the security of who'll use this system
Basically, this is a good system, but as said already, needs a lot of tweaks.
Good job tho.