Advertisement
Guest User

Untitled

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