|
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
|

09-09-2013
, 03:42
Re: It's possible to make this?
|
#8
|
Work but i have a problem, for example when i have enabled my lights others players can control my lights when they type /lights, same with me if i type /lights and the others players have enabled the lights i can control his lights, with disable work fine i mean if i have disabled the lights the other players when they type /lights they cant control my lights just work for me, can someone tell me why happen this?
this is the code:
PHP Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <amx_settings_api> #include <cs_weap_models_api> #include <zp50_core> #include <colorchat>
// Settings file new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
// Default sounds new const sound_grenade_flare_explode[][] = { "items/nvg_on.wav" }
#define MODEL_MAX_LENGTH 64 #define SOUND_MAX_LENGTH 64 #define SPRITE_MAX_LENGTH 64
// Models new g_model_grenade_flare[MODEL_MAX_LENGTH] = "models/zombie_plague/v_grenade_flare.mdl"
// Sprites new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
new Array:g_sound_grenade_flare_explode
// HACK: pev_ field used to store custom nade types and their values const PEV_NADE_TYPE = pev_flTimeStepSound const NADE_TYPE_FLARE = 4444 const PEV_FLARE_COLOR = pev_punchangle const PEV_FLARE_DURATION = pev_flSwimTime
new g_trailSpr
new cvar_grenade_flare_duration, cvar_grenade_flare_radius, cvar_grenade_flare_color
new bool:g_bajaluz[33] new iMaxPlayers; new bool: flare_disabled[33]
public plugin_init() { register_plugin("[ZP] Grenade: Flare", ZP_VERSION_STRING, "ZP Dev Team") register_forward(FM_SetModel, "fw_SetModel") RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade") cvar_grenade_flare_duration = register_cvar("zp_grenade_flare_duration", "60") cvar_grenade_flare_radius = register_cvar("zp_grenade_flare_radius", "25") cvar_grenade_flare_color = register_cvar("zp_grenade_flare_color", "0") iMaxPlayers = get_maxplayers() register_clcmd("say /lights", "bajarluz") }
public plugin_precache() { // Initialize arrays g_sound_grenade_flare_explode = ArrayCreate(SOUND_MAX_LENGTH, 1) // Load from external file amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE FLARE", g_sound_grenade_flare_explode) // If we couldn't load custom sounds from file, use and save default ones new index if (ArraySize(g_sound_grenade_flare_explode) == 0) { for (index = 0; index < sizeof sound_grenade_flare_explode; index++) ArrayPushString(g_sound_grenade_flare_explode, sound_grenade_flare_explode[index]) // Save to external file amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE FLARE", g_sound_grenade_flare_explode) } // Load from external file, save if not found if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE FLARE", g_model_grenade_flare, charsmax(g_model_grenade_flare))) amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE FLARE", g_model_grenade_flare) if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail))) amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail) // Precache models precache_model(g_model_grenade_flare) g_trailSpr = precache_model(g_sprite_grenade_trail) }
public zp_fw_core_cure_post(id, attacker) { // Set custom grenade model cs_set_player_view_model(id, CSW_SMOKEGRENADE, g_model_grenade_flare) }
public zp_fw_core_infect(id, attacker) { // Remove custom grenade model cs_reset_player_view_model(id, CSW_SMOKEGRENADE) }
public bajarluz(id) { if (!g_bajaluz[id] && !flare_disabled[id]) { g_bajaluz[id] = true flare_disabled[id] = true ColorChat(id, TEAM_COLOR, "^x04 ZP |^x01 You have disabled lighting!") } else { g_bajaluz[id] = false flare_disabled[id] = false ColorChat(id, TEAM_COLOR, "^x04 ZP |^x01 You have enabled lighting!") } } // Forward Set Model public fw_SetModel(entity, const model[]) { // We don't care if (strlen(model) < 8) return; // Narrow down our matches a bit if (model[7] != 'w' || model[8] != '_') return; // Get damage time of grenade static Float:dmgtime pev(entity, pev_dmgtime, dmgtime) // Grenade not yet thrown if (dmgtime == 0.0) return; // Grenade's owner is zombie? if (zp_core_is_zombie(pev(entity, pev_owner))) return; // Smoke Grenade if (model[9] == 's' && model[10] == 'm') { // Build flare's color static rgb[3] switch (get_pcvar_num(cvar_grenade_flare_color)) { case 0: // white { rgb[0] = 255 // r rgb[1] = 255 // g rgb[2] = 255 // b } case 1: // red { rgb[0] = random_num(50,255) // r rgb[1] = 0 // g rgb[2] = 0 // b } case 2: // green { rgb[0] = 0 // r rgb[1] = random_num(50,255) // g rgb[2] = 0 // b } case 3: // blue { rgb[0] = 0 // r rgb[1] = 0 // g rgb[2] = random_num(50,255) // b } case 4: // random (all colors) { rgb[0] = random_num(50,200) // r rgb[1] = random_num(50,200) // g rgb[2] = random_num(50,200) // b } case 5: // random (r,g,b) { switch (random_num(1, 3)) { case 1: // red { rgb[0] = random_num(50,255) // r rgb[1] = 0 // g rgb[2] = 0 // b } case 2: // green { rgb[0] = 0 // r rgb[1] = random_num(50,255) // g rgb[2] = 0 // b } case 3: // blue { rgb[0] = 0 // r rgb[1] = 0 // g rgb[2] = random_num(50,255) // b } } } } // Give it a glow fm_set_rendering(entity, kRenderFxGlowShell, rgb[0], rgb[1], rgb[2], kRenderNormal, 16); // And a colored trail message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BEAMFOLLOW) // TE id write_short(entity) // entity write_short(g_trailSpr) // sprite write_byte(10) // life write_byte(10) // width write_byte(rgb[0]) // r write_byte(rgb[1]) // g write_byte(rgb[2]) // b write_byte(200) // brightness message_end() // Set grenade type on the thrown grenade entity set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE) // Set flare color on the thrown grenade entity set_pev(entity, PEV_FLARE_COLOR, rgb) } }
// Ham Grenade Think Forward public fw_ThinkGrenade(entity) { // Invalid entity if (!pev_valid(entity)) return HAM_IGNORED; // Get damage time of grenade static Float:dmgtime pev(entity, pev_dmgtime, dmgtime) new Float:current_time = get_gametime() // Check if it's time to go off if (dmgtime > current_time) return HAM_IGNORED; // Check if it's one of our custom nades switch (pev(entity, PEV_NADE_TYPE)) { case NADE_TYPE_FLARE: // Flare { // Get its duration new duration = pev(entity, PEV_FLARE_DURATION) // Already went off, do lighting loop for the duration of PEV_FLARE_DURATION if (duration > 0) { // Check whether this is the last loop if (duration == 1) { // Get rid of the flare entity g_bajaluz[pev(entity, pev_owner)] = false engfunc(EngFunc_RemoveEntity, entity) return HAM_SUPERCEDE; } // Light it up! for(new i=1; i<=iMaxPlayers ;i++) { if(is_user_connected(i) && !flare_disabled[i]) { flare_lighting(i, entity, duration) } } // Set time for next loop set_pev(entity, PEV_FLARE_DURATION, --duration) set_pev(entity, pev_dmgtime, current_time + 2.0) } // Light up when it's stopped on ground else if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10) { // Flare sound static sound[SOUND_MAX_LENGTH] ArrayGetString(g_sound_grenade_flare_explode, random_num(0, ArraySize(g_sound_grenade_flare_explode) - 1), sound, charsmax(sound)) emit_sound(entity, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM) // Set duration and start lightning loop on next think set_pev(entity, PEV_FLARE_DURATION, 1 + get_pcvar_num(cvar_grenade_flare_duration)/2) set_pev(entity, pev_dmgtime, current_time + 0.1) } else { // Delay explosion until we hit ground set_pev(entity, pev_dmgtime, current_time + 0.5) } } } return HAM_IGNORED; } // Flare Lighting Effects flare_lighting(id, entity, duration) { // Get origin and color static Float:origin[3], color[3] pev(entity, pev_origin, origin) pev(entity, PEV_FLARE_COLOR, color) // Lighting engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, origin, id) write_byte(TE_DLIGHT) // TE id engfunc(EngFunc_WriteCoord, origin[0]) // x engfunc(EngFunc_WriteCoord, origin[1]) // y engfunc(EngFunc_WriteCoord, origin[2]) // z if (g_bajaluz[pev(entity, pev_owner)]) write_byte(2) else write_byte(get_pcvar_num(cvar_grenade_flare_radius)) // radius write_byte(color[0]) // r write_byte(color[1]) // g write_byte(color[2]) // b write_byte(21) //life write_byte((duration < 2) ? 3 : 0) //decay rate message_end() // Sparks engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, origin, id) write_byte(TE_SPARKS) // TE id engfunc(EngFunc_WriteCoord, origin[0]) // x engfunc(EngFunc_WriteCoord, origin[1]) // y engfunc(EngFunc_WriteCoord, origin[2]) // z message_end() }
// Set entity's rendering type (from fakemeta_util) stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) { static Float:color[3] color[0] = float(r) color[1] = float(g) color[2] = float(b) set_pev(entity, pev_renderfx, fx) set_pev(entity, pev_rendercolor, color) set_pev(entity, pev_rendermode, render) set_pev(entity, pev_renderamt, float(amount)) }
// Get entity's speed (from fakemeta_util) stock fm_get_speed(entity) { static Float:velocity[3] pev(entity, pev_velocity, velocity) return floatround(vector_length(velocity)); }
Last edited by wicho; 09-09-2013 at 03:44.
|
|