Advertisement
Guest User

Untitled

a guest
Feb 28th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <dini>
  3. #include <dudb>
  4.  
  5.  
  6.  
  7. new IsLogged[MAX_PLAYERS], file[128];
  8.  
  9.  
  10. enum pInfo
  11. {
  12. AdminLevel,
  13. SkinID,
  14. PlayerLevel,
  15. Cash,
  16. Banned,
  17. Sindacco,
  18. Tier,
  19. Faction,
  20. Rank [256],
  21. }
  22. new PlayerInfo[MAX_PLAYERS][pInfo];
  23.  
  24. //==========================================//Moving the stored data in "Rank" into the
  25. //==========================================//variable "pprank" and assigning it with the playerid.
  26.  
  27. public OnPlayerConnect(playerid)
  28. {
  29. GetPlayerName(playerid, aname, sizeof(aname));
  30. format(stri, sizeof(stri), "%s.ini", aname);
  31. if(fexist(stri))
  32. {
  33. new pprank[256];
  34. pprank = dini_Get(stri, "Rank");
  35. PlayerInfo [playerid] [Rank] = strval(pprank);
  36. }
  37. return 1;
  38. }
  39.  
  40. // On OnPlayerDisconnect it is reset. ( The rank )
  41.  
  42. //===============// The faction chat /f ( The problem is that it does not show the rank )
  43.  
  44. if (strcmp(cmd, "/f", true) == 0)
  45. {
  46. GetPlayerName(playerid, name, sizeof(name));
  47. format(file, sizeof(file), "%s.ini", name);
  48. if(fexist(file))
  49. {
  50. new temp[256], temp2[256], temp3[256];
  51. temp = dini_Get(file, "Faction");
  52. temp2 = dini_Get(file, "Sindacco");
  53. temp3 = dini_Get(file, "Rank");
  54. if(strval(temp) > 0 && strval(temp2) > 0)
  55. {
  56. if(strlen(pID) == 0) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /f [Message].");
  57. kreplace(name, '_', ' ');
  58. format(s, sizeof(s), "(( %s %s says: %s ))",strval(PlayerInfo [playerid] [Rank]) ,name, cmdtext[3]);
  59. for( q = 0; q <= MAX_PLAYERS; q++)
  60. {
  61. GetPlayerName(q, pname, sizeof(pname));
  62. format(strin, sizeof(strin), "%s.ini", pname);
  63. if(fexist(strin))
  64. {
  65. new atemp[256], atemp2[256];
  66. atemp = dini_Get(strin, "Faction");
  67. atemp2 = dini_Get(file, "Sindacco");
  68. if(strval(atemp) > 0 && strval(atemp2) > 0)
  69. {
  70. SendClientMessage(q, COLOR_BRIGHT_YELLOW, s);
  71. }
  72. }
  73. }
  74. }
  75. else SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to perform this command.");
  76. }
  77. return 1;
  78. }
  79.  
  80. //=======================================// Setting the player's rank and storing it inside the
  81. //=======================================// "Rank" inside the player's file.
  82.  
  83. if(strcmp(cmd, "/setrank", true) == 0)
  84. {
  85. new tmp[256], tmp1[256], tmp2[256], tmp4[256], fRank[256];
  86. fRank = strtok1(cmdtext, idx);
  87. GetPlayerName(playerid, pname, sizeof(pname));
  88. format(strin, sizeof(strin), "%s.ini", pname);
  89. if(fexist(strin))
  90. {
  91. tmp1 = dini_Get(strin, "Faction");
  92. tmp2 = dini_Get(strin, "Tier");
  93. tmp4 = dini_Get(strin, "Sindacco");
  94. if(strval(tmp1) == 1 && strval(tmp2) == 0)
  95. {
  96. GetPlayerName(strval(pID), name, sizeof(name));
  97. format(file, sizeof(file), "%s.ini", name);
  98. if(!IsPlayerConnected(strval(pID))) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Wrong player name or player ID.");
  99. if(fexist(file))
  100. {
  101. if(strlen(pID) == 0) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /setrank [PlayerID] [Rank].");
  102. tmp = dini_Get(file, "Faction");
  103. if(strval(tmp) == 1)
  104. {
  105. new tmp3[256];
  106. tmp3 = dini_Get(file, "Sindacco");
  107. if( strval(tmp3) == strval(tmp4) )
  108. {
  109. dini_Set(file, "Rank", fRank);
  110. PlayerInfo [strval(pID)] [Rank] = strval(fRank);
  111. GetPlayerName(strval(pID), aname, sizeof(aname));
  112. kreplace(aname, '_', ' ');
  113. format(str, sizeof(str), "(Sindacco): %s's rank has been changed to %s", aname, cmdtext[10+strlen(pID)]);
  114. SendClientMessage(strval(pID), COLOR_FMESSAGES, str);
  115. }
  116. }
  117. else SendClientMessage(playerid, COLOR_ERROR, "ERROR: Selected player is not in any faction.");
  118. }
  119. else SendClientMessage(playerid, COLOR_ERROR, "ERROR: Wrong player name or player ID.");
  120. }
  121. else SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to use this command.");
  122. }
  123. return 1;
  124. }
  125.  
  126. //====================================// What may be wrong? When I go to the player's file, it
  127. //====================================// shows only the first four letters of the rank, why?
  128. //====================================// May I not store and load words using dini?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement