28.10.2017, 18:57
pawn Код:
new MySQL:database;
pawn Код:
public OnGameModeInit()
{
database = mysql_connect(MYSQL_HOSt, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE);
print("Database succesfully loaded");
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new query[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
mysql_format(database, query, sizeof(query), "SELECT * FROM players WHERE username = '%s' , pname);
new Cache:result = mysql_query(database, query);
if(cache_get_num_rows(result));
{
// login
}
else
{
//register
}
cache_delete(result);
return 1;
}