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 21u3qp7smzms4 dodana przez Filip1512, 19.11.2013 18:32
play_time
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. 255. 256. 257. 258. 259. 260. 261. 262. 263. 264. 265. 266. 267. 268. 269. 270. 271. 272. 273. 274. 275. 276. 277. 278. 279. 280. 281. 282. 283. 284. 285. 286. 287. 288. 289. 290. 291. 292. 293. 294. 295. 296. 297. 298. 299. 300. 301. 302. 303. 304. 305. 306. 307. 308. 309. 310. 311. 312. 313. 314. 315. 316. 317. 318. 319. 320. 321. 322. 323. 324. 325. 326. 327. 328. 329. 330. 331. 332. 333. 334. 335. 336. 337. 338. 339. 340. 341. 342. 343. 344. 345. 346. 347. 348. 349. 350. 351. 352. 353. 354. 355. 356. 357. 358. 359. 360. 361. 362. 363. 364. 365. 366. 367. 368. 369. 370. 371. 372. 373. 374. 375. 376. 377. 378. 379.
#include <amxmodx> #include <cstrike> #include <nvault> #define MM_HOUR 3600 enum ChatColor{ CHATCOLOR_NORMAL = 1, CHATCOLOR_GREEN, CHATCOLOR_TEAM_COLOR, CHATCOLOR_GREY, CHATCOLOR_RED, CHATCOLOR_BLUE, } new g_TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" } new g_msgSayText new g_msgTeamInfo new const gNazwaPluginu[] = "Play Time Bonus"; new const gWersjaPluginu[] = "0.1"; new const gAutorPluginu[] = "MisieQ"; // pcvarki na bonusy new pcvar_pt, pcvar_pt_bonus new pcvar_pt_bonus_1h, pcvar_pt_bonus_5h, pcvar_pt_bonus_10h, pcvar_pt_bonus_20h, pcvar_pt_bonus_30h new g_Vault public plugin_init(){ register_plugin(gNazwaPluginu, gWersjaPluginu, gAutorPluginu); pcvar_pt = register_cvar("pt_enabled", "1") pcvar_pt_bonus = register_cvar("pt_bonus", "1") pcvar_pt_bonus_1h = register_cvar("pt_bonus_1h", "200") pcvar_pt_bonus_5h = register_cvar("pt_bonus_5h", "500") pcvar_pt_bonus_10h = register_cvar("pt_bonus_10h", "1000") pcvar_pt_bonus_20h = register_cvar("pt_bonus_20h", "2000") pcvar_pt_bonus_30h = register_cvar("pt_bonus_30h", "3000") register_event("SendAudio", "eventEndRound", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw") g_msgSayText = get_user_msgid("SayText") g_msgTeamInfo = get_user_msgid("TeamInfo") register_event("HLTV", "event_new_round", "a", "1=0", "2=0"); register_logevent("GameCommencing", 2, "1=Game_Commencing"); } new gRound=0; public event_new_round(){ ++gRound; } public GameCommencing(){ gRound=0; } // koniec pcvarek public plugin_cfg(){ if(get_pcvar_num(pcvar_pt)) { g_Vault = nvault_open("play_time") if(g_Vault == INVALID_HANDLE) { set_fail_state("Error opening nVault") } //nvault_prune(g_Vault , 0 , get_systime() - (30 * 86400 )) } } public plugin_end(){ if(get_pcvar_num(pcvar_pt)) { nvault_close(g_Vault) } } public client_disconnect(id){ if(get_pcvar_num(pcvar_pt)) { played_time(id) } } public eventEndRound(){ time_play_bonus() } public played_time(id){ new szPlayers[32], iNum, szKey[32], szData[128], szName[32] new szMinute[5], szHour[5], szDay[5], szMonth[5], szYear[5] new iMinute, iHour, iDay, iMonth, iYear format_time(szMinute, sizeof(szMinute) - 1, "%M") format_time(szHour, sizeof(szHour) - 1, "%H") format_time(szDay, sizeof(szDay) - 1, "%d") format_time(szMonth, sizeof(szMonth) - 1, "%m") format_time(szYear, sizeof(szYear) - 1, "%Y") iMinute = str_to_num(szMinute) iHour = str_to_num(szHour) iDay = str_to_num(szDay) iMonth = str_to_num(szMonth) iYear = str_to_num(szYear) get_players(szPlayers, iNum) get_user_name(id, szName, sizeof(szName) - 1) formatex(szKey, sizeof(szKey) - 1, "PLAYED_TIME#%s", szName) nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1) new iTime = str_to_num(szData) formatex(szData, sizeof(szData) - 1, "%d", iTime + (get_user_time(id))) nvault_set(g_Vault , szKey, szData) formatex(szKey, sizeof(szKey) - 1, "LAST_VISIT#%s", szName) formatex(szData, sizeof(szData) - 1, "%d %d %d %d %d", iDay, iMonth, iYear,iHour, iMinute) nvault_set(g_Vault , szKey, szData) formatex(szKey, sizeof(szKey) - 1, "TODAY_PLAY#%s", szName) nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1) new szToday[5], szTodayPlay[256] parse(szData, szToday, sizeof(szToday), szTodayPlay, sizeof(szTodayPlay)) if(str_to_num(szToday) != iDay) { formatex(szData, sizeof(szData) - 1, "%d 0", iDay) nvault_set(g_Vault , szKey, szData) } else { formatex(szData, sizeof(szData) - 1, "%d %d", iDay, (get_user_time(id) + str_to_num(szTodayPlay))) nvault_set(g_Vault , szKey, szData) } } // rozdawanie kasy public time_play_bonus(){ if(gRound<4) return PLUGIN_HANDLED; if(!get_pcvar_num(pcvar_pt_bonus) || !get_pcvar_num(pcvar_pt)) { return PLUGIN_HANDLED } new iCash, iTmpCash, iDay, szDay[5] new szPlayers[32], iNum, szName[32] new szKey[50], szData[128] new iCash_1h = get_pcvar_num(pcvar_pt_bonus_1h) new iCash_5h = get_pcvar_num(pcvar_pt_bonus_5h) new iCash_10h = get_pcvar_num(pcvar_pt_bonus_10h) new iCash_20h = get_pcvar_num(pcvar_pt_bonus_20h) new iCash_30h = get_pcvar_num(pcvar_pt_bonus_30h) format_time(szDay, sizeof(szDay) - 1, "%d") iDay = str_to_num(szDay) get_players(szPlayers, iNum) for(new i = 0; i < iNum; i++) { if(cs_get_user_team(szPlayers[i]) == CS_TEAM_SPECTATOR) { continue } get_user_name(szPlayers[i], szName, sizeof(szName) - 1) formatex(szKey, sizeof(szKey) - 1, "TODAY_PLAY#%s", szName) nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1) new szToday[5], szTodayPlay[256] parse(szData, szToday, sizeof(szToday), szTodayPlay, sizeof(szTodayPlay)) if(iDay != str_to_num(szToday)) { formatex(szData, sizeof(szData) - 1, "%d 0", iDay) nvault_set(g_Vault, szKey, szData) continue } new iTime = (get_user_time(szPlayers[i]) + str_to_num(szTodayPlay)) / MM_HOUR iCash = cs_get_user_money(szPlayers[i]) if(!iTime) { continue } if(iTime == 1 && iCash_1h != 0) { if((iCash + iCash_1h) > 16000) { cs_set_user_money(szPlayers[i], 16000) } else { cs_set_user_money(szPlayers[i], iCash + iCash_1h) } iTmpCash = iCash_1h } if(iTime == 5 && iCash_5h != 0) { if((iCash + iCash_5h) > 16000) { cs_set_user_money(szPlayers[i], 16000) } else { cs_set_user_money(szPlayers[i], iCash + iCash_5h) } iTmpCash = iCash_5h } if(iTime == 10 && iCash_10h != 0) { if((iCash + iCash_10h) > 16000) { cs_set_user_money(szPlayers[i], 16000) } else { cs_set_user_money(szPlayers[i], iCash + iCash_10h) } iTmpCash = iCash_10h } if(iTime == 20 && iCash_20h != 0) { if((iCash + iCash_20h) > 16000) { cs_set_user_money(szPlayers[i], 16000) } else { cs_set_user_money(szPlayers[i], iCash + iCash_20h) } iTmpCash = iCash_20h } if(iTime > 30 && iCash_30h != 0) { if((iCash + iCash_30h) > 16000) { cs_set_user_money(szPlayers[i], 16000) } else { cs_set_user_money(szPlayers[i], iCash + iCash_30h) } iTmpCash = iCash_30h } colorChat(szPlayers[i], CHATCOLOR_GREEN, "Grasz juz u nas $t%d h.$g dlatego dostajesz $t%d$$g bonusu", iTime, iTmpCash) } return PLUGIN_HANDLED } // koniec rozdawania kasy colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...){ new team, index, MSG_Type new bool:teamChanged = false static message[192] switch(color) { case CHATCOLOR_NORMAL: // Normal { message[0] = 0x01; } case CHATCOLOR_GREEN: // Green { message[0] = 0x04; } default: // Grey, Red, Blue { message[0] = 0x03; } } vformat(message[1], 190, msg, 4); replace_all(message, 190, "$g", "^x04") replace_all(message, 190, "$n", "^x01") replace_all(message, 190, "$t", "^x03") if(id == 0) { index = findAnyPlayer(); MSG_Type = MSG_ALL; } else { index = id; MSG_Type = MSG_ONE; } if(index != 0) { team = get_user_team(index); if(color == CHATCOLOR_RED && team != 1) { messageTeamInfo(index, MSG_Type, g_TeamName[1]) teamChanged = true } else if(color == CHATCOLOR_BLUE && team != 2) { messageTeamInfo(index, MSG_Type, g_TeamName[2]) teamChanged = true } else if(color == CHATCOLOR_GREY && team != 0) { messageTeamInfo(index, MSG_Type, g_TeamName[0]) teamChanged = true } messageSayText(index, MSG_Type, message); if(teamChanged) { messageTeamInfo(index, MSG_Type, g_TeamName[team]) } } } messageSayText(id, type, message[]){ message_begin(type, g_msgSayText, _, id) write_byte(id) write_string(message) message_end() } messageTeamInfo(id, type, team[]){ message_begin(type, g_msgTeamInfo, _, id) write_byte(id) write_string(team) message_end() } findAnyPlayer(){ static players[32], inum, pid get_players(players, inum, "ch") for (new a = 0; a < inum; a++) { pid = players[a] if(is_user_connected(pid)) return pid } return 0 }
Dodanych wklejek: 4031
Powered By (Pav32) Pastebin © 2011