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[5] = "baza";
- static const PRAZNO_IME[7] = "Prazno";
- static const PRAZNA_PORUKA[7] = "Prazno";
- new MySQL: SQL;
- new poruka[128];
- new ime[24];
- public OnFilterScriptInit() {
- Konekcija();
- SetTimer("UcitajPoruku", 1000, 1);
- return true;
- }
- public OnFilterScriptExit() {
- mysql_close(SQL);
- return true;
- }
- Konekcija() {
- SQL = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
- if (mysql_errno() != 0) { print("Nije se moguce konektovati na databazu."); return 0; }
- mysql_log(ALL);
- return true;
- }
- forward public UcitajPoruku();
- public UcitajPoruku() {
- static q[128], Cache:result;
- mysql_format(SQL, q, sizeof(q), "select * from test where sqlid= '1' LIMIT 1");
- result = mysql_query(SQL, q);
- if(cache_num_rows())
- {
- cache_get_value_name(0, "poruka", poruka, 128);
- cache_get_value_name(0, "ime", ime, 24);
- if(strcmp(ime, PRAZNO_IME, true) == 0 || strcmp(poruka, PRAZNA_PORUKA, true) == 0) return 0;
- else {
- static string[128];
- format(string, sizeof(string), "[SEREVER WEB PORUKA] %s kaze %s", ime, poruka);
- SendClientMessageToAll(0xFFFFFF, string);
- static query[128];
- mysql_format(SQL, query, sizeof(query), "update test set poruka= '%s', ime= '%s' WHERE sqlid= '1'",
- PRAZNA_PORUKA, PRAZNO_IME);
- mysql_tquery(SQL, query);
- }
- } else return 0;
- cache_delete(result);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment