Guest User

Untitled

a guest
Feb 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.16 KB | None | 0 0
  1. stock ShowLoginScreen(playerid)
  2. {
  3.     new string[100];
  4.     format(string, sizeof(string), "{6EF83C}Welcome back %s\nBefore playing you must login\nEnter your password below and click login",PlayerName(playerid));
  5.     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"{6EF83C}Login required",string,"Login","Cancel");
  6. }
  7.  
  8. stock ShowRegisterScreen(playerid)
  9. {
  10.     new string[100];
  11.     format(string, sizeof(string), "{6EF83C}Welcome to the Sfrcnr{F81414} %s\nYou need to create an account before playing",PlayerName(playerid));
  12.     ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"{F81414}Registration required",string,"Register","Cancel");
  13. }
  14.  
  15. La OnPlayerConnect
  16.     if(udb_Exists(PlayerName(playerid)) && !PLAYERLIST_authed[playerid]) {
  17.     ShowLoginScreen(playerid);
  18.     return 0;
  19. }
  20.     if(!udb_Exists(PlayerName(playerid)) && !PLAYERLIST_authed[playerid]) {
  21.     ShowRegisterScreen(playerid);
  22.     return 0;
  23. }
  24.  
  25.  
  26. sh la OnDialogResponse
  27.  
  28. if(dialogid == DIALOG_LOGIN)
  29.     {
  30.         if (response == 0)
  31.         {
  32.             SendClientMessage(playerid,COLOR_ERROR,"You must login before playing on this server.");
  33.             ShowLoginScreen(playerid);
  34.             return 1;
  35.         }
  36.         if (response == 1)
  37.         {
  38.             if (strlen(inputtext) == 0)
  39.             {
  40.                 SendClientMessage(playerid,COLOR_ERROR,"Please enter your password for your account in the box below.");
  41.                 ShowLoginScreen(playerid);
  42.                 return 1;
  43.             }
  44.             if (udb_CheckLogin(PlayerName(playerid),inputtext))
  45.             {
  46.                 GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
  47.                 PLAYERLIST_authed[playerid]=true;
  48.                 new pIp[16];
  49.                 GetPlayerIp(playerid, pIp, sizeof(pIp));
  50.                 dUserSet(PlayerName(playerid)).("IP", pIp);
  51.                 PLAYERLIST_authed[playerid]=true;
  52.                 return SendClientMessage(playerid,COLOR_GREEN,"You have successfully logged!");
  53.             }
  54.             ShowLoginScreen(playerid);
  55.             CheckPasswordAttempts(playerid);
  56.         }
  57.         return 1;
  58.     }
  59.     if(dialogid == DIALOG_REGISTER)
  60.     {
  61.         if (response == 0)
  62.         {
  63.             SendClientMessage(playerid,COLOR_ERROR,"You must register before playing on this server.");
  64.             ShowRegisterScreen(playerid);
  65.             return 1;
  66.         }
  67.         if (response == 1)
  68.         {
  69.             if (udb_Exists(PlayerName(playerid)))
  70.             {
  71.                 SendClientMessage(playerid,COLOR_ERROR,"This account already exists, please choose a different player name.");
  72.                 return 1;
  73.             }
  74.             if (strlen(inputtext)==0)
  75.             {
  76.                 SendClientMessage(playerid,COLOR_ERROR,"Please enter your password in the box to register in this server.");
  77.                 ShowRegisterScreen(playerid);
  78.                 return 1;
  79.             }
  80.             if (udb_Create(PlayerName(playerid),inputtext))
  81.             {
  82.                 SendClientMessage(playerid,COLOR_GREEN,"Congratulations!You have registered,now please enter your password in the box to login.");
  83.                 ShowLoginScreen(playerid);
  84.                 dUserSetINT(PlayerName(playerid)).("money",7500);
  85.                 new pIp[16];
  86.                 GetPlayerIp(playerid, pIp, sizeof(pIp));
  87.                 dUserSet(PlayerName(playerid)).("IP", pIp);
  88.             }
  89.             return true;
  90.         }
  91.         return 1;
  92.     }
Add Comment
Please, Sign In to add comment