1 #include <amxmodx> 2 #include <fakemeta> 3 #include "acg.inc" 4 5 #define GAUGEBOX_R "gfx/gauge/GAUGEBOX_R.tga" 6 #define GAUGE_C "gfx/gauge/GAUGE_C.tga" 7 #define GAUGEEFFECT_C "gfx/gauge/GAUGEEFFECT_C.tga" 8 9 #define TGA_GAUGE_BG 12 10 #define TGA_GAUGE_BAR 13 11 #define TGA_GAUGE_FX 14 12 13 #define TEXT_TIP 2 14 15 #define GAUGE_POS_X 0.344 16 #define GAUGE_POS_Y 0.882 17 18 #define BAR_OFFSET_X 0.009 19 #define BAR_OFFSET_Y 0.006 20 21 #define SCREEN_WIDTH 1024.0 22 #define SCREEN_HEIGHT 768.0 23 24 #define NEXT_THINK 0.025 25 26 new g_bCanDraw[33]; 27 new Float:g_flStartTime[33]; 28 new Float:g_flHoldTime[33]; 29 new Float:g_flNextThink[33]; 30 31 public plugin_init() 32 { 33 register_plugin("gauge", "1.0", "crsky"); 34 35 register_clcmd("say", "qq"); 36 37 register_forward(FM_PlayerPostThink, "Forward_PlayerPostThink"); 38 } 39 40 public plugin_precache() 41 { 42 precache_generic(GAUGEBOX_R); 43 precache_generic(GAUGE_C); 44 precache_generic(GAUGEEFFECT_C); 45 } 46 47 public client_putinserver(id) 48 { 49 set_task(0.5, "Task_InitFont", id + 100); 50 } 51 52 public Task_InitFont(iTaskId) 53 { 54 new id = iTaskId - 100; 55 56 acg_initfont(id, "SimSun", 12, 1, 0, 0, TEXT_TIP); 57 } 58 59 public qq(id) 60 { 61 DrawGauge(id, 5.0); 62 } 63 64 stock DrawGauge(id, Float:flTime) 65 { 66 if(is_user_bot(id)) 67 return; 68 69 g_flStartTime[id] = get_gametime(); 70 g_flHoldTime[id] = flTime; 71 g_bCanDraw[id] = 1; 72 73 acg_drawtga(id, GAUGEBOX_R, 255, 255, 255, 255, GAUGE_POS_X, GAUGE_POS_Y, 0, FX_NONE, 0.0, 0.0, 0.0, flTime, 0, 0, TGA_GAUGE_BG); 74 acg_drawtga(id, GAUGE_C, 255, 255, 255, 255, GAUGE_POS_X + BAR_OFFSET_X, GAUGE_POS_Y + BAR_OFFSET_Y, 0, FX_NONE, 0.0, 0.0, 0.0, flTime, 0, 0, TGA_GAUGE_BAR); 75 acg_drawtext(id, 0.464, GAUGE_POS_Y, "无敌时间 >>", 240, 240, 240, 255, 0.0, 0.0, flTime, 0, TS_NONE, 0, 0, TEXT_TIP); 76 } 77 78 public Forward_PlayerPostThink(id) 79 { 80 if(get_gametime() - g_flNextThink[id] < NEXT_THINK) 81 return; 82 83 g_flNextThink[id] = get_gametime(); 84 85 if(!g_bCanDraw[id]) 86 return; 87 88 if(is_user_bot(id)) 89 return; 90 91 new Float:flTime = get_gametime() - g_flStartTime[id]; 92 93 if(flTime > g_flHoldTime[id]) 94 { 95 g_flHoldTime[id] = 0.0; 96 g_bCanDraw[id] = 0; 97 98 acg_removedrawnimage(id, 2, TGA_GAUGE_BG); 99 acg_removedrawnimage(id, 2, TGA_GAUGE_BAR); 100 acg_removedrawnimage(id, 2, TGA_GAUGE_FX); 101 acg_removedrawnimage(id, 3, TEXT_TIP); 102 103 return; 104 } 105 106 new Float:flXScale = flTime / g_flHoldTime[id] * (302.0 / 8.0); 107 acg_resizeimage(id, flXScale, 1.0, 1, TGA_GAUGE_BAR); 108 109 new Float:flFxPos = (((GAUGE_POS_X + BAR_OFFSET_X) * SCREEN_WIDTH) + (8.0 * flXScale) - 25.0) / SCREEN_WIDTH; 110 111 acg_drawtga(id, GAUGEEFFECT_C, 255, 255, 255, 255, flFxPos, GAUGE_POS_Y + 0.001, 0, FX_NONE, 0.0, 0.0, 0.0, 0.2, 0, 0, TGA_GAUGE_FX); 112 }
时间: 2024-11-03 22:26:57