Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- static const SQL_HOST[10] = "localhost";
- static const SQL_USER[5] = "root";
- static const SQL_PASS[1] = "";
- static const SQL_DB[6] = "testt";
- enum PI { rekord, online }
- new PortalInfo[PI];
- new MySQL:sql;
- public OnFilterScriptInit() {
- sql = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
- if(mysql_errno(sql) != 0 || sql == MYSQL_INVALID_HANDLE) {
- print("Konekcija sa databazom nije uspesna.");
- SendRconCommand("exit");
- return true; }
- mysql_tquery(sql, "SELECT * FROM `test`", "UcitajRekord");
- return true;
- }
- public OnFilterScriptExit() {
- mysql_close(sql);
- return true;
- }
- public OnPlayerConnect(playerid) {
- PortalInfo[online] ++;
- static query[128];
- mysql_format(sql, query, sizeof(query), "UPDATE `test`\
- SET `online`='%d'\
- WHERE `sqlid`= '1'", PortalInfo[online]);
- mysql_tquery(sql, query);
- RekordProvera();
- return true;
- }
- public OnPlayerDisconnect(playerid, reason) {
- PortalInfo[online] --;
- static query[128];
- mysql_format(sql, query, sizeof(query), "UPDATE `test`\
- SET `online`='%d'\
- WHERE `sqlid`= '1'", PortalInfo[online]);
- mysql_tquery(sql, query);
- return true;
- }
- forward public UcitajRekord();
- public UcitajRekord() { if(cache_num_rows() > 0) { cache_get_value_int(0, "rekord", PortalInfo[rekord]); } }
- static stock RekordProvera() {
- if(PortalInfo[rekord] < PortalInfo[online]) {
- PortalInfo[rekord] = PortalInfo[online];
- static query[128];
- mysql_format(sql, query, sizeof(query), "UPDATE `test`\
- SET `rekord`='%d'\
- WHERE `sqlid`= '1'", PortalInfo[online]);
- mysql_tquery(sql, query);
- return true; }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement