Ter | Дата: Вторник, 15.09.2009, 23:59:28 | Сообщение # 1 |
Майор
Группа: Пользователи
Сообщений: 83
Статус: Не в сети
| Пожалуйста кто ни будь, может сделать так когда становишься инфекция то если вкл фонарик то он отключается автоматически. Code #include <amxmodx> #include <engine> #include <zombieplague> #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","100"); register_cvar("flashlight_g","100"); register_cvar("flashlight_b","100"); register_cvar("flashlight_drain","1.0"); register_cvar("flashlight_charge","0.5"); register_cvar("flashlight_decay","60"); 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(!zp_get_user_zombie(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,0,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); } else { message_begin(MSG_ONE,get_user_msgid("FlashBat"),{0,0,0},id); write_byte(0); message_end(); } }
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(20); // 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(); } } Добавлено (15.09.2009, 23:59:28) --------------------------------------------- up!
Сообщение отредактировал Ter - Вторник, 15.09.2009, 19:52:02 |
|
| |