SHARE
TWEET

Untitled

a guest Oct 16th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <mysql>
  4. #include <zcmd>
  5. #include <sscanf2>
  6. #include <data>
  7.  
  8. #define mysql_host "localhost" //your destination server
  9. #define mysql_user "root" //default user name of wampserver
  10. #define mysql_password "" //wampserver has no default password unless you have set one.
  11. #define mysql_database "sa-mpsql"//the name of your database
  12. new MySQL:mysql;
  13. new field[128];
  14.  
  15. #define mysql_fetch_float(%0,%1) mysql_fetch_field(%0,field); \
  16. %1=floatstr(field)
  17. #define mysql_fetch_string(%0,%1) mysql_fetch_field(%0,%1)
  18. #define mysql_fetch_int(%0,%1) mysql_fetch_field(%0,field); \
  19. %1=strval(field)
  20. enum PlayerInfo
  21. {
  22.     ID,
  23.     Nick[24],
  24.     pAdmin,
  25.     pMoney,
  26.     pKills,
  27.     pDeaths,
  28.     pScore,
  29.     IP[16],
  30.     Logged,
  31.     IsRegistered
  32. };
  33. new pInfo[MAX_PLAYERS][PlayerInfo];
  34.  
  35. #define MAX_ADMIN_LEVEL 7
  36. #define SETLEVEL_ADMIN 5
  37. #define SETKILLS_ADMIN 4
  38. public OnGameModeInit()
  39. {
  40.     mysql = mysql_init(LOG_ALL);
  41.     new Connection = mysql_connect(mysql_host, mysql_user, mysql_password, mysql_database, mysql);
  42.     if(Connection)
  43.     {
  44.         new dest[200];
  45.         mysql_stat(dest);
  46.         printf(dest);
  47.         printf(">> MySQL uspesno bese startan <<");
  48.     }
  49.     return 1;
  50. }
  51.  
  52. public OnGameModeExit()
  53. {
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59.     new Query[500];
  60.     GetPlayerName(playerid, pInfo[playerid][Nick], 24);
  61.     GetPlayerIp(playerid, pInfo[playerid][IP], 16);
  62.     mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]);
  63.     format(Query, 500, "SELECT `nick` FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
  64.     mysql_query(Query);
  65.     mysql_store_result();
  66.     if(mysql_num_rows() > 0)
  67.     {
  68.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login", "Akauntot e vekje kreiran\nVnesete ja vasata lozinka za da se pustite na serverot!", "Login", "");
  69.     }
  70.     else
  71.     {
  72.         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Register", "Akauntot ne e registriran\nVnesete ja vasata lozinka za da se registrirate!", "Register", "");
  73.     }
  74.     mysql_free_result();
  75.     return 1;
  76. }
  77.  
  78. public OnPlayerDisconnect(playerid, reason)
  79. {
  80.     SavePlayer(playerid);
  81.     return 1;
  82. }
  83.  
  84. public OnPlayerSpawn(playerid)
  85. {
  86.     return 1;
  87. }
  88.  
  89. public OnPlayerDeath(playerid, killerid, reason)
  90. {
  91.     return 1;
  92. }
  93.  
  94. public OnVehicleSpawn(vehicleid)
  95. {
  96.     return 1;
  97. }
  98.  
  99. public OnVehicleDeath(vehicleid, killerid)
  100. {
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerText(playerid, text[])
  105. {
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerCommandText(playerid, cmdtext[])
  110. {
  111.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  112.     {
  113.         // Do something here
  114.         return 1;
  115.     }
  116.     return 0;
  117. }
  118.  
  119. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  120. {
  121.     return 1;
  122. }
  123.  
  124. public OnPlayerExitVehicle(playerid, vehicleid)
  125. {
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerStateChange(playerid, newstate, oldstate)
  130. {
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerEnterCheckpoint(playerid)
  135. {
  136.     return 1;
  137. }
  138.  
  139. public OnPlayerLeaveCheckpoint(playerid)
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerEnterRaceCheckpoint(playerid)
  145. {
  146.     return 1;
  147. }
  148.  
  149. public OnPlayerLeaveRaceCheckpoint(playerid)
  150. {
  151.     return 1;
  152. }
  153.  
  154. public OnRconCommand(cmd[])
  155. {
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerRequestSpawn(playerid)
  160. {
  161.     return 1;
  162. }
  163.  
  164. public OnObjectMoved(objectid)
  165. {
  166.     return 1;
  167. }
  168.  
  169. public OnPlayerObjectMoved(playerid, objectid)
  170. {
  171.     return 1;
  172. }
  173.  
  174. public OnPlayerPickUpPickup(playerid, pickupid)
  175. {
  176.     return 1;
  177. }
  178.  
  179. public OnVehicleMod(playerid, vehicleid, componentid)
  180. {
  181.     return 1;
  182. }
  183.  
  184. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  185. {
  186.     return 1;
  187. }
  188.  
  189. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  190. {
  191.     return 1;
  192. }
  193.  
  194. public OnPlayerSelectedMenuRow(playerid, row)
  195. {
  196.     return 1;
  197. }
  198.  
  199. public OnPlayerExitedMenu(playerid)
  200. {
  201.     return 1;
  202. }
  203.  
  204. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  205. {
  206.     return 1;
  207. }
  208.  
  209. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  210. {
  211.     return 1;
  212. }
  213.  
  214. public OnRconLoginAttempt(ip[], password[], success)
  215. {
  216.     return 1;
  217. }
  218.  
  219. public OnPlayerUpdate(playerid)
  220. {
  221.     return 1;
  222. }
  223.  
  224. public OnPlayerStreamIn(playerid, forplayerid)
  225. {
  226.     return 1;
  227. }
  228.  
  229. public OnPlayerStreamOut(playerid, forplayerid)
  230. {
  231.     return 1;
  232. }
  233.  
  234. public OnVehicleStreamIn(vehicleid, forplayerid)
  235. {
  236.     return 1;
  237. }
  238.  
  239. public OnVehicleStreamOut(vehicleid, forplayerid)
  240. {
  241.     return 1;
  242. }
  243.  
  244. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  245. {
  246.     if(dialogid == 2)
  247.     {
  248.         if(response)
  249.         {
  250.             if(!strlen(inputtext) || strlen(inputtext) > 68)
  251.             {
  252.                 SendClientMessage(playerid, 0xFF0000, "Vasata lozinka mora da bide pod 68 i nad 1 karakter!");
  253.                         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Register", "Akauntot ne e registriran\nVnesete ja vasata lozinka za da se registrirate!", "Register", "");
  254.             }
  255.             else if(strlen(inputtext) > 0 && strlen(inputtext) < 68)
  256.             {
  257.                 new escpass[100];
  258.                 mysql_real_escape_string(inputtext, escpass);
  259.                 MySQL_Register(playerid, escpass);
  260.             }
  261.         }
  262.         if(!response)
  263.         {
  264.             SendClientMessage(playerid, 0xFF0000, "Prvo registracija pa potoa login!!!");
  265.             ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Register", "Akauntot ne e registriran\nVnesete ja vasata lozinka za da se registrirate!", "Register", "");
  266.         }
  267.     }
  268.     if(dialogid == 1)
  269.     {
  270.         if(!response)
  271.         {
  272.                 SendClientMessage(playerid, 0xFF0000, "Mora da se logirate pred spawn!!"); // OVA TUKA VIE ANTIBOT, AKO SAKATE BOTOVI IZBIRSETE GO :P
  273.                 Kick(playerid);
  274.         }
  275.         if(response) //If the player clicked login
  276.         {
  277.             if(!strlen(inputtext) || strlen(inputtext) > 68)
  278.             {
  279.                 SendClientMessage(playerid, 0xFF0000, "Passwordot mora da bide nad 1 karakter i pod 68 !!");
  280.                 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login","Vnesete lozina za da se logirate na serverot!","Login","Izlez");
  281.                 return 1;
  282.             }
  283.             new Query[400];
  284.             mysql_real_escape_string(inputtext, inputtext);
  285.             mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]);
  286.             format(Query, 400, "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' AND `password` = '%d'", pInfo[playerid][Nick], udb_hash(inputtext)); // now here check the database if the player has given the proper password.HTTP
  287.             mysql_query(Query);
  288.             mysql_store_result();
  289.             if(mysql_num_rows() > 0) {
  290.                 MySQL_Login(playerid);
  291.             } else {
  292.                 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login","Vnesete lozina za da se logirate na serverot!","Login","Izlez");
  293.             }
  294.             mysql_free_result();
  295.         }
  296.     }
  297.     return 1;
  298. }
  299.  
  300. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  301. {
  302.     return 1;
  303. }
  304. stock MySQL_Register(playerid, passwordstring[])
  305. {
  306.     new Query[300];
  307.     mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]);
  308.     mysql_real_escape_string(pInfo[playerid][IP], pInfo[playerid][IP]);
  309.     format(Query, sizeof(Query), "INSERT INTO `playerdata` (`nick`, `password`, `ip`) VALUES('%s', '%d', '0', '0', '%s')", pInfo[playerid][Nick], udb_hash(passwordstring), pInfo[playerid][IP]);
  310.     mysql_query(Query);
  311.     SendClientMessage(playerid, -1, "Zdravo %s dobredojdovte na MYSQL Gamemode v1",pInfo[playerid]Nick);
  312.     pInfo[playerid][Logged] = 1;
  313.     pInfo[playerid][IsRegistered] = 1;
  314.     return 1;
  315. }
  316.  
  317. stock MySQL_Login(playerid)
  318. {
  319.     new Query[500];
  320.     mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]);
  321.     format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]);
  322.     mysql_query(Query);
  323.     mysql_store_result();
  324.     while(mysql_fetch_row(Query))
  325.     {
  326.         mysql_fetch_int("id", pInfo[playerid][ID]);
  327.         mysql_fetch_int("admin", pInfo[playerid][pAdmin]);
  328.         mysql_fetch_int("score", pInfo[playerid][pScore]); SetPlayerScore(playerid, pInfo[playerid][pScore]);
  329.         mysql_fetch_int("money", pInfo[playerid][pMoney]); GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
  330.         mysql_fetch_int("kills", pInfo[playerid][pKills]);
  331.         mysql_fetch_int("deaths", pInfo[playerid][pDeaths]);
  332.     }
  333.     mysql_free_result();
  334.     pInfo[playerid][Logged] = 1;
  335.     return 1;
  336. }
  337. SavePlayer(playerid)
  338. {
  339.     if(pInfo[playerid][Logged] == 1)
  340.     {
  341.         new Query[500];
  342.         format(Query, 500, "UPDATE `playerdata` SET `admin` = '%d', `score` = '%d', `money` = '%d', `kills` = '%d', `deaths` = '%d' WHERE `id` = '%d' LIMIT 1",
  343.         pInfo[playerid][pAdmin],
  344.         pInfo[playerid][pScore],
  345.         pInfo[playerid][pMoney],
  346.         pInfo[playerid][pKills],
  347.         pInfo[playerid][pDeaths],
  348.         pInfo[playerid][ID]);
  349.         mysql_query(Query);
  350.     }
  351. }
  352. CMD:makeadmin(playerid, params[])
  353. {
  354.     if(IsPlayerAdmin(playerid) || pInfo[playerid][pAdmin] >= SETLEVEL_ADMIN)
  355.     {
  356.         new level, target;
  357.         if(sscanf(params, "ui", target, level)) return SendClientMessage(playerid, red, "[*] Usage: /makeadmin [playerid/name] [level]");
  358.         if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[*] Nevaliden nickname/ID!");
  359.         new string[128], Query[500], str2[50];
  360.         if(level < 0 || level > MAX_ADMIN_LEVEL)
  361.         {
  362.             format(string, sizeof(string), "Vnesete admin level pomegju 0 i %d", MAX_ADMIN_LEVEL);
  363.             SendClientMessage(playerid, red,string);
  364.             return 1;
  365.         }
  366.         format(Query, 500, "UPDATE `playerdata` SET `admin` = '%d' WHERE `id` = '%d' LIMIT 1", level, pInfo[target][ID]);
  367.         mysql_query(Query);
  368.         pInfo[target][pAdmin] = level;
  369.         format(string, 256, "Mu dadovte na %s administartor so level %d", pInfo[target][Nick], target, level);
  370.         SendClientMessage(playerid, green, string);
  371.         format(string, 256, "Administrator %s ve ovlasti vo AdminLVL %d", pInfo[playerid][Nick], level);
  372.         SendClientMessage(target, yellow, string);
  373.         for (new i=0; i<MAX_PLAYERS; i++)
  374.         {
  375.             if(pInfo[i][Logged] == 1 && pInfo[i][pAdmin])
  376.             {
  377.                 format(str2, sizeof(str2), "[MYSQL/INFO]:Admin %s[%d] ja iskoristi komandata /makeadmin", pInfo[playerid][Nick], playerid, pInfo[playerid][pAdmin], pInfo[target][Nick], target);
  378.                 SendClientMessage(i,COLOR_SPRINGGREEN,string);
  379.             }
  380.         }
  381.         PlayerPlaySound(target,1057,0.0,0.0,0.0);
  382.     }
  383.     else return ErrorMessage(playerid);
  384.     return 1;
  385. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top