Advertisement
Sants101100

Untitled

Jan 25th, 2021
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.25 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. //Macro Para Formatar a pasta
  5. #define PASTAC "Contas/%s.ini"
  6.  
  7. //Enums para determinar o id da Dialog
  8. enum {
  9.     LOGIN,
  10.     REGISTRO
  11. }
  12.  
  13. //Enums para auxiliar na manipulação dos dados do jogar.
  14. enum pInfo{
  15.     pIp,
  16.     pScore,
  17.     Float:pLife
  18. }
  19.  
  20. //variável para chamar a enum e o que há dentro dela.
  21. new PlayerInfo[MAX_PLAYERS][pInfo];
  22.  
  23. //Variáveis para formatar strings
  24. new pSenha[24];
  25. new pNick[24];
  26.  
  27. forward KickPlayer(playerid);
  28.  
  29. main()
  30. {
  31.     print("\n----------------------------------");
  32.     print(" Blank Gamemode by your name here");
  33.     print("----------------------------------\n");
  34. }
  35.  
  36. public OnGameModeInit()
  37. {
  38.     // Don't use these lines if it's a filterscript
  39.     SetGameModeText("Blank Script");
  40.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  41.     return 1;
  42. }
  43.  
  44. public OnGameModeExit()
  45. {
  46.  
  47.     //EXTREMAMANETE NECESSÁRIO, isso avisará ao DOF2 quando ele poderá sair da GM.
  48.     DOF2_Exit();
  49.     return 1;
  50. }
  51.  
  52. public OnPlayerRequestClass(playerid, classid)
  53. {
  54.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  55.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  56.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerConnect(playerid)
  61. {  
  62.     //Dialogs simples, de Registro e Login. Caso o player tenta conta, ele loga. Caso não, ele se registra.
  63.     new arquivo[40];
  64.     format(arquivo, 40, PASTAC, GetNick(playerid));
  65.     if(!DOF2_FileExists(arquivo)) {
  66.         SendClientMessage(playerid, -1, "(Info) Sua conta não está registrada no banco de dados.");
  67.         ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro", "Coloque sua senha para fazer registro", "Confirmar", "Sair");
  68.     }
  69.     else {
  70.         SendClientMessage(playerid, -1, "(Info) Sua conta está registrada no banco de dados.");
  71.         ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Coloque sua senha para fazer Login", "Confirmar", "Sair");
  72.     }
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerDisconnect(playerid, reason)
  77. {
  78.     //Salva a conta do jogador ao sair.
  79.     SalvarConta(playerid);
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerSpawn(playerid)
  84. {
  85.     //Aqui seta o que foi salvo dentro do aquivo do jogador.
  86.     new arquivo[40];
  87.     format(arquivo, 40, PASTAC, GetNick(playerid));
  88.     SetPlayerHealth(playerid, DOF2_GetFloat(arquivo, "Life"));
  89.     SetPlayerScore(playerid, DOF2_GetInt(arquivo, "Score"));
  90.     return 1;
  91. }
  92.  
  93. public OnPlayerDeath(playerid, killerid, reason)
  94. {
  95.     return 1;
  96. }
  97.  
  98. public OnVehicleSpawn(vehicleid)
  99. {
  100.     return 1;
  101. }
  102.  
  103. public OnVehicleDeath(vehicleid, killerid)
  104. {
  105.     return 1;
  106. }
  107.  
  108. public OnPlayerText(playerid, text[])
  109. {
  110.     return 1;
  111. }
  112.  
  113. public OnPlayerCommandText(playerid, cmdtext[])
  114. {
  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.     switch(dialogid) {
  247.         case REGISTRO: {
  248.             //Aqui realizamos o registro. Caso ele responda negativamente, ele é kickado, caso insira algum caractere é registrado
  249.             //e levado a dialog de login
  250.             if(!response) {
  251.                 SendClientMessage(playerid, -1, "(Info) Você optou por sair do servidor");
  252.                 SetTimerEx("KickPlayer", 1000, 0, "i", playerid);
  253.             }
  254.             else {
  255.                 PlayerInfo[playerid][pScore] = 0;
  256.                 new arquivo[40];
  257.                 format(pSenha, 24, "%s", inputtext);
  258.                 format(arquivo, 40, PASTAC, GetNick(playerid));
  259.                 GetPlayerIp(playerid, PlayerInfo[playerid][pIp], 20);
  260.                 format(pNick, 40, "%s", GetNick(playerid));
  261.                 DOF2_CreateFile(arquivo);
  262.                 DOF2_SetString(arquivo, "Nick", pNick);
  263.                 DOF2_SetString(arquivo, "Senha", pSenha);
  264.                 DOF2_SetString(arquivo, "IP", PlayerInfo[playerid][pIp]);
  265.                 DOF2_SetInt(arquivo, "Score", PlayerInfo[playerid][pScore]);
  266.                 DOF2_SetFloat(arquivo, "Life", 100);
  267.                 DOF2_SaveFile();
  268.                 //Salvamos dados básicos do jogador em sua conta. Assim poderemos setar quando ele spawnar (após o login).
  269.  
  270.                 ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Coloque sua senha para fazer Login", "Confirmar", "Sair");
  271.                 SendClientMessage(playerid, -1, "(Info) Conta criada com sucesso, por favor insira sua senha para logar.");
  272.             }
  273.             return 1;
  274.         }
  275.         case LOGIN: {
  276.             //Caso responda negativamente é kickado, se responder e a senha for correta ele loga, se não for ele terá que redigitar a senha.
  277.             if(!response) {
  278.                 SendClientMessage(playerid, -1, "(Info) Você optou por sair do servidor");
  279.                 SetTimerEx("KickPlayer", 1000, 0, "i", playerid);
  280.             }
  281.             else {
  282.                 new arquivo[40];
  283.                 format(arquivo, 40, PASTAC, GetNick(playerid));
  284.                 if(!strcmp(inputtext, DOF2_GetString(arquivo, "Senha"), true)) {
  285.                     SpawnPlayer(playerid);
  286.                     SendClientMessage(playerid, -1, "(Info) Você logou com sucesso e spawnou no servidor!");
  287.                 }
  288.                 else {
  289.                     ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Coloque sua senha para fazer Login", "Confirmar", "Sair");
  290.                     SendClientMessage(playerid, -1, "(Info) Sua senha está errada, por favor tente novamente.");
  291.                 }
  292.             }
  293.         }
  294.     }
  295.     return 1;
  296. }
  297.  
  298. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  299. {
  300.     return 1;
  301. }
  302.  
  303.  
  304. //Função que kicka o jogador do servidor.
  305. public KickPlayer(playerid) {
  306.     Kick(playerid);
  307. }
  308.  
  309.  
  310. //Função usada para pegar o nick do jogador.
  311. GetNick(playerid) {
  312.     new name[MAX_PLAYER_NAME];
  313.     GetPlayerName(playerid, name, sizeof(name));
  314.     return name;
  315. }
  316.  
  317.  
  318. //Função usada parasalvar a conta do jogador.
  319. SalvarConta(playerid) {
  320.     new arquivo[40], Float:vida;
  321.     GetPlayerHealth(playerid, Float:vida);
  322.     format(arquivo, 40, PASTAC, GetNick(playerid));
  323.     DOF2_SetInt(arquivo, "Score", GetPlayerScore(playerid));
  324.     DOF2_SetFloat(arquivo, "Life", vida);
  325.     return 1;
  326. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement