Fitri_Fahim

BUG D:

Jun 20th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. //:o
  2.  
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5.  
  6.  
  7.  
  8. #define PATH "/PlayerCoin/%s.ini"
  9.  
  10.  
  11.  
  12. enum pInfo
  13. {
  14. pCoin,
  15. }
  16. new PlayerInfo[MAX_PLAYERS][pInfo];
  17.  
  18. forward LoadUser_data(playerid,name[],value[]);
  19. public LoadUser_data(playerid,name[],value[])
  20. {
  21. INI_Int("Fa-Coins",PlayerInfo[playerid][pCoin]);
  22. return 1;
  23. }
  24.  
  25. stock UserPath(playerid)
  26. {
  27. new string[128],playername[MAX_PLAYER_NAME];
  28. GetPlayerName(playerid,playername,sizeof(playername));
  29. format(string,sizeof(string),PATH,playername);
  30. return string;
  31. }
  32.  
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36. if(fexist(UserPath(playerid)))
  37. {
  38. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  39. }
  40. else
  41. {
  42. new INI:File = INI_Open(UserPath(playerid));
  43. INI_SetTag(File,"data");
  44. INI_WriteInt(File,"Fa-Coins",0);
  45. INI_Close(File);
  46. }
  47. return 1;
  48. }
  49.  
  50. public OnPlayerDisconnect(playerid, reason)
  51. {
  52. new INI:File = INI_Open(UserPath(playerid));
  53. INI_SetTag(File,"data");
  54. INI_WriteInt(File,"Fa-Coin",PlayerInfo[playerid][pCoin]);
  55. INI_Close(File);
  56. return 1;
  57. }
  58.  
  59.  
  60.  
  61. public OnPlayerCommandText(playerid, cmdtext[])
  62. {
  63. if(!strcmp(cmdtext, "/mycoins", true)) // 3 is the length of /me
  64. {
  65. new str[128];
  66. GetPlayerName(playerid, str, sizeof(str));
  67. format(str, sizeof(str), "Name: %s Fa-Coins: %d", str, PlayerInfo[playerid][pCoin]);
  68. SendClientMessage(playerid,-1, str);
  69. return 1;
  70. }
  71. if(!strcmp(cmdtext, "/needcoin", true)) // 3 is the length of /me
  72. {
  73. GivePlayerCoin(playerid,20);
  74. new str[128];
  75. GetPlayerName(playerid, str, sizeof(str));
  76. format(str, sizeof(str), "Name: %s Fa-Coins: %d", str, PlayerInfo[playerid][pCoin]);
  77. SendClientMessage(playerid,-1, str);
  78. return 1;
  79. }
  80. return 0;
  81. }
  82.  
  83.  
  84. stock GivePlayerCoin(playerid,amount)
  85. {
  86. PlayerInfo[playerid][pCoin] += amount;
  87. return 1;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment