|
楼主 |
发表于 2009-1-13 13:10:21
|
显示全部楼层
来自 中国–广东–广州–白云区
- #include <amxmodx>
- #include <engine>
- #define TASK_CHARGE 100
- new flashlight[33];
- new flashbattery[33] = { 100, ... };
- public plugin_init() {
- register_plugin("CustomFlashlight","0.11","Avalanche");
- register_event("Flashlight","event_flashlight","b");
- register_cvar("flashlight_custom","1");
- register_cvar("flashlight_r","5");
- register_cvar("flashlight_g","500");
- register_cvar("flashlight_b","5");
- register_cvar("flashlight_drain","5");
- register_cvar("flashlight_charge","1");
- register_cvar("flashlight_radius","30");
- register_cvar("flashlight_decay","0");
- register_event("DeathMsg","event_deathmsg","a");
- }
- public client_putinserver(id) {
- flashbattery[id] = 100;
- }
- public client_disconnect(id) {
- remove_task(TASK_CHARGE+id);
- }
- public event_deathmsg() {
- new victim = read_data(2);
- flashbattery[victim] = 100;
- flashlight[victim] = 0;
- }
- public event_flashlight(id) {
- if(!get_cvar_num("flashlight_custom")) {
- return;
- }
- if(flashlight[id]) {
- flashlight[id] = 0;
- }
- else {
- if(flashbattery[id] > 0) {
- flashlight[id] = 1;
- }
- }
- if(!task_exists(TASK_CHARGE+id)) {
- new parms[1];
- parms[0] = id;
- set_task((flashlight[id]) ? get_cvar_float("flashlight_drain") : get_cvar_float("flashlight_charge"),"charge",TASK_CHARGE+id,parms,1);
- }
- message_begin(MSG_ONE,get_user_msgid("Flashlight"),{0,255,0},id);
- write_byte(flashlight[id]);
- write_byte(flashbattery[id]);
- message_end();
- entity_set_int(id,EV_INT_effects,entity_get_int(id,EV_INT_effects) & ~EF_DIMLIGHT);
- }
- public charge(parms[]) {
- if(!get_cvar_num("flashlight_custom")) {
- return;
- }
- new id = parms[0];
- if(flashlight[id]) {
- flashbattery[id] -= 1;
- }
- else {
- flashbattery[id] += 1;
- }
- message_begin(MSG_ONE,get_user_msgid("FlashBat"),{0,0,0},id);
- write_byte(flashbattery[id]);
- message_end();
- if(flashbattery[id] <= 0) {
- flashbattery[id] = 0;
- flashlight[id] = 0;
- message_begin(MSG_ONE,get_user_msgid("Flashlight"),{0,0,0},id);
- write_byte(flashlight[id]);
- write_byte(flashbattery[id]);
- message_end();
- // don't return so we can charge it back up to full
- }
- else if(flashbattery[id] >= 100) {
- flashbattery[id] = 100;
- return; // return because we don't need to charge anymore
- }
- set_task((flashlight[id]) ? get_cvar_float("flashlight_drain") : get_cvar_float("flashlight_charge"),"charge",TASK_CHARGE+id,parms,1);
- }
- public client_PreThink(id) {
- if(!get_cvar_num("flashlight_custom")) {
- return;
- }
- if(flashlight[id] && flashbattery[id]) {
- new origin[3];
- get_user_origin(id,origin,3);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(27); // TE_DLIGHT
- write_coord(origin[0]); // X
- write_coord(origin[1]); // Y
- write_coord(origin[2]); // Z
- write_byte(get_cvar_num("flashlight_radius")); // radius
- write_byte(get_cvar_num("flashlight_r")); // R
- write_byte(get_cvar_num("flashlight_g")); // G
- write_byte(get_cvar_num("flashlight_b")); // B
- write_byte(1); // life
- write_byte(get_cvar_num("flashlight_decay")); // decay rate
- message_end();
- }
- }
复制代码 19# 点通粉丝
按F绿色大灯源码 |
|