Advertisement
Guest User

Joe Torran C

a guest
May 30th, 2010
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.09 KB | None | 0 0
  1. // [FS] torran's Registration System v2
  2. // Made by Joe Torran C
  3. // DO NOT REMOVE THESE CREDITS
  4.  
  5. #include <a_samp>
  6. #include <dini>
  7. #include <dudb>
  8. #include <zcmd>
  9.  
  10. #define SCRIPT_VERSION          "v2"
  11.  
  12. #define colorRed                0xFF0000FF
  13. #define colorGreen              0x008000FF
  14.  
  15. #define DIALOG_REGISTER         1
  16. #define DIALOG_LOGIN            2
  17. #define DIALOG_ACCOUNT          3
  18. #define DIALOG_CHANGEPASS       4
  19.  
  20. #pragma unused                  ret_memcpy
  21.  
  22. forward UpdateTime(playerid);
  23.  
  24. new str[128];
  25. new file[128];
  26.  
  27. new Update;
  28.  
  29. public OnPlayerConnect(playerid)
  30. {
  31.     format(file, 128, "/tReg/%s.ini", GetName(playerid));
  32.    
  33.     if(!dini_Exists(file))
  34.     {
  35.         format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
  36.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
  37.     }
  38.     if(dini_Exists(file))
  39.     {
  40.         format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
  41.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
  42.     }
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerDisconnect(playerid, reason)
  47. {
  48.     format(file, 128, "/tReg/%s.ini", GetName(playerid));
  49.  
  50.     if(GetPVarInt(playerid, "Logged") == 1)
  51.     {
  52.         dini_IntSet(file, "Money", GetPlayerMoney(playerid));
  53.         dini_IntSet(file, "Score", GetPlayerScore(playerid));
  54.         dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
  55.         dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
  56.         dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
  57.        
  58.         KillTimer(Update);
  59.     }
  60.     return 1;
  61. }
  62.  
  63. public OnFilterScriptInit()
  64. {
  65.     printf("\n  [FS] torran's Registration System %s \n", SCRIPT_VERSION);
  66.     return 1;
  67. }
  68.  
  69. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  70. {
  71.     format(file, 128, "/tReg/%s.ini", GetName(playerid));
  72.    
  73.     if(dialogid == DIALOG_REGISTER)
  74.     {
  75.         if(!response) return Kick(playerid);
  76.         if(response)
  77.         {
  78.             if(strlen(inputtext) == 0)
  79.             {
  80.                 format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
  81.                 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
  82.                 return 0;
  83.             }
  84.             if(!dini_Exists(file))
  85.             {
  86.                 dini_Create(file);
  87.                 dini_IntSet(file, "Password", udb_hash(inputtext));
  88.                 dini_IntSet(file, "Money", GetPlayerMoney(playerid));
  89.                 dini_IntSet(file, "Score", GetPlayerScore(playerid));
  90.                 dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
  91.                 dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
  92.                 dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
  93.                
  94.                 format(str, 128, "Account successfully Registered \n\n\nWelcome %s \n\nPlease login to your account", GetName(playerid));
  95.                 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
  96.             }
  97.         }
  98.     }
  99.     if(dialogid == DIALOG_LOGIN)
  100.     {
  101.         if(!response) return Kick(playerid);
  102.         if(response)
  103.         {
  104.             if(strlen(inputtext) == 0)
  105.             {
  106.                 format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
  107.                 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
  108.                 return 0;
  109.             }
  110.             if(fexist(file))
  111.             {
  112.                 new password = dini_Int(file, "Password");
  113.                 if(udb_hash(inputtext) != password)
  114.                 {
  115.                     if(GetPVarInt(playerid, "Attempts") == 0)
  116.                     {
  117.                         SetPVarInt(playerid, "Attempts", 1);
  118.                         SendClientMessage(playerid, colorRed, "Incorrect password, You have 1 more attempt");
  119.                        
  120.                         format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
  121.                         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
  122.                     }
  123.                     else if(GetPVarInt(playerid, "Attempts") == 1)
  124.                     {
  125.                         SendClientMessage(playerid, colorRed, "Incorrect password, You do not have any attempts left");
  126.                         Kick(playerid);
  127.                     }
  128.                 }
  129.                 else
  130.                 {
  131.                     SetPVarInt(playerid, "Logged", 1);
  132.                    
  133.                     SetPlayerMoney(playerid, dini_Int(file, "Money"));
  134.                     SetPlayerScore(playerid, dini_Int(file, "Score"));
  135.                     SetPVarInt(playerid, "Kills", dini_Int(file, "Kills"));
  136.                     SetPVarInt(playerid, "Deaths", dini_Int(file, "Deaths"));
  137.                     SetPVarInt(playerid, "Time", dini_Int(file, "Minutes Ingame"));
  138.                    
  139.                     Update = SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);
  140.                    
  141.                     SendClientMessage(playerid, colorGreen, "You have successfully logged in.");
  142.                 }
  143.             }
  144.         }
  145.     }
  146.     if(dialogid == DIALOG_CHANGEPASS)
  147.     {
  148.         if(response)
  149.         {
  150.             if(GetPVarInt(playerid, "PassStage") == 1)
  151.             {
  152.                 new password = dini_Int(file, "Password");
  153.                 if(udb_hash(inputtext) == password)
  154.                 {
  155.                     SetPVarInt(playerid, "PassStage", 2);
  156.                     ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your new password", "Change Pass", "Cancel");
  157.                 }
  158.                 else
  159.                 {
  160.                     SendClientMessage(playerid, colorRed, "Incorrect password.");
  161.                 }
  162.             }
  163.             if(GetPVarInt(playerid, "PassStage") == 2)
  164.             {
  165.                 if(GetPVarInt(playerid, "Logged") == 1)
  166.                 {
  167.                     dini_IntSet(file, "Password", udb_hash(inputtext));
  168.                     SendClientMessage(playerid, colorGreen, "Password successfully changed.");
  169.                 }
  170.             }
  171.         }
  172.     }
  173.     return 0;
  174. }
  175.  
  176. public UpdateTime(playerid)
  177. {
  178.     format(file, 128, "/tReg/%s.ini", GetName(playerid));
  179.    
  180.     SetPVarInt(playerid, "Time", GetPVarInt(playerid, "Time")+1);
  181.     return 1;
  182. }
  183.  
  184. CMD:changepass(playerid, params[])
  185. {
  186.     if(GetPVarInt(playerid, "Logged") == 1)
  187.     {
  188.         SetPVarInt(playerid, "PassStage", 1);
  189.         ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your current password for verification", "Continue", "Cancel");
  190.     }
  191.     return 1;
  192. }
  193.  
  194. stock GetName(playerid)
  195. {
  196.     new name[MAX_PLAYER_NAME];
  197.     GetPlayerName(playerid, name, sizeof name);
  198.     return name;
  199. }
  200.  
  201. stock SetPlayerMoney(playerid, amount)
  202. {
  203.     ResetPlayerMoney(playerid);
  204.     return GivePlayerMoney(playerid, amount);
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement