Guest User

GM! Error y_ini

a guest
Feb 23rd, 2013
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.82 KB | None | 0 0
  1. //MODO DE JUEGO NO DEFINIDO
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4.  
  5. //______ Sistema de Usuarios ______//
  6. #define Ruta "/usuarios/%s.ini"
  7.  
  8. enum pInfo
  9. {
  10.     pPass[129],
  11.     pAdmin,
  12.     pSkin,
  13.     pDinero
  14. }
  15. new InfoJugador[MAX_PLAYERS][pInfo];
  16. #define LOGIND 500
  17. #define REGISTROD 501
  18. //______ Sistema de Usuarios ______//
  19.  
  20. main()
  21. {
  22.     print("\n----------------------------------");
  23.     print(" Gamemode no definido!");
  24.     print("----------------------------------\n");
  25. }
  26.  
  27. public OnGameModeInit()
  28. {
  29.     SetGameModeText("No Definido");
  30.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  31.     return 1;
  32. }
  33.  
  34. public OnGameModeExit()
  35. {
  36.     return 1;
  37. }
  38.  
  39. public OnPlayerRequestClass(playerid, classid)
  40. {
  41.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  42.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  43.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  44.     return 1;
  45. }
  46.  
  47. public OnPlayerConnect(playerid)
  48. {
  49.     if(fexist(Usuario(playerid)))
  50.     {
  51.         new string[128], nombre[MAX_PLAYER_NAME];
  52.         GetPlayerName(playerid, nombre, sizeof(nombre));
  53.         INI_ParseFile(Usuario(playerid), "CargarUsuario", .bExtra = true, .extra = playerid);
  54.         format(string, sizeof(string), "{FFFFFF}Bienvenido {FF0000}%s {FFFFFF}a nuestro gamemode!\nIngresa tu password para ingresar a tu cuenta", nombre);
  55.         ShowPlayerDialog(playerid, LOGIND, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Ingresar", "Salir");
  56.     }
  57.     else
  58.     {
  59.         new string[128], nombre[MAX_PLAYER_NAME];
  60.         GetPlayerName(playerid, nombre, sizeof(nombre));
  61.         format(string, sizeof(string), "{FFFFFF}Bienvenido por primera vez {FF6600}%s {FFFFFF}a nuestro gamemode!\nEscribe una password para crear tu nueva cuenta", nombre);
  62.         ShowPlayerDialog(playerid, REGISTROD, DIALOG_STYLE_INPUT, "{FFFFFF}Registrando cuenta..", string, "Registrarse", "Salir");
  63.     }
  64.     return 1;
  65. }
  66.  
  67. public OnPlayerDisconnect(playerid, reason)
  68. {
  69.     new INI:Arch = INI_Open(Usuario(playerid));
  70.     INI_SetTag(Arch,"[Cuenta del Jugador]");
  71.     INI_WriteInt(Arch, "Dinero", InfoJugador[playerid][pDinero]);
  72.     INI_WriteInt(Arch, "Administrador", InfoJugador[playerid][pAdmin]);
  73.     INI_WriteInt(Arch, "Skin", InfoJugador[playerid][pSkin]);
  74.     INI_Close(Arch);
  75.     return 1;
  76. }
  77.  
  78. public OnPlayerSpawn(playerid)
  79. {
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerDeath(playerid, killerid, reason)
  84. {
  85.     return 1;
  86. }
  87.  
  88. public OnVehicleSpawn(vehicleid)
  89. {
  90.     return 1;
  91. }
  92.  
  93. public OnVehicleDeath(vehicleid, killerid)
  94. {
  95.     return 1;
  96. }
  97.  
  98. public OnPlayerText(playerid, text[])
  99. {
  100.     return 1;
  101. }
  102.  
  103.  
  104. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  105. {
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerExitVehicle(playerid, vehicleid)
  110. {
  111.     return 1;
  112. }
  113.  
  114. public OnPlayerStateChange(playerid, newstate, oldstate)
  115. {
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerEnterCheckpoint(playerid)
  120. {
  121.     return 1;
  122. }
  123.  
  124. public OnPlayerLeaveCheckpoint(playerid)
  125. {
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerEnterRaceCheckpoint(playerid)
  130. {
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerLeaveRaceCheckpoint(playerid)
  135. {
  136.     return 1;
  137. }
  138.  
  139. public OnPlayerRequestSpawn(playerid)
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerPickUpPickup(playerid, pickupid)
  145. {
  146.     return 1;
  147. }
  148.  
  149. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  150. {
  151.     return 1;
  152. }
  153.  
  154. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  155. {
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  160. {
  161.     return 1;
  162. }
  163.  
  164. public OnRconLoginAttempt(ip[], password[], success)
  165. {
  166.     return 1;
  167. }
  168.  
  169. public OnPlayerUpdate(playerid)
  170. {
  171.     return 1;
  172. }
  173.  
  174.  
  175. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  176. {
  177.     switch(dialogid)
  178.     {
  179.         case REGISTROD:
  180.         {
  181.             if(!response) return Kick(playerid);
  182.             if(response)
  183.             {
  184.                 new string[128], nombre[MAX_PLAYER_NAME];
  185.                 GetPlayerName(playerid, nombre, sizeof(nombre));
  186.                 format(string, sizeof(string), "{FFFFFF}Bienvenido por primera vez {FF6600}%s {FFFFFF}a nuestro gamemode!\nEscribe una password para crear tu nueva cuenta", nombre);
  187.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, REGISTROD, DIALOG_STYLE_INPUT, "{FFFFFF}Registrando cuenta..", string, "Registrarse", "Salir");
  188.                 new INI:Arch = INI_Open(Usuario(playerid));
  189.                 INI_SetTag(Arch, "[Cuenta del jugador]");
  190.                 INI_WriteString(Arch, "Pass", inputtext);
  191.                 INI_WriteInt(Arch, "Dinero", 5000);
  192.                 INI_WriteInt(Arch, "Administrador", 0);
  193.                 INI_WriteInt(Arch, "Skin", 0);
  194.                 INI_Close(Arch);
  195.                 SpawnPlayer(playerid);
  196.                 format(string, sizeof(string), "Felicidades! Tu cuenta {FF0000}%s {FFFFFF}se ha creado exitosamente..", nombre);
  197.                 SendClientMessage(playerid, 0, string);
  198.             }
  199.         }
  200.        
  201.         case LOGIND:
  202.         {
  203.             if(!response) return Kick(playerid);
  204.             if(response)
  205.             {
  206.                 if(strcmp(inputtext, InfoJugador[playerid][pPass]) == 0)
  207.                 {
  208.                     new string[128];
  209.                     INI_ParseFile(Usuario(playerid), "CargarUsuario", .bExtra = true, .extra = playerid);
  210.                     DarDinero(playerid, InfoJugador[playerid][pDinero]);
  211.                     SpawnPlayer(playerid);
  212.                     format(string, sizeof(string), " >> Bienvenido %s a tu cuenta!", PlayerName(playerid));
  213.                     SendClientMessage(playerid, 0, string);
  214.                 }
  215.                 else
  216.                 {
  217.                     new string[128], nombre[MAX_PLAYER_NAME];
  218.                     GetPlayerName(playerid, nombre, sizeof(nombre));
  219.                     format(string, sizeof(string), "{FF0000}Password incorrecto. {FFFFFF}Bienvenido {FF0000}%s {FFFFFF}a nuestro gamemode!\nIngresa tu password para ingresar a tu cuenta", nombre);
  220.                     ShowPlayerDialog(playerid, LOGIND, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Ingresar", "Salir");
  221.                 }
  222.                 return 1;
  223.             }
  224.         }
  225.     }
  226.     return 1;
  227. }
  228.  
  229. forward CargarUsuario(playerid, name[], value[]);
  230. public CargarUsuario(playerid, name[], value[])
  231. {
  232.     INI_String("Pass", InfoJugador[playerid][pPass], 129);
  233.     INI_Int("Dinero", InfoJugador[playerid][pDinero]);
  234.     INI_Int("Administrador", InfoJugador[playerid][pAdmin]);
  235.     INI_Int("Skin", InfoJugador[playerid][pSkin]);
  236.     return 1;
  237. }
  238.  
  239. /*forward GuardarCuenta(playerid);
  240. public GuardarCuenta(playerid)
  241. {
  242.     new INI:Arch = INI_Open(Usuario(playerid));
  243.     INI_SetTag(Arch,"[Cuenta del Jugador]");
  244.     INI_WriteInt(Arch, "Dinero", InfoJugador[playerid][pDinero]);
  245.     INI_WriteInt(Arch, "Administrador", InfoJugador[playerid][pAdmin]);
  246.     INI_WriteInt(Arch, "Skin", InfoJugador[playerid][pSkin]);
  247.     INI_Close(Arch);
  248.     return 1;
  249. }*/
  250.  
  251. stock Usuario(playerid)
  252. {
  253.     new string[128],nombre[MAX_PLAYER_NAME];
  254.     GetPlayerName(playerid, nombre, sizeof(nombre));
  255.     format(string, sizeof(string), Ruta, nombre);
  256.     return string;
  257. }
  258.  
  259. stock DarDinero(playerid, dinero)
  260. {
  261.     InfoJugador[playerid][pDinero] = dinero;
  262.     return GivePlayerMoney(playerid, dinero);
  263. }
  264.  
  265. stock PlayerName(playerid)
  266. {
  267.     new name[MAX_PLAYER_NAME];
  268.     GetPlayerName(playerid, name, sizeof(name));
  269.     return name;
  270. }
Advertisement
Add Comment
Please, Sign In to add comment