Advertisement
StageZero

Untitled

Oct 15th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.38 KB | None | 0 0
  1. /* SZRegistration System v1.0
  2.  Created by StageZero, contact me: [email protected]
  3. */
  4.  
  5. #include <a_samp>
  6. #include <YSI\y_ini>
  7.  
  8. #define DIALOG_REG 1
  9. #define DIALOG_LOGIN 2
  10.  
  11. //COLORS
  12. #define COLOR_RED 0xFF0000FF
  13. #define COLOR_GREEN 0x33AA33AA
  14. #define COLOR_WHITE 0xFFFFFFAA
  15. #define COLOR_ORANGE 0xFF8000FF
  16.  
  17. #define MAX_FAILED_LOGIN 3 // Maximum number of login failures
  18.  
  19. #pragma tabsize 0
  20.  
  21. enum stat_info {admin_level, score, money, failed_login, bool: logged}; // Players statistics
  22. new player_stat[MAX_PLAYERS][stat_info];
  23.  
  24. new pstring[500], p_password[20], bool: banned; //Array & check banned at login
  25.  
  26. new INI: opened_file; // Variable that identifies the open file
  27.  
  28. public OnFilterScriptInit()
  29. {
  30.     print("\n--------------------------------------");
  31.     print("        SZRegistration System v1.0");
  32.     print("--------------------------------------\n");
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.     new name[24];
  39.     GetPlayerName(playerid, name, 24);
  40.     format(pstring,sizeof(pstring), "/Accounts/%s.ini", name);
  41.     if(!fexist(pstring))
  42.     {
  43.     format(pstring, 500, "{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Your account is not registered.\nEnter a password to register a new account:", name);
  44.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registering...", pstring, "Register", "");
  45.     return 1;
  46.     }
  47.     else
  48.     {
  49.     format(pstring, 500, "{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Your account is registered.\nEnter the password to login:", name);
  50.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
  51.     return 1;
  52.     }
  53. }
  54.  
  55. public OnPlayerDisconnect(playerid, reason)
  56. {
  57. new name[24];
  58. GetPlayerName(playerid, name, sizeof(name));
  59. switch(reason)
  60. {
  61. case 0: format(pstring, 500, "{B0EC1B}%s {C1C1C1}has left the server {A1A1A1}[crash].", name);
  62. case 1: format(pstring, 500, "{B0EC1B}%s {C1C1C1}has left the server.", name);
  63. case 2: format(pstring, 500, "{B0EC1B}%s {C1C1C1}has left the server {A1A1A1}[kick/ban].", name);
  64. }
  65. SendClientMessageToAll(-1, pstring);
  66. if(player_stat[playerid][logged])
  67. {
  68. format(pstring, sizeof(pstring), "Accounts/%s.ini", name);
  69. opened_file = INI_Open(pstring);
  70. new pyear, pmonth, pday, phour, pminute, psecond;
  71. getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
  72. format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
  73. new ip[20];
  74. GetPlayerIp(playerid, ip, 20);
  75. INI_WriteString(opened_file, "Last_Login", pstring);
  76. INI_WriteString(opened_file, "Last_IP", ip);
  77. INI_WriteInt(opened_file, "Admin_Level", player_stat[playerid][admin_level]);
  78. INI_WriteInt(opened_file, "Score", player_stat[playerid][score]);
  79. INI_WriteInt(opened_file, "Money", player_stat[playerid][money]);
  80. INI_Close(opened_file);
  81. }
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerSpawn(playerid)
  86. {
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerDeath(playerid, killerid, reason)
  91. {
  92.     return 1;
  93. }
  94.  
  95. public OnVehicleSpawn(vehicleid)
  96. {
  97.     return 1;
  98. }
  99.  
  100. public OnVehicleDeath(vehicleid, killerid)
  101. {
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerText(playerid, text[])
  106. {
  107.     return 1;
  108. }
  109.  
  110. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  111. {
  112.     return 1;
  113. }
  114.  
  115. public OnPlayerExitVehicle(playerid, vehicleid)
  116. {
  117.     return 1;
  118. }
  119.  
  120. public OnPlayerStateChange(playerid, newstate, oldstate)
  121. {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerEnterCheckpoint(playerid)
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerLeaveCheckpoint(playerid)
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerEnterRaceCheckpoint(playerid)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnPlayerLeaveRaceCheckpoint(playerid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnRconCommand(cmd[])
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnPlayerRequestSpawn(playerid)
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnObjectMoved(objectid)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnPlayerObjectMoved(playerid, objectid)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerPickUpPickup(playerid, pickupid)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnVehicleMod(playerid, vehicleid, componentid)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnPlayerSelectedMenuRow(playerid, row)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnPlayerExitedMenu(playerid)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnRconLoginAttempt(ip[], password[], success)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnPlayerUpdate(playerid)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerStreamIn(playerid, forplayerid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerStreamOut(playerid, forplayerid)
  221. {
  222.     return 1;
  223. }
  224.  
  225. public OnVehicleStreamIn(vehicleid, forplayerid)
  226. {
  227.     return 1;
  228. }
  229.  
  230. public OnVehicleStreamOut(vehicleid, forplayerid)
  231. {
  232.     return 1;
  233. }
  234.  
  235. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  236. {
  237.     new name[24];
  238.     GetPlayerName(playerid, name, 24);
  239.     switch(dialogid)
  240.     {
  241.     case DIALOG_REG:
  242.     {
  243.     if(!response)
  244.     {
  245.     PlayerPlaySound(playerid, 1055, 0, 0 ,0); //Errors Sounds
  246.     SendClientMessage(playerid, COLOR_RED, "[SERVER:] {C1C1C1}You must register to play. You have been kicked from the server.");
  247.     Kick(playerid);
  248.     return 1;
  249.     }
  250.     if(!strlen(inputtext))
  251.     {
  252.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  253.     format(pstring, 500, "{F1781B}-Enter a valid password-\n{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Your account is not registered.\nEnter a password to register a new account:", name);
  254.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registering...", pstring, "Register", "");
  255.     return 1;
  256.     }
  257.     if(strlen(inputtext) > 20)
  258.     {
  259.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  260.     format(pstring, 500, "{F1781B}-Maximum 20 characters for the password-\n{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Your account is not registered.\nEnter a password to register a new account:", name);
  261.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registering...", pstring, "Register", "");
  262.     return 1;
  263.     }
  264.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  265.     GetPlayerName(playerid, name, 24);
  266.     format(pstring,sizeof(pstring),"/Accounts/%s.ini",name);
  267.     opened_file = INI_Open(pstring);
  268.     new pyear, pmonth, pday, phour, pminute, psecond;
  269.     getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
  270.     format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
  271.     new ip[20];
  272.     GetPlayerIp(playerid, ip, 20);
  273.     INI_WriteString(opened_file, "Password", inputtext);
  274.     INI_WriteString(opened_file, "Date_Registration", pstring);
  275.     INI_WriteString(opened_file, "Last_Login", pstring);
  276.     INI_WriteString(opened_file, "IP_Registration", ip);
  277.     INI_WriteString(opened_file, "Last_IP", ip);
  278.     INI_WriteInt(opened_file, "Admin_Level", 0);
  279.     INI_WriteInt(opened_file, "Score", 0);
  280.     INI_WriteInt(opened_file, "Money", 0);
  281.     INI_WriteBool(opened_file, "Banned", false);
  282.     INI_Close(opened_file);
  283.     format(pstring, 500, "{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Congratulations, you've successfully registered.\nEnter the password to login:", name);
  284.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
  285.     return 1;
  286.     }
  287.     case DIALOG_LOGIN:
  288.     {
  289.     if(!response)
  290.     {
  291.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  292.     SendClientMessage(playerid, COLOR_RED, "[SERVER:] {C1C1C1}You need to log to play. You have been kicked from the server.");
  293.     Kick(playerid);
  294.     return 1;
  295.     }
  296.     if(!strlen(inputtext))
  297.     {
  298.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  299.     format(pstring, 500, "{F1781B}-Enter a password to login-\n{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Congratulations, you've successfully registered.\nEnter the password to login:", name);
  300.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  301.     return 1;
  302.     }
  303.     if(strlen(inputtext) > 20)
  304.     {
  305.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  306.     format(pstring, 500, "{F1781B}-Maximum 20 characters for the password-\n{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Congratulations, you've successfully registered.\nEnter the password to login:", name);
  307.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  308.     return 1;
  309.     }
  310.     format(pstring,sizeof(pstring),"/Accounts/%s.ini",name);
  311.     INI_ParseFile(pstring, "Parse_Player_Pass", .bExtra = true, .extra = playerid);
  312.     if(strcmp(inputtext, p_password, true))
  313.     {
  314.     player_stat[playerid][failed_login]++;
  315.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  316.     if(player_stat[playerid][failed_login] == MAX_FAILED_LOGIN)
  317.     {
  318.     SendClientMessage(playerid, COLOR_RED, "[SERVER:] {C1C1C1}Have exceeded the maximum number of login attempts. You have been kicked from the server.");
  319.     Kick(playerid);
  320.     return 1;
  321.     }
  322.     format(pstring, 500, "{F1781B}-Attempting login %d/%d. To %d attempts you will be kicked-\n{C1C1C1}Welcome {B0EC1B}%s{C1C1C1} to the server!\n\n Congratulations, you've successfully registered.\nEnter the password to login:", player_stat[playerid][failed_login], MAX_FAILED_LOGIN, MAX_FAILED_LOGIN, name);
  323.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  324.     return 1;
  325.     }
  326.     else
  327.     {
  328.     format(pstring,sizeof(pstring),"/Accounts/%s.ini",name);
  329.     INI_ParseFile(pstring,"Load_Player_Data", .bExtra = true, .extra = playerid);
  330.     if(banned)
  331.     {
  332.     banned = false;
  333.     SendClientMessage(playerid, COLOR_RED, "This account is banned from the server.");
  334.     Kick(playerid);
  335.     return 2;
  336.     }
  337.     player_stat[playerid][logged] = true;
  338.     return 1;
  339.     }
  340.     }
  341.     }
  342.     return 1;
  343.     }
  344.  
  345.     forward Parse_Player_Pass(playerid, name[], value[]);
  346.     public Parse_Player_Pass(playerid, name[], value[])
  347.     {
  348.     INI_String("Password", p_password, 20);
  349.     return 1;
  350.     }
  351.  
  352.     forward Load_Player_Data(playerid, name[], value[]);
  353.     public Load_Player_Data(playerid, name[], value[])
  354.     {
  355.     INI_Int("Admin_Level", player_stat[playerid][admin_level]);
  356.     INI_Int("Score", player_stat[playerid][score]);
  357.     INI_Int("Money", player_stat[playerid][money]);
  358.     INI_Bool("Banned", banned);
  359.     return 1;
  360. }
  361.  
  362. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  363. {
  364.     return 1;
  365. }
  366.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement