Guest User

GM ERROR!

a guest
Sep 25th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.20 KB | None | 0 0
  1. //Proyecto Truck  -  Empezado 25/09/2012
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4.  
  5. native WP_Hash(buffer[], len, const str[]);
  6.  
  7. #pragma tabsize 0
  8. //Dialogs
  9.  
  10.  
  11. //Defines
  12. #define DIALOG_REGISTER 1
  13. #define DIALOG_LOGIN 2
  14. #define DIALOG_SUCCESS_1 3
  15. #define DIALOG_SUCCESS_2 4
  16.  
  17. #define COL_WHITE "{FFFFFF}"
  18. #define COL_RED "{F81414}"
  19. #define COL_GREEN "{00FF22}"
  20. #define COL_LIGHTBLUE "{00CED1}"
  21.  
  22.  
  23. #define PATH "/Usuarios/%s.ini"
  24. //Enums
  25. enum pInfo
  26. {
  27.     pPass[129],
  28.     pCash,
  29.     pAdmin,
  30.     pKills,
  31.     pDeaths
  32. }
  33. new PlayerInfo[MAX_PLAYERS][pInfo];
  34.  
  35.  
  36. main()
  37. {
  38.     print("\n----------------------------------");
  39.     print(" Truck");
  40.     print("----------------------------------\n");
  41. }
  42.  
  43.  
  44. public OnGameModeInit()
  45. {
  46.     SetGameModeText("Truck");
  47.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  48.     return 1;
  49. }
  50.  
  51. public OnGameModeExit()
  52. {
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerRequestClass(playerid, classid)
  57. {
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerConnect(playerid)
  62. {
  63.     if(fexist(UserPath(playerid)))
  64.     {
  65.         INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
  66.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  67.     }
  68.     else
  69.     {
  70.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  71.     }
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77.     new INI:File = INI_Open(UserPath(playerid));
  78.     INI_SetTag(File,"PlayerData");
  79.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  80.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  81.     INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  82.     INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  83.     INI_Close(File);
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerSpawn(playerid)
  88. {
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerDeath(playerid, killerid, reason)
  93. {
  94.     PlayerInfo[killerid][pKills]++;
  95.     PlayerInfo[playerid][pDeaths]++;
  96.     return 1;
  97. }
  98.  
  99. public OnVehicleSpawn(vehicleid)
  100. {
  101.     return 1;
  102. }
  103.  
  104. public OnVehicleDeath(vehicleid, killerid)
  105. {
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerText(playerid, text[])
  110. {
  111.     return 1;
  112. }
  113.  
  114. public OnPlayerCommandText(playerid, cmdtext[])
  115. {
  116.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  117.     {
  118.         // Do something here
  119.         return 1;
  120.     }
  121.     return 0;
  122. }
  123.  
  124. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  125. {
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerExitVehicle(playerid, vehicleid)
  130. {
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerStateChange(playerid, newstate, oldstate)
  135. {
  136.     return 1;
  137. }
  138.  
  139. public OnPlayerEnterCheckpoint(playerid)
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerLeaveCheckpoint(playerid)
  145. {
  146.     return 1;
  147. }
  148.  
  149. public OnPlayerEnterRaceCheckpoint(playerid)
  150. {
  151.     return 1;
  152. }
  153.  
  154. public OnPlayerLeaveRaceCheckpoint(playerid)
  155. {
  156.     return 1;
  157. }
  158.  
  159. public OnRconCommand(cmd[])
  160. {
  161.     return 1;
  162. }
  163.  
  164. public OnPlayerRequestSpawn(playerid)
  165. {
  166.     return 1;
  167. }
  168.  
  169. public OnObjectMoved(objectid)
  170. {
  171.     return 1;
  172. }
  173.  
  174. public OnPlayerObjectMoved(playerid, objectid)
  175. {
  176.     return 1;
  177. }
  178.  
  179. public OnPlayerPickUpPickup(playerid, pickupid)
  180. {
  181.     return 1;
  182. }
  183.  
  184. public OnVehicleMod(playerid, vehicleid, componentid)
  185. {
  186.     return 1;
  187. }
  188.  
  189. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  190. {
  191.     return 1;
  192. }
  193.  
  194. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  195. {
  196.     return 1;
  197. }
  198.  
  199. public OnPlayerSelectedMenuRow(playerid, row)
  200. {
  201.     return 1;
  202. }
  203.  
  204. public OnPlayerExitedMenu(playerid)
  205. {
  206.     return 1;
  207. }
  208.  
  209. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  210. {
  211.     return 1;
  212. }
  213.  
  214. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  215. {
  216.     return 1;
  217. }
  218.  
  219. public OnRconLoginAttempt(ip[], password[], success)
  220. {
  221.     return 1;
  222. }
  223.  
  224. public OnPlayerUpdate(playerid)
  225. {
  226.     return 1;
  227. }
  228.  
  229. public OnPlayerStreamIn(playerid, forplayerid)
  230. {
  231.     return 1;
  232. }
  233.  
  234. public OnPlayerStreamOut(playerid, forplayerid)
  235. {
  236.     return 1;
  237. }
  238.  
  239. public OnVehicleStreamIn(vehicleid, forplayerid)
  240. {
  241.     return 1;
  242. }
  243.  
  244. public OnVehicleStreamOut(vehicleid, forplayerid)
  245. {
  246.     return 1;
  247. }
  248.  
  249. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  250. {
  251.     switch( dialogid )
  252.     {
  253.         case DIALOG_REGISTER:
  254.         {
  255.             if (!response) return Kick(playerid);
  256.             if(response)
  257.             {
  258.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Making your account ..",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  259.                 new INI:File = INI_Open(UserPath(playerid));
  260.                 INI_SetTag(File,"PlayerData");
  261.                 new HashPass[129];
  262.                 WP_Hash(HashPass, sizeof(HashPass), inputtext);
  263.                 INI_WriteString(File, "Password", HashPass);
  264.                 INI_WriteInt(File,"Cash",GivePlayerMoney(playerid,5000));
  265.                 INI_WriteInt(File,"Admin",-1);
  266.                 INI_WriteInt(File,"Kills",0);
  267.                 INI_WriteInt(File,"Deaths",0);
  268.                 INI_Close(File);
  269.  
  270.                 SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  271.                 ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Account created!",""COL_GREEN"You've created an account successfuly. Relogging is recommended.","Ok","");
  272.             }
  273.         }
  274.  
  275.         case DIALOG_LOGIN:
  276.         {
  277.             if ( !response ) return Kick ( playerid );
  278.             if( response )
  279.             {
  280.                 new HashPass[129];
  281.                 WP_Hash(HashPass, sizeof(HashPass), inputtext);
  282.                 if(strcmp(HashPass, PlayerInfo[playerid][pPass]) == 0)
  283.                 {
  284.                     INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
  285.                     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  286.                     ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
  287.                 }
  288.                 else
  289.                 {
  290.                     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  291.                 }
  292.                 return 1;
  293.             }
  294.         }
  295.     }
  296.     return 1;
  297. }
  298.  
  299. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  300. {
  301.     return 1;
  302. }
  303.  
  304. //Publics y Stocks
  305. forward LoadUser_data(playerid,name[],value[]);
  306. public LoadUser_data(playerid,name[],value[])
  307. {
  308.     INI_String("Password",PlayerInfo[playerid][pPass], 129);
  309.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  310.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  311.     INI_Int("Kills",PlayerInfo[playerid][pKills]);
  312.     INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  313.     return 1;
  314. }
  315.  
  316. stock UserPath(playerid)
  317. {
  318.     new string[128],playername[MAX_PLAYER_NAME];
  319.     GetPlayerName(playerid,playername,sizeof(playername));
  320.     format(string,sizeof(string),PATH,playername);
  321.     return string;
  322. }
Advertisement
Add Comment
Please, Sign In to add comment