Advertisement
Sixxx-script

Tela de Login

Jun 18th, 2021
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. new String[128];
  5. new bool:Logado[MAX_PLAYERS];
  6.  
  7. //-------Dialogs-------
  8. #define D_LOGIN 0
  9. #define D_REGISTRO 1
  10.  
  11.  
  12. #define varGet(%0)      getproperty(0,%0)
  13. #define varSet(%0,%1)   setproperty(0, %0, %1)
  14. #define new_strcmp(%0,%1) \
  15.         (varSet(%0, 1), varGet(%1) == varSet(%0, 0))
  16.  
  17. main ();
  18.  
  19. public OnGameModeInit()
  20. {
  21.     return 1;
  22. }
  23.  
  24. public OnGameModeExit()
  25. {
  26.     DOF2_Exit();
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerRequestClass(playerid, classid)
  31. {
  32.     InterpolateCameraPos(playerid, 1127.696044, -1662.729858, 45.204086, 1186.296142, -1724.055908, 19.555419, 20000);
  33.     InterpolateCameraLookAt(playerid, 1130.844360, -1666.290527, 43.651832, 1189.594238, -1727.615356, 18.350280, 20000);
  34.     for(new i; i < 20; i++)
  35.     {
  36.         SendClientMessage(playerid, -1, "");
  37.     }
  38.     SendClientMessage(playerid, -1, "Seja bem vindo ao Cidade Real {FFFFFF}RP");
  39.     format(String, sizeof(String), "Contas/%s.ini", PlayerName(playerid));
  40.     if(DOF2_FileExists(String))
  41.     {
  42.         format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {00FF00}Registrado\n\nDigite sua senha para Logar!", PlayerName(playerid));
  43.         ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Login", String, "Logar", "Cancelar");
  44.     }
  45.     else
  46.     {
  47.         format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {FF0000}Nao Registrado\n\nDigite sua senha para se Registrar!", PlayerName(playerid));
  48.         ShowPlayerDialog(playerid, D_REGISTRO , DIALOG_STYLE_PASSWORD, "{FF0000}Registro", String, "Registrar", "Cancelar");
  49.     }
  50.  
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56.     return 1;
  57. }
  58.  
  59. public OnPlayerDisconnect(playerid, reason)
  60. {
  61.     if(Logado[playerid] == true)
  62.     {
  63.         format(String, sizeof(String), "Contas/%s.ini", PlayerName(playerid));
  64.         if(DOF2_FileExists(String))
  65.         {
  66.             new Float:X, Float:Y, Float:Z, Float:R; GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, R);
  67.             DOF2_SetFloat(String, "X", X);
  68.             DOF2_SetFloat(String, "Y", Y);
  69.             DOF2_SetFloat(String, "Z", Z);
  70.             DOF2_SetFloat(String, "R", R);
  71.             DOF2_SetInt(String, "Dinheiro", GetPlayerMoney(playerid));
  72.             DOF2_SetInt(String, "Level", GetPlayerScore(playerid));
  73.             DOF2_SetInt(String, "Skin", GetPlayerSkin(playerid));
  74.             DOF2_SaveFile();
  75.         }
  76.     }
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerDeath(playerid, killerid, reason)
  86. {
  87.     return 1;
  88. }
  89.  
  90. public OnVehicleSpawn(vehicleid)
  91. {
  92.     return 1;
  93. }
  94.  
  95. public OnVehicleDeath(vehicleid, killerid)
  96. {
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerText(playerid, text[])
  101. {
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerCommandText(playerid, cmdtext[])
  106. {
  107.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  108.     {
  109.         // Do something here
  110.         return 1;
  111.     }
  112.     return 0;
  113. }
  114.  
  115. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  116. {
  117.     return 1;
  118. }
  119.  
  120. public OnPlayerExitVehicle(playerid, vehicleid)
  121. {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerStateChange(playerid, newstate, oldstate)
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerEnterCheckpoint(playerid)
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerLeaveCheckpoint(playerid)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnPlayerEnterRaceCheckpoint(playerid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnPlayerLeaveRaceCheckpoint(playerid)
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnRconCommand(cmd[])
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnPlayerRequestSpawn(playerid)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnObjectMoved(objectid)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerObjectMoved(playerid, objectid)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerPickUpPickup(playerid, pickupid)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnVehicleMod(playerid, vehicleid, componentid)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnPlayerSelectedMenuRow(playerid, row)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerExitedMenu(playerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnRconLoginAttempt(ip[], password[], success)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerUpdate(playerid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerStreamIn(playerid, forplayerid)
  221. {
  222.     return 1;
  223. }
  224.  
  225. public OnPlayerStreamOut(playerid, forplayerid)
  226. {
  227.     return 1;
  228. }
  229.  
  230. public OnVehicleStreamIn(vehicleid, forplayerid)
  231. {
  232.     return 1;
  233. }
  234.  
  235. public OnVehicleStreamOut(vehicleid, forplayerid)
  236. {
  237.     return 1;
  238. }
  239.  
  240. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  241. {
  242.     if(dialogid == D_LOGIN)
  243.     {
  244.         if(response)
  245.         {
  246.             if(strlen(inputtext) >= 5 && strlen(inputtext) <= 20)
  247.             {
  248.                 format(String, sizeof(String), "Contas/%s.ini", PlayerName(playerid));
  249.                 if(new_strcmp(inputtext, DOF2_GetString(String, "Senha")))
  250.                 {
  251.                     //Logou
  252.                     new Float:X, Float:Y, Float:Z, Float:R;
  253.                     X = DOF2_GetFloat(String, "X");
  254.                     Y = DOF2_GetFloat(String, "Y");
  255.                     Z = DOF2_GetFloat(String, "Z");
  256.                     R = DOF2_GetFloat(String, "R");
  257.                     new Skin = DOF2_GetInt(String, "Skin");
  258.                     new Dinheiro = DOF2_GetInt(String, "Dinheiro"); GivePlayerMoney(playerid, Dinheiro);
  259.                     new Level = DOF2_GetInt(String, "Level"); SetPlayerScore(playerid, Level);
  260.                     SetPlayerSkin(playerid, Skin);
  261.                     SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), X, Y, Z, R, 0, 0, 0, 0, 0, 0);
  262.                     //1210.5579,-1749.1705,13.5939
  263.                     SpawnPlayer(playerid);
  264.                     for(new i; i < 20; i++)
  265.                     {
  266.                         SendClientMessage(playerid, -1, "");
  267.                     }
  268.                     SendClientMessage(playerid, 0x5FB404FF, "|SERVER| Logado com sucesso!");
  269.                     Logado[playerid] = true;
  270.                 }
  271.                 else
  272.                 {
  273.                     format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {00FF00}Registrado\n\nDigite sua senha para Logar!", PlayerName(playerid));
  274.                     ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Login", String, "Logar", "Cancelar");
  275.                     return SendClientMessage(playerid, 0x5FB404FF, "|SERVER| Logado com sucesso!");
  276.                 }
  277.             }
  278.             else
  279.             {
  280.                 format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {00FF00}Registrado\n\nDigite sua senha para Logar!", PlayerName(playerid));
  281.                 ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Login", String, "Logar", "Cancelar");
  282.                 SendClientMessage(playerid, 0xFF0000FF,"Digite uma senha sem numeros menor que 20 e maior que 5");
  283.             }
  284.         }
  285.         else
  286.         {
  287.             SendClientMessage(playerid, 0xFF000FF, "|SERVER| Voce cancelou o login e foi kickado do servidor!");
  288.             SetTimerEx("KickPlayer", 500, false, "i", playerid);
  289.  
  290.         }
  291.     }
  292.     else if(dialogid == D_REGISTRO)
  293.     {
  294.         if(response)
  295.         {
  296.             if(strlen(inputtext) >= 5 && strlen(inputtext) <= 20)
  297.             {
  298.                 //Registrou
  299.                 format(String, sizeof(String), "Contas/%s.ini", PlayerName(playerid));
  300.                 if(!DOF2_FileExists(String))
  301.                 {
  302.                     DOF2_CreateFile(String);
  303.                     DOF2_SetString(String, "Senha", inputtext);
  304.                     DOF2_SetInt(String, "Skin", 36);
  305.                     DOF2_SetInt(String, "Dinheiro", 1000);
  306.                     DOF2_SetInt(String, "Level", 1);
  307.                     DOF2_SetFloat(String, "X", 1210.5579);
  308.                     DOF2_SetFloat(String, "Y", -1749.1705);
  309.                     DOF2_SetFloat(String, "Z", 13.5939);
  310.                     DOF2_SetFloat(String, "R", 38.4018);
  311.                     DOF2_SaveFile();
  312.                     SendClientMessage(playerid, -1, "|SERVER|Conta registrada com sucesso!");
  313.                     format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {00FF00}Registrado\n\nDigite sua senha para Logar!", PlayerName(playerid));
  314.                     ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Login", String, "Logar", "Cancelar");
  315.                 }
  316.             }
  317.             else
  318.             {
  319.                 format(String, sizeof(String), "{FFFFFF}Conta %s\n\nStatus: {FF0000}Nao Registrado\n\nDigite sua senha para se Registrar!", PlayerName(playerid));
  320.                 ShowPlayerDialog(playerid, D_REGISTRO , DIALOG_STYLE_PASSWORD, "{FF0000}Registro", String, "Registrar", "Cancelar");
  321.                 return SendClientMessage(playerid, 0xFF0000FF, "|SERVER| Digite uma senha sem numeros menor que 20 e maior que 5!");
  322.             }
  323.         }
  324.         else
  325.         {
  326.             SendClientMessage(playerid, 0xFF000FF, "|SERVER| Voce cancelou o login e foi kickado do servidor!");
  327.             SetTimerEx("KickPlayer", 500, false, "i", playerid);
  328.         }
  329.     }
  330.     return 1;
  331. }
  332.  
  333. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  334. {
  335.     return 1;
  336. }
  337.  
  338. stock KickPlayer(playerid);
  339. public KickPlayer(playerid)
  340. {
  341.     Kick(playerid);
  342.     return 1;
  343. }
  344.  
  345. stock PlayerName(playerid)
  346. {
  347.     new Nome[24]; GetPlayerName(playerid, Nome, sizeof(Nome));
  348.     return Nome;
  349. }
Advertisement
RAW Paste Data Copied
Advertisement