Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.73 KB | None | 0 0
  1.  
  2. // 인클루드
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <cstrike>
  6. #include <geoip.inc>
  7. #include <string.inc>
  8. #include <sdkhooks>
  9.  
  10. #pragma semicolon 1
  11.  
  12. #define die1 "booster.wav"
  13. #define die2 "emfty.wav"
  14. #define die3 "full.wav"
  15. #define Color "\x07FF80FF"
  16. #define Color2 "\x07F84960"
  17. #define Color3 "\x07FAF4C0"
  18. #define Color4 "\x07664B00"
  19. #define DMG_FALL (1 << 5)
  20.  
  21. // 저장을 위한 선언
  22. new String:Path[MAXPLAYERS+1];
  23. new const GodColor[3] = {255, 255, 255};//R, G, B
  24. // 초 , 분 , 시간 , 일 선언
  25. new second[MAXPLAYERS+1];
  26. new minute[MAXPLAYERS+1];
  27. new times[MAXPLAYERS+1];
  28. new day[MAXPLAYERS+1];
  29. new Booster[MAXPLAYERS+1] = 0;
  30. new Full = 100;
  31. new BoosterCoolTimeCheck[MAXPLAYERS+1] = 0;
  32. new BCTCounter[MAXPLAYERS+1] = 5;
  33. new Boosterroundcheck = 0;
  34.  
  35. // 옆에 뜨는 Total Playing Time 되게 하는거
  36. new Handle:INFO[MAXPLAYERS+1];
  37. new Handle:htimer[MAXPLAYERS+1];
  38. new Handle:GodTimer;
  39. new Handle:CoolTime[MAXPLAYERS+1] = INVALID_HANDLE;
  40. new Handle:BoosterPower = INVALID_HANDLE;
  41.  
  42. public OnPluginStart()
  43. {
  44. RegConsoleCmd("sm_booster",booster,"부스터온");
  45.  
  46. HookEvent("player_spawn",eventspawn);
  47. HookEvent("round_start", eventstart);
  48. HookEvent("round_end",eventend);
  49.  
  50. BoosterPower = CreateConVar("sv_bpower","1200.0","부스터 파워 값(원래값의 1/80 ~ 1/100으로만설정바람)",FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED);
  51. AutoExecConfig(true,"BoosterGage");
  52. }
  53.  
  54. // 플러그인 스타트
  55. public OnMapStart()
  56. {
  57. BuildPath(Path_SM, Path, 64, "data/timerserver_db.txt");
  58. decl String:File1[256];
  59. Format(File1, 256, "sound/%s", die1);
  60. AddFileToDownloadsTable(File1);
  61. PrecacheSound(die1, true);
  62.  
  63. decl String:File2[256];
  64. Format(File2, 256, "sound/%s", die2);
  65. AddFileToDownloadsTable(File2);
  66.  
  67. PrecacheSound(die2, true);
  68.  
  69. decl String:file3[256];
  70. Format(file3, 256, "sound/%s", die3);
  71. AddFileToDownloadsTable(file3);
  72.  
  73. PrecacheSound(die3, true);
  74. }
  75.  
  76. public Action:eventstart(Handle:event, const String:name[], bool:dontBroadcast)
  77. {
  78. new Client = GetClientOfUserId(GetEventInt(event,"userid"));
  79. CreateTimer(0.1, GameStartTimer, Client);
  80.  
  81. for (new i = 1; i <= MaxClients; i++)
  82. {
  83. if (IsClientInGame(i) && IsPlayerAlive(i))
  84. {
  85. SetEntProp(i, Prop_Data, "m_takedamage", 0, 1);
  86. SetEntityRenderColor(i, GodColor[0], GodColor[1], GodColor[2], 150);
  87. PrintToChat(i, "\x04[System Chat] \x03라운드 시작\x04 7\x03초간 무적상태가 됩니다.");
  88.  
  89. GodTimer = CreateTimer(7.0, GOD_END, i);
  90. }
  91. }
  92. }
  93.  
  94. public Action:OnTakeDamage(victim, &attacker, &inflict, &Float:damage, &damagetype)
  95. {
  96. if(damagetype & DMG_FALL)
  97. {
  98. damage = 0.0;
  99. return Plugin_Handled;
  100. }
  101. return Plugin_Continue;
  102. }
  103.  
  104. public Action:GameStartTimer(Handle:timer, any:Client)
  105. {
  106. if(GetTeamClientCount(1)+GetTeamClientCount(2)+GetTeamClientCount(3) == 0)
  107. {
  108. Boosterroundcheck = 0;
  109. PrintToChat(Client, "\x04[SM] - \x05지금은 부스터를 사용할 수 없습니다.");
  110. }
  111. else if(GetTeamClientCount(1)+GetTeamClientCount(2)+GetTeamClientCount(3) != 0)
  112. {
  113. Boosterroundcheck = 1;
  114. }
  115. }
  116.  
  117.  
  118. public Action:GOD_END(Handle:timer, any:Client)
  119. {
  120. if(IsPlayerAlive(Client) == true)
  121. {
  122. SetEntProp(Client, Prop_Data, "m_takedamage", 2, 1);
  123. SetEntityRenderColor(Client, 255, 255, 255, 255);
  124. PrintToChat(Client, "\x04[System Chat] \x03무적상태가 해제되었습니다.");
  125. GodTimer = INVALID_HANDLE;
  126. }
  127. }
  128.  
  129. public Action:eventend(Handle:event, const String:name[], bool:Brodcast)
  130. {
  131. for(new i = 0;i <= MaxClients; i++)
  132. {
  133. if(CoolTime[i] != INVALID_HANDLE)
  134. {
  135. KillTimer(CoolTime[i]);
  136. CoolTime[i] = INVALID_HANDLE;
  137. }
  138. }
  139. }
  140.  
  141. public OnMapEnd()
  142. {
  143. for(new i = 1; i <= MaxClients; i++)
  144. {
  145. Save(i);
  146. KillTimer(htimer[i]);
  147. KillTimer(INFO[i]);
  148. KillTimer(GodTimer);
  149. if(CoolTime[i] != INVALID_HANDLE)
  150. {
  151. KillTimer(CoolTime[i]);
  152. CoolTime[i] = INVALID_HANDLE;
  153. }
  154. }
  155. }
  156.  
  157. public OnClientDisconnect(Client)
  158. {
  159. Save(Client);
  160. KillTimer(htimer[Client]);
  161. KillTimer(INFO[Client]);
  162. KillTimer(GodTimer);
  163. KillTimer(CoolTime[Client]);
  164. }
  165.  
  166. public Action:eventspawn(Handle:Event, const String:Name[], bool:Broadcast)
  167. {
  168. new Client = GetClientOfUserId(GetEventInt(Event,"userid"));
  169. BCTCounter[Client] = 5;
  170. BoosterCoolTimeCheck[Client] = 0;
  171. Booster[Client] = 100;
  172. PrintToChat(Client,"\x04[SM] - \x05부스터 게이지가 초기화 되었습니다.");
  173. EmitSoundToAll(die3, SOUND_FROM_PLAYER, _, _, _, 1.0);
  174. }
  175.  
  176. public Action:booster(Client,Arguments)
  177. {
  178. if(Boosterroundcheck == 1)
  179. {
  180. new Float:BPower = GetConVarFloat(BoosterPower);
  181. if(AliveCheck(Client) == true && BoosterCoolTimeCheck[Client] == 0)
  182. {
  183. if(Booster[Client] >= 1)
  184. {
  185. new Float:eye[3],Float:angle[3];
  186. GetClientEyeAngles(Client,angle);
  187. GetAngleVectors(angle,eye,NULL_VECTOR,NULL_VECTOR);
  188. NormalizeVector(eye,eye);
  189. ScaleVector(eye,Booster[Client]*BPower);
  190. TeleportEntity(Client, NULL_VECTOR, NULL_VECTOR, eye);
  191. PrintToChat(Client,"\x04[SM] - \x05부스터 게이지가 방출되었습니다[쿨타임 5초].");
  192. new String:name[64];
  193. GetClientName(Client, name, sizeof(name));
  194. PrintCenterTextAll("===[%s]=== 님이 부스터를 사용하셨습니다.", name);
  195. EmitSoundToAll(die1, SOUND_FROM_PLAYER, _, _, _, 1.0);
  196. Booster[Client] = 0;
  197. BoosterCoolTimeCheck[Client] = 1;
  198. CoolTime[Client] = CreateTimer(1.0, BCT, Client, TIMER_REPEAT);
  199. }
  200. else if(Booster[Client] == 0)
  201. {
  202. PrintToChat(Client,"\x04[SM] - \x05부스터 게이지가 부족합니다.");
  203. EmitSoundToAll(die2, SOUND_FROM_PLAYER, _, _, _, 1.0);
  204. }
  205. }
  206. else if(AliveCheck(Client) == true && BoosterCoolTimeCheck[Client] == 1)
  207. {
  208. PrintToChat(Client, "\x04[SM] - \x05아직 쿨타임 입니다[%d 초 남음]", BCTCounter[Client]);
  209. }
  210. }
  211. else if(Boosterroundcheck == 0)
  212. {
  213. PrintToChat(Client,"\x04[SM] - \x05지금은 사용 하실수 없습니다.");
  214. }
  215. return Plugin_Handled;
  216. }
  217.  
  218. public Action:BCT(Handle:timer, any:Client)
  219. {
  220. BCTCounter[Client] -= 1;
  221.  
  222. if(BCTCounter[Client] == 0)
  223. {
  224. PrintToChat(Client, "\x04[SM] - \x05부스터 시전 가능");
  225. BCTCounter[Client] = 5;
  226. BoosterCoolTimeCheck[Client] = 0;
  227. KillTimer(CoolTime[Client]);
  228. CoolTime[Client] = INVALID_HANDLE;
  229. }
  230. }
  231.  
  232. // 저장임 적당히 응용이 쉬움
  233. public Action:Save(Client)
  234. {
  235. if(Client > 0 && IsClientInGame(Client))
  236. {
  237. new String:SteamID[32];
  238. GetClientAuthString(Client, SteamID, 32);
  239.  
  240. decl Handle:Vault;
  241.  
  242. Vault = CreateKeyValues("Vault");
  243.  
  244. if(FileExists(Path))
  245. {
  246. FileToKeyValues(Vault, Path);
  247. }
  248.  
  249. if(second[Client] > 0)
  250. {
  251. KvJumpToKey(Vault, "second", true);
  252. KvSetNum(Vault, SteamID, second[Client]);
  253. KvRewind(Vault);
  254. }
  255. else
  256. {
  257. KvJumpToKey(Vault, "second", false);
  258. KvDeleteKey(Vault, SteamID);
  259. KvRewind(Vault);
  260. }
  261.  
  262. if(minute[Client] > 0)
  263. {
  264. KvJumpToKey(Vault, "minute", true);
  265. KvSetNum(Vault, SteamID, minute[Client]);
  266. KvRewind(Vault);
  267. }
  268. else
  269. {
  270. KvJumpToKey(Vault, "minute", false);
  271. KvDeleteKey(Vault, SteamID);
  272. KvRewind(Vault);
  273. }
  274.  
  275. if(times[Client] > 0)
  276. {
  277. KvJumpToKey(Vault, "times", true);
  278. KvSetNum(Vault, SteamID, times[Client]);
  279. KvRewind(Vault);
  280. }
  281. else
  282. {
  283. KvJumpToKey(Vault, "times", false);
  284. KvDeleteKey(Vault, SteamID);
  285. KvRewind(Vault);
  286. }
  287.  
  288. if(day[Client] > 0)
  289. {
  290. KvJumpToKey(Vault, "day", true);
  291. KvSetNum(Vault, SteamID, day[Client]);
  292. KvRewind(Vault);
  293. }
  294. else
  295. {
  296. KvJumpToKey(Vault, "day", false);
  297. KvDeleteKey(Vault, SteamID);
  298. KvRewind(Vault);
  299. }
  300.  
  301. KvRewind(Vault);
  302.  
  303. KeyValuesToFile(Vault, Path);
  304.  
  305. CloseHandle(Vault);
  306. }
  307. }
  308.  
  309. // 로드임 이거역시 응용하기 쉬움
  310. public Action:Load(Client)
  311. {
  312. if(Client > 0 && Client <= MaxClients)
  313. {
  314. new String:SteamID[32];
  315. GetClientAuthString(Client, SteamID, 32);
  316.  
  317. decl Handle:Vault;
  318.  
  319. Vault = CreateKeyValues("Vault");
  320.  
  321. FileToKeyValues(Vault, Path);
  322.  
  323. KvJumpToKey(Vault, "second", false);
  324. second[Client] = KvGetNum(Vault, SteamID);
  325. KvRewind(Vault);
  326.  
  327. KvJumpToKey(Vault, "minute", false);
  328. minute[Client] = KvGetNum(Vault, SteamID);
  329. KvRewind(Vault);
  330.  
  331. KvJumpToKey(Vault, "times", false);
  332. times[Client] = KvGetNum(Vault, SteamID);
  333. KvRewind(Vault);
  334.  
  335. KvJumpToKey(Vault, "day", false);
  336. day[Client] = KvGetNum(Vault, SteamID);
  337. KvRewind(Vault);
  338.  
  339. CloseHandle(Vault);
  340. }
  341. }
  342.  
  343. public OnClientPutInServer(Client)
  344. {
  345. Load(Client);
  346. SDKHook(Client, SDKHook_OnTakeDamage, OnTakeDamage);
  347. htimer[Client] = CreateTimer(1.0, ServerTimer, Client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  348. INFO[Client] = CreateTimer(0.5, ShowCountText2, Client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  349. PrintToChat(Client, "\x04당신의 플레이 시간 \x03 %d일 %d시간 %d분 %d초", day[Client], times[Client], minute[Client], second[Client]);
  350. }
  351.  
  352. public Action:ServerTimer(Handle:Timer, any:Client)
  353. {
  354. if(IsClientInGame(Client) && IsPlayerAlive(Client))
  355. {
  356. second[Client] += 1;
  357.  
  358. // 만약... 60초 라면
  359. if(second[Client] == 60)
  360. {
  361. // 1분 추가
  362. minute[Client] += 1;
  363. // 60초 감소
  364. second[Client] -= 60;
  365. }
  366. // 만약... 60분 이라면
  367. if(minute[Client] == 60)
  368. {
  369. // 1시간 추가
  370. times[Client] += 1;
  371. // 60분 감소
  372. minute[Client] -= 60;
  373. }
  374. // 만약... 24시간 이라면
  375. if(times[Client] == 24)
  376. {
  377. // 1일을 더해준다
  378. day[Client] += 1;
  379. // 24시간을 감소
  380. times[Client] -= 24;
  381. }
  382. }
  383. }
  384.  
  385. public Action:ShowCountText2(Handle:timer, any:Client)
  386. {
  387. new CT = 0;
  388. new TR = 0;
  389. new plus = 0;
  390.  
  391. for(new i = 1;i <= MaxClients; i++)
  392. {
  393. if(IsClientInGame(i) && IsPlayerAlive(i))
  394. {
  395. if(GetClientTeam(i) == 2) TR++;
  396. else if(GetClientTeam(i) == 3) CT++;
  397. plus++;
  398. }
  399. }
  400. if(IsClientInGame(Client))
  401. {
  402. ActionBooster(Client);
  403. decl String:HudText[256];
  404. Format(HudText, sizeof(HudText), "◎Alive|CT : %d|T : %d|All : %d|\n\n◎플레이 타임[Total] : %d일 %d시간 %d분 %d초\n\n◎부스터 게이지 : %d", CT, TR, plus, day[Client], times[Client], minute[Client], second[Client], Booster[Client]);
  405. // 옆에 뜨는것들
  406. new Handle:buffer = StartMessageOne("KeyHintText", Client);
  407. BfWriteByte(buffer, 1);
  408. BfWriteString(buffer, HudText);
  409. EndMessage();
  410. }
  411. }
  412.  
  413. stock bool:IsClientConnectedIngame(client){
  414.  
  415. if(client > 0 && client <= MaxClients){
  416.  
  417. if(IsClientConnected(client) == true){
  418.  
  419. if(IsClientInGame(client) == true){
  420.  
  421. return true;
  422.  
  423. }else{
  424.  
  425. return false;
  426.  
  427. }
  428.  
  429. }else{
  430.  
  431. return false;
  432.  
  433. }
  434.  
  435. }else{
  436.  
  437. return false;
  438.  
  439. }
  440.  
  441. }
  442.  
  443. public ActionBooster(Client)
  444. {
  445. if(Booster[Client] <Full)
  446. Booster[Client]++;
  447. else if(Booster[Client] == Full)
  448. Booster[Client] = Full;
  449. }
  450.  
  451. stock SendKeyHintTextMsg(Client, String:msg[], any:...){ // 허드띄울라면 이게필요함
  452. new Handle:hudhandle = INVALID_HANDLE;
  453. if(Client == 0){
  454. hudhandle = StartMessageAll("KeyHintText");
  455. }else{
  456. hudhandle = StartMessageOne("KeyHintText", Client);
  457. }
  458. new String:txt[255];
  459. VFormat(txt, sizeof(txt), msg, 3);
  460. if(hudhandle != INVALID_HANDLE){
  461. BfWriteByte(hudhandle, 1);
  462. BfWriteString(hudhandle, txt);
  463. EndMessage();
  464. }
  465. }
  466.  
  467. stock bool:AliveCheck(Client)
  468. {
  469. if(Client > 0 && Client <= MaxClients){
  470. if(IsClientConnected(Client) == true){
  471. if(IsClientInGame(Client) == true){
  472. if(IsPlayerAlive(Client) == true){
  473. return true;
  474. }else{
  475. return false;
  476. }
  477. }else{
  478. return false;
  479. }
  480. }else{
  481. return false;
  482. }
  483. }else{
  484. return false;
  485. }
  486. }
  487. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  488. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset129 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
  489. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement