Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Guest Message by DevFuse
Wklejka 1ovpnqwnt1xc0 dodana przez speedkill, 02.11.2012 17:30
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251. 252. 253. 254.
#include <amxmodx>
#include <amxmisc>
#include <csx>
#define PLUGIN "Rangi"
#define VERSION "1.0.1"
#define AUTHOR "R3X"
// User stats parms id
#define STATS_KILLS 0
#define STATS_DEATHS 1
#define STATS_HS 2
#define STATS_TKS 3
#define STATS_SHOTS 4
#define STATS_HITS 5
#define STATS_DAMAGE 6
//Max count of levels
#define LEVELS 20
//Max len of ClassName
#define CLASS_LEN 25
#define MAX_NAME_LENGTH 31
#define MAX_BUFFER_LENGTH 2047
#define TASK_SHOWCLASS 2222
//Buffers
new t_sName[MAX_NAME_LENGTH + 1] = ""
new g_sBuffer[MAX_BUFFER_LENGTH + 1] = ""
new giXP[LEVELS+1];
new gszClass[LEVELS+1][CLASS_LEN];
new giPointer=1;
new gcvarMaxName;
new gcvarType, gcvarTop, gcvarList;
new gmsgSayText;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_dictionary("statsx.txt");
register_clcmd("say /top10", "cmdTop10", 0, "- wyswietla range i statystyki");
register_clcmd("say /rank", "cmdRank", 0, "- wyswietla range i statystyki");
register_clcmd("say /rangi", "cmdHelp", 0, "- wyswietla liste rang");
register_clcmd("say_team /top10", "cmdTop10", 0, "- wyswietla range i statystyki");
register_clcmd("say_team /rank", "cmdRank", 0, "- wyswietla range i statystyki");
register_clcmd("say_team /rangi", "cmdHelp", 0, "- wyswietla liste rang");
gcvarMaxName = register_cvar("rangi_maxname", "Reszta jest milczeniem");
gcvarType = register_cvar("rangi_hud","0");
gcvarTop = register_cvar("rangi_top10","1");
gcvarList = register_cvar("rangi_list","1");
gmsgSayText = get_user_msgid("SayText");
register_event( "ResetHUD", "eventUpdateStatus", "be");
register_event( "StatusValue", "eventUpdateStatus", "be", "1=1" ,"2=0");
}
//CONFIG
public plugin_cfg(){
new szFile[128];
get_configsdir(szFile, 127);
add(szFile, 127, "/rangi.ini");
if(!file_exists(szFile))
return set_fail_state("Nie znalaziono pliku ranga.ini w folderze configs/");
new szLine[96], iLen=0, szClass[CLASS_LEN], szXP[16];
for(new i=0;read_file(szFile, i, szLine, 95, iLen);i++,szClass[0]=szXP[0]='^0'){
if( giPointer > LEVELS) break;
if(iLen==0) continue;
trim(szLine);
if(szLine[0]=='^0' || szLine[0]==';') continue;
parse(szLine, szClass, CLASS_LEN-1, szXP, 15);
if(szClass[0] && szXP[0]){
giXP[giPointer]=str_to_num(szXP);
copy(gszClass[giPointer], CLASS_LEN-1, szClass)
giPointer++;
}
}
return PLUGIN_CONTINUE;
}
//COMMANDS
public cmdTop10(id){
if(get_pcvar_num(gcvarTop) <= 0){
print_colored(id, "* ^x04Top10^x01 jest wylaczone");
return PLUGIN_HANDLED;
}
format_top10(g_sBuffer)
show_motd(id, g_sBuffer, "Top 10")
return PLUGIN_CONTINUE;
}
public cmdRank(id)
{
static stats[8], body[8], rankpos, rankmax;
get_user_stats(id, stats, body);
rankpos = get_user_stats(id, stats, body);
rankmax = get_statsnum();
print_colored(id, "* Twoja ranga to^x04 %s^x01, zajmujesz^x03 %d^x01 pozycje z^x03 %d", get_rankname(stats[0]), rankpos, rankmax);
print_colored(id, "* Posiadasz^x03 %d^x01 zabojstw,^x03 %d^x01 smierci oraz^x03 %d^x01 headshot'ow, zadajac^x03 %d^x01 obrazen.", stats[STATS_KILLS ], stats[STATS_DEATHS], stats[STATS_HS], stats[STATS_DAMAGE]);
return PLUGIN_HANDLED;
}
public cmdHelp(id){
if(get_pcvar_num(gcvarList) <= 0){
print_colored(id, "* ^x04Lista rang^x01 jest niedostepna");
return PLUGIN_HANDLED;
}
static sBuffer[MAX_BUFFER_LENGTH+1];
new iLen;
iLen = formatex(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>")
iLen += formatex(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "#id Nazwa Prog^n");
if(giPointer > 1)
iLen += formatex(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%02d %-22.22s < %d^n", 1, gszClass[1], giXP[1]);
for(new i=2;i<giPointer;i++){
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%02d %-22.22s %d-%d^n", i, gszClass[i], giXP[i-1]+1,giXP[i]);
}
new szMaxName[CLASS_LEN];
get_pcvar_string(gcvarMaxName, szMaxName, CLASS_LEN-1);
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "* %s > %d", szMaxName, giXP[giPointer-1]);
show_motd(id, sBuffer, "Rangi");
return PLUGIN_HANDLED;
}
//FORWARDS
public eventUpdateStatus(id){
if(is_user_bot(id) || get_pcvar_num(gcvarType)==0)
return;
static stats[8], body[8];
get_user_stats(id, stats, body);
showStatus(id, "Ranga: %s Zabojstw: %d / %d", get_rankname(stats[STATS_KILLS ]), stats[STATS_KILLS ], giXP[get_lvl_by_exp(STATS_KILLS) + 1]);
}
stock showStatus(id, const szStatus[], ...){
new szBuffer[128];
vformat(szBuffer, 127, szStatus, 3);
static msgStatusText = 0;
if(!msgStatusText)
msgStatusText = get_user_msgid("StatusText");
message_begin(MSG_ONE, msgStatusText, _, id);
write_byte(0);
write_string(szBuffer);
message_end();
}
//CLASS
get_lvl_by_exp(iXP){
new i;
for(i=1;i<=giPointer;i++){
if(giXP[i]>=iXP)
break;
}
if(i > giPointer)
return -1;
return i;
}
get_rankname(frags){
static szClass[CLASS_LEN];
new iLvl=get_lvl_by_exp(frags);
if(iLvl>=0)
copy(szClass,CLASS_LEN-1, gszClass[iLvl]);
else
get_pcvar_string(gcvarMaxName, szClass, CLASS_LEN-1);
return szClass;
}
//RANK
// Stats formulas
Float:effec(izStats[8])
{
if(!izStats[STATS_KILLS])
return (0.0)
return (100.0 * float(izStats[STATS_KILLS]) / float(izStats[STATS_KILLS] + izStats[STATS_DEATHS]))
}
Float:accuracy(izStats[8])
{
if(!izStats[STATS_SHOTS])
return (0.0)
return (100.0 * float(izStats[STATS_HITS]) / float(izStats[STATS_SHOTS]))
}
// Get and format top 10
public format_top10(sBuffer[MAX_BUFFER_LENGTH + 1])
{
new iMax = get_statsnum()
new izStats[8], izBody[8]
new iLen = 0
if (iMax > 10)
iMax = 10;
new lKills[16], lDeaths[16], lHits[16], lShots[16], lEff[16], lAcc[16]
format(lKills, 15, "%L", LANG_SERVER, "KILLS")
format(lDeaths, 15, "%L", LANG_SERVER, "DEATHS")
format(lHits, 15, "%L", LANG_SERVER, "HITS")
format(lShots, 15, "%L", LANG_SERVER, "SHOTS")
format(lEff, 15, "%L", LANG_SERVER, "EFF")
format(lAcc, 15, "%L", LANG_SERVER, "ACC")
ucfirst(lEff)
ucfirst(lAcc)
iLen = format(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>")
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%2s %-22.22s %6s %6s %6s %6s %4s %4s %4s^n", "#", "Nick", "Level", lKills, lDeaths, lHits, lShots, "HS", lEff, lAcc)
for (new i = 0; i < iMax && MAX_BUFFER_LENGTH - iLen > 0; i++)
{
get_stats(i, izStats, izBody, t_sName, MAX_NAME_LENGTH)
replace_all(t_sName, MAX_NAME_LENGTH, "<", "[")
replace_all(t_sName, MAX_NAME_LENGTH, ">", "]")
iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%2d %-22.22s %-22.22s %6d %6d %6d %6d %4d %3.0f%% %3.0f%%^n", i + 1, t_sName,get_rankname(izStats[STATS_KILLS]), izStats[STATS_KILLS],
izStats[STATS_DEATHS], izStats[STATS_HITS], izStats[STATS_SHOTS], izStats[STATS_HS], effec(izStats), accuracy(izStats))
}
}
//STOCKS
stock print_colored(id, const text[], any:...)
{
static szMessage[192];
szMessage[0]='^x01';
vformat(szMessage[1], 190, text, 3);
if(id==0)
{
new plist[32], playernum;
get_players(plist, playernum);
for(new i = 0; i < playernum; i++)
{
id = plist[i];
message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id);
write_byte(id);
write_string(szMessage);
message_end();
}
}
else
{
message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id);
write_byte(id);
write_string(szMessage);
message_end();
}
}
Dodanych wklejek: 15354
Powered By (Pav32) Pastebin © 2011


Dodatki SourceMod


