Hello gubka.
I have some problems with laser mine. I changed some mechanics for my server(now they slow down zombies after touching the beam instead killing).Generally this didn't change source code but there is some magick with these mines.Sometimes they disappear. I have no idea why, it's actualy random moments.
They can disappear after 10 sec (not all, one of some mines which i put), but can stay in place all round.Absolutely random thing.
Sometimes it happens like beam is disappearing and only model mine still stay, and model explode after i shoot on it. Sometimes it happens like all mine is disappearing.
I wrote only this in source code in "public void EventBeamTouched":
Spoiler
PHP Code:
// Apply damage
//SDKHooks_TakeDamage(activatorIndex, nEntity, ownerIndex, GetConVarFloat(gCvarList[CVAR_LASERMINE_DAMAGE]), DMG_BURN);
(I switched off this)
// Emit hurt sound
EmitSoundToAll("*/zbm3/mine/suitchargeok1.mp3", activatorIndex, SNDCHAN_VOICE, SNDLEVEL_NORMAL);
/**
* ============================================================================
*
* Zombie Plague Mod #3 Generation
*
*
* Copyright (C) 2015 Nikita Ushakov (Ireland, Dublin)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================================
**/
// Load cvars
gCvarList[CVAR_LASERMINE_DAMAGE] = CreateConVar("zp_lasermines_damage", "1.0", "The damage to deal to a zombie by the laser in the each frame");
gCvarList[CVAR_LASERMINE_HEALTH] = CreateConVar("zp_lasermines_health", "1200", "The laser mines health. ['0' = never breaked]");
gCvarList[CVAR_LASERMINE_COLOR] = CreateConVar("zp_lasermines_color", "0 0 255", "Beam color. Set by RGB");
gCvarList[CVAR_LASERMINE_ACTIVE_TIME] = CreateConVar("zp_lasermines_time", "2.0", "The delay of laser mines' activation");
// Add translation for buying phrase
LoadTranslations("zombieplagueitems.pharses");
}
/**
* The map is starting.
**/
public void OnMapStart(/*void*/)
{
// Precache models
PrecacheModel(MODEL_BEAM);
PrecacheModel(MODEL_MINE);
// Add textures and models to download list
AddFileToDownloadsTable("models/lasermine/lasermine.dx80.vtx");
AddFileToDownloadsTable("models/lasermine/lasermine.dx90.vtx");
AddFileToDownloadsTable("models/lasermine/lasermine.mdl");
AddFileToDownloadsTable("models/lasermine/lasermine.phy");
AddFileToDownloadsTable("models/lasermine/lasermine.vvd");
AddFileToDownloadsTable("materials/models/lasermine/lasermine.vmt");
AddFileToDownloadsTable("materials/models/lasermine/lasermine.vtf");
/**
* Map has loaded, all configs has been executed.
**/
public void OnConfigsExecuted(/*void*/)
{
// Get string with RGB color
char sColor[SMALL_LINE_LENGTH];
GetConVarString(gCvarList[CVAR_LASERMINE_COLOR], sColor, sizeof(sColor));
// Convert color string to RGB value
char sRGB[3][SMALL_LINE_LENGTH];
int nPieces = ExplodeString(sColor, " ", sRGB, sizeof(sRGB), sizeof(sRGB[]));
// Breaks a string into pieces and stores each piece into an array of buffers
for(int i = 0; i < nPieces; i++)
{
iColor[i] = StringToInt(sRGB[i]);
}
}
/**
* Called once a client successfully connects.
*
* @param clientIndex The client index.
**/
public void OnClientConnected(int clientIndex)
{
#pragma unused clientIndex
// Reset amount of lasermines
gLaserMine[clientIndex] = 0;
}
/**
* Called when a client is disconnecting from the server.
*
* @param clientIndex The client index.
**/
public void OnClientDisconnect(int clientIndex)
{
#pragma unused clientIndex
// Reset amount of lasermines
gLaserMine[clientIndex] = 0;
/**
* Called when a client became a zombie.
*
* @param clientIndex The client index.
* @param attackerIndex The attacker index.
**/
public void ZP_OnClientInfected(int clientIndex, int attackerIndex)
{
#pragma unused clientIndex, attackerIndex
/**
* Event callback (player_death)
* The player is about to die.
*
* @param gEventHook The event handle.
* @param gEventName The name of the event.
* @param dontBroadcast If true, event is broadcasted to all clients, false if not.
**/
public Action EventPlayerDeath(Event gEventHook, const char[] gEventName, bool dontBroadcast)
{
// Get the weapon name
char sClassname[SMALL_LINE_LENGTH];
GetEventString(gEventHook, "weapon", sClassname, sizeof(sClassname));
// If it is beam entity, change icon
if (StrEqual(sClassname, "env_beam"))
{
SetEventString(gEventHook, "weapon", "taser");
SetEventBool(gEventHook, "headshot", true);
}
}
/**
* Hook: OnTakeDamage
* Called right before damage is done.
*
* @param victimIndex The victim index.
* @param attackerIndex The attacker index.
* @param inflicterIndex The inflictor index.
* @param damageAmount The amount of damage inflicted.
* @param damageBits The type of damage inflicted.
**/
public Action OnTakeDamage(int victimIndex, int &attackerIndex, int &inflicterIndex, float &damageAmount, int &damageBits)
{
#pragma unused victimIndex, attackerIndex
// Returns whether or not an edict index is valid
if (IsEntityLasermine(victimIndex))
{
// Verify that the attacker is exist
if (IsPlayerExist(attackerIndex))
{
// If the attacker is human, then stop
if (ZP_IsPlayerHuman(attackerIndex))
{
// Block breaking
return Plugin_Handled;
}
// Allow breaking
return Plugin_Continue;
}
// Verify that the attacker is another lasermine
else if (!IsEntityLasermine(inflicterIndex))
{
// Block breaking
return Plugin_Handled;
}
}
// Allow breaking
return Plugin_Continue;
}
/**
* Called after select an extraitem in equipment menu.
*
* @param clientIndex The client index.
* @param extraitemIndex The index of extraitem from ZP_RegisterExtraItem() native.
*
* @return Plugin_Handled or Plugin_Stop to block purhase. Anything else
* (like Plugin_Continue) to allow purhase and taking ammopacks.
**/
public Action ZP_OnExtraBuyCommand(int clientIndex, int extraitemIndex)
{
#pragma unused clientIndex
// Check the item's index
if(extraitemIndex == iItem)
{
// If you don't allowed to buy, then return ammopacks
if(ZP_IsPlayerZombie(clientIndex) || ZP_IsPlayerSurvivor(clientIndex))
{
return Plugin_Handled;
}
// Give lasermine
GiveLasermine(clientIndex);
}
// Allow buying
return Plugin_Continue;
}
/**
* Called when a clients movement buttons are being processed.
*
* @param clientIndex The client index.
* @param bitFlags Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc).
* @param iImpulse Copyback buffer containing the current impulse command.
* @param flVelocity Players desired velocity.
* @param flAngles Players desired view angles.
* @param weaponIndex Entity index of the new weapon if player switches weapon, 0 otherwise.
* @param iSubType Weapon subtype when selected from a menu.
* @param iCmdNum Command number. Increments from the first command sent.
* @param iTickCount Tick count. A client's prediction based on the server's GetGameTickCount value.
* @param iSeed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
* @param iMouse Mouse direction (x, y).
**/
public Action OnPlayerRunCmd(int clientIndex, int &bitFlags, int &iImpulse, float flVelocity[3], float flAngles[3], int &weaponIndex, int &iSubType, int &iCmdNum, int &iTickCount, int &iSeed, int iMouse[2])
{
#pragma unused clientIndex
/**
* Called when a clients press 'SHIFT' button.
*
* @param clientIndex The client index.
**/
void PlantLaserMine(int clientIndex)
{
#pragma unused clientIndex
// Do the trace
Handle hTrace = TraceRay(clientIndex);
// If trace hit the wall
if (TR_DidHit(hTrace) && TR_GetEntityIndex(hTrace) < 1)
{
// Create an lasermine entities
int nMine = CreateEntityByName("prop_physics_override");
int nBeam = CreateEntityByName("env_beam");
// If entity aren't valid, then skip
if(nMine && nBeam)
{
// Set model for the lasermine
SetEntityModel(nMine, MODEL_MINE);
// Set explosion fake damage for the lasermine
DispatchKeyValue(nMine, "ExplodeDamage", "1");
DispatchKeyValue(nMine, "ExplodeRadius", "1");
// Spawn the lasermine into the world
DispatchKeyValue(nMine, "spawnflags", "3");
DispatchSpawn(nMine);
// Disable any physics
AcceptEntityInput(nMine, "DisableMotion");
SetEntityMoveType(nMine, MOVETYPE_NONE);
// Teleport the lasermine
TeleportEntity(nMine, flOrigin, flNormal, NULL_VECTOR);
// Set modified flags on lasermine
SetEntProp(nMine, Prop_Data, "m_nSolidType", 6);
SetEntProp(nMine, Prop_Data, "m_CollisionGroup", 11);
// Set health for the lasermine
if(GetConVarInt(gCvarList[CVAR_LASERMINE_HEALTH]) > 0)
{
SetEntProp(nMine, Prop_Data, "m_takedamage", 2);
SetEntProp(nMine, Prop_Data, "m_iHealth", GetConVarInt(gCvarList[CVAR_LASERMINE_HEALTH]));
}
// Turn off the beam
AcceptEntityInput(nBeam, "TurnOff");
// Set model for the beam
SetEntityModel(nBeam, MODEL_BEAM);
// Teleport the beam
TeleportEntity(nBeam, flBeamEnd, NULL_VECTOR, NULL_VECTOR);
// Set size of the model
SetEntPropVector(nBeam, Prop_Data, "m_vecEndPos", flOrigin);
SetEntPropFloat(nBeam, Prop_Data, "m_fWidth", 3.0);
SetEntPropFloat(nBeam, Prop_Data, "m_fEndWidth", 3.0);
// Sets the owner of the beam
SetEntPropEnt(nBeam, Prop_Data, "m_hOwnerEntity", clientIndex);
SetEntPropEnt(nMine, Prop_Data, "m_hMoveChild", nBeam);
SetEntPropEnt(nBeam, Prop_Data, "m_hEffectEntity", nMine);
//*********************************************************************
//* OTHER *
//*********************************************************************
// Send data to the timer
DataPack hPack = CreateDataPack();
WritePackCell(hPack, nMine);
WritePackCell(hPack, nBeam);
WritePackString(hPack, sClassname);
// Create activation time
CreateTimer(GetConVarFloat(gCvarList[CVAR_LASERMINE_ACTIVE_TIME]), OnActivateLaser, hPack, TIMER_FLAG_NO_MAPCHANGE | TIMER_HNDL_CLOSE);
// Hook damage of the lasermine
SDKHook(nMine, SDKHook_OnTakeDamage, OnTakeDamage);
/**
* Called when a clients press 'R' button.
*
* @param clientIndex The client index.
**/
void PickUpLasermine(int clientIndex)
{
#pragma unused clientIndex
// Do the trace
Handle hTrace = TraceRay(clientIndex);
// Initialize entity index
int nEntity = -1;
// If trace hit the lasermine
if (TR_DidHit(hTrace) && (nEntity = TR_GetEntityIndex(hTrace)) > MaxClients)
{
// Validate client index and owner index, then pickup lasermine
if (GetClientByLasermine(nEntity) == clientIndex)
{
// Give lasermine
GiveLasermine(clientIndex);
/**
* Called, when lasermine is activated.
*
* @param hTimer The timer handle.
* @param hPack The data pack.
**/
public Action OnActivateLaser(Handle hTimer, any hPack)
{
// Resets the position in a data pack
ResetPack(hPack);
// Get values from datapack
int nMine = ReadPackCell(hPack);
int nBeam = ReadPackCell(hPack);
// Convert string from datapack
ReadPackString(hPack, sClassname, sizeof(sClassname));
// If entity is valid, then emit activation sound
if (IsValidEdict(nMine))
{
EmitSoundToAll("*/zbm3/mine/mine_activate.mp3", nMine, SNDCHAN_STATIC);
}
// If entity is valid, then activate it
if(IsValidEdict(nBeam))
{
// Iniliaze char
char sDispatch[SMALL_LINE_LENGTH];
// Turn on the beam
AcceptEntityInput(nBeam, "TurnOn");
// Set color for the beam model
SetEntityRenderColor(nBeam, iColor[0], iColor[1], iColor[2]);
// Set modified flags on the beam
Format(sDispatch, sizeof(sDispatch), "%s,TurnOff,,0.001,-1", sClassname);
DispatchKeyValue(nBeam, "OnTouchedByEntity", sDispatch);
Format(sDispatch, sizeof(sDispatch), "%s,TurnOn,,0.002,-1", sClassname);
DispatchKeyValue(nBeam, "OnTouchedByEntity", sDispatch);
}
// Destroy timer
return Plugin_Stop;
}
/**
* Called when a clients touch env_beam entity.
*
* @param sOutput The output char.
* @param nEntity The entity index.
* @param activatorIndex The activator index.
* @param flDelay The delay of updating.
**/
public void EventBeamTouched(const char[] sOutput, int nEntity, int activatorIndex, float flDelay)
{
#pragma unused activatorIndex
// If round end, then stop
if (ZP_GetRoundState(STATE_END_ROUND))
{
return;
}
// If entity isn't valid, then stop
if(!IsValidEdict(nEntity))
{
return;
}
// Verify that the activator is exist
if (!IsPlayerExist(activatorIndex))
{
return;
}
// Verify that the activator is zombie
if(!ZP_IsPlayerZombie(activatorIndex))
{
return;
}
// Get the owner of the lasermine
int ownerIndex = GetEntPropEnt(nEntity, Prop_Data, "m_hOwnerEntity");
// Verify that the owner is connected
if (!IsPlayerExist(ownerIndex, false))
{
return;
}
/**
* Return owner index from beam entity.
*
* @param nEntity The entity index.
* @return The client index.
**/
stock int GetClientByLasermine(int nEntity)
{
// Get beam index from lasermine
int nBeam = GetBeamByLasermine(nEntity)
// If valid
if (nBeam != -1)
{
return GetEntPropEnt(nBeam, Prop_Data, "m_hOwnerEntity");
}
// If didn't find, then stop
return -1;
}
/**
* Return beam index from lasermine entity.
*
* @param nEntity The entity index.
* @return The beam index.
**/
stock int GetBeamByLasermine(int nEntity)
{
// If valid
if (IsEntityLasermine(nEntity))
{
return GetEntPropEnt(nEntity, Prop_Data, "m_hMoveChild");
}
// If didn't find, then stop
return -1;
}
/**
* Check lasermine entity valid or not.
*
* @param nEntity The entity index.
* @return True or false.
**/
stock bool IsEntityLasermine(int nEntity)
{
// If entity isn't valid, then stop
if (nEntity <= MaxClients || !IsValidEdict(nEntity))
{
return false;
}
// Return true, if found
return (StrEqual(sModel, MODEL_MINE, false) && GetEntPropEnt(nEntity, Prop_Data, "m_hMoveChild") != -1) ? true : false;
}
/**
* Give lasermine to the player and send the info message.
*
* @param clientIndex The client index.
**/
stock void GiveLasermine(int clientIndex)
{
// Give lasermine
gLaserMine[clientIndex]++;
// Set translation target
SetGlobalTransTarget(clientIndex);
// Show message
PrintHintText(clientIndex, "%t", "@Buy lasermine", gLaserMine[clientIndex]);
}
/**
* Check all entities and remove lasermines.
*
* @param clientIndex The client index.
**/
stock void RemoveLasermine(int clientIndex)
{
#pragma unused clientIndex
// Get max amount of entities
int nGetMaxEnt = GetMaxEntities();
// nEntity = entity index
for (int nEntity = 0; nEntity <= nGetMaxEnt; nEntity++)
{
// Validate client index and owner index, then delete entity
if (GetClientByLasermine(nEntity) == clientIndex)
{
AcceptEntityInput(nEntity, "Kill");
}
}
}
/**
* Delay function.
*
* @param clientIndex The client index.
* @param flDelay The delay of updating.
**/
stock bool IsDelay(int clientIndex, float flDelay)
{
// Initialize time array
static float flTime[MAXPLAYERS+1];
// Returns the game time based on the game tick
float flCurrentTime = GetEngineTime();
// Cooldown don't over yet, then stop
if ((flCurrentTime - flTime[clientIndex]) < flDelay)
{
// Block usage
return true;
}
// Update countdown time
flTime[clientIndex] = flCurrentTime;
// Allow usage
return false;
}
/*
* Trace filtering functions
*/
/**
* Starts up a new trace ray using a new trace result and a customized trace ray filter.
* Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter function is currently not allowed and may not work.
*
* @param clientIndex The client index.
**/
Handle TraceRay(int clientIndex)
{
#pragma unused clientIndex
Hello gubka.
I have some problems with laser mine. I changed some mechanics for my server(now they slow down zombies after touching the beam instead killing).Generally this didn't change source code but there is some magick with these mines.Sometimes they disappear. I have no idea why, it's actualy random moments.
They can disappear after 10 sec (not all, one of some mines which i put), but can stay in place all round.Absolutely random thing.
Sometimes it happens like beam is disappearing and only model mine still stay, and model explode after i shoot on it. Sometimes it happens like all mine is disappearing.
I wrote only this in source code in "public void EventBeamTouched":
Spoiler
PHP Code:
// Apply damage //SDKHooks_TakeDamage(activatorIndex, nEntity, ownerIndex, GetConVarFloat(gCvarList[CVAR_LASERMINE_DAMAGE]), DMG_BURN); (I switched off this) // Emit hurt sound EmitSoundToAll("*/zbm3/mine/suitchargeok1.mp3", activatorIndex, SNDCHAN_VOICE, SNDLEVEL_NORMAL);
/** * ============================================================================ * * Zombie Plague Mod #3 Generation * * * Copyright (C) 2015 Nikita Ushakov (Ireland, Dublin) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * ============================================================================ **/
// Load cvars gCvarList[CVAR_LASERMINE_DAMAGE] = CreateConVar("zp_lasermines_damage", "1.0", "The damage to deal to a zombie by the laser in the each frame"); gCvarList[CVAR_LASERMINE_HEALTH] = CreateConVar("zp_lasermines_health", "1200", "The laser mines health. ['0' = never breaked]"); gCvarList[CVAR_LASERMINE_COLOR] = CreateConVar("zp_lasermines_color", "0 0 255", "Beam color. Set by RGB"); gCvarList[CVAR_LASERMINE_ACTIVE_TIME] = CreateConVar("zp_lasermines_time", "2.0", "The delay of laser mines' activation");
// Add translation for buying phrase LoadTranslations("zombieplagueitems.pharses"); }
/** * The map is starting. **/ public void OnMapStart(/*void*/) { // Precache models PrecacheModel(MODEL_BEAM); PrecacheModel(MODEL_MINE);
// Add textures and models to download list AddFileToDownloadsTable("models/lasermine/lasermine.dx80.vtx"); AddFileToDownloadsTable("models/lasermine/lasermine.dx90.vtx"); AddFileToDownloadsTable("models/lasermine/lasermine.mdl"); AddFileToDownloadsTable("models/lasermine/lasermine.phy"); AddFileToDownloadsTable("models/lasermine/lasermine.vvd"); AddFileToDownloadsTable("materials/models/lasermine/lasermine.vmt"); AddFileToDownloadsTable("materials/models/lasermine/lasermine.vtf");
/** * Map has loaded, all configs has been executed. **/ public void OnConfigsExecuted(/*void*/) { // Get string with RGB color char sColor[SMALL_LINE_LENGTH]; GetConVarString(gCvarList[CVAR_LASERMINE_COLOR], sColor, sizeof(sColor));
// Convert color string to RGB value char sRGB[3][SMALL_LINE_LENGTH]; int nPieces = ExplodeString(sColor, " ", sRGB, sizeof(sRGB), sizeof(sRGB[]));
// Breaks a string into pieces and stores each piece into an array of buffers for(int i = 0; i < nPieces; i++) { iColor[i] = StringToInt(sRGB[i]); } }
/** * Called once a client successfully connects. * * @param clientIndex The client index. **/ public void OnClientConnected(int clientIndex) { #pragma unused clientIndex
// Reset amount of lasermines gLaserMine[clientIndex] = 0; }
/** * Called when a client is disconnecting from the server. * * @param clientIndex The client index. **/ public void OnClientDisconnect(int clientIndex) { #pragma unused clientIndex
// Reset amount of lasermines gLaserMine[clientIndex] = 0;
/** * Called when a client became a zombie. * * @param clientIndex The client index. * @param attackerIndex The attacker index. **/ public void ZP_OnClientInfected(int clientIndex, int attackerIndex) { #pragma unused clientIndex, attackerIndex
/** * Event callback (player_death) * The player is about to die. * * @param gEventHook The event handle. * @param gEventName The name of the event. * @param dontBroadcast If true, event is broadcasted to all clients, false if not. **/ public Action EventPlayerDeath(Event gEventHook, const char[] gEventName, bool dontBroadcast) { // Get the weapon name char sClassname[SMALL_LINE_LENGTH]; GetEventString(gEventHook, "weapon", sClassname, sizeof(sClassname));
// If it is beam entity, change icon if (StrEqual(sClassname, "env_beam")) { SetEventString(gEventHook, "weapon", "taser"); SetEventBool(gEventHook, "headshot", true); } }
/** * Hook: OnTakeDamage * Called right before damage is done. * * @param victimIndex The victim index. * @param attackerIndex The attacker index. * @param inflicterIndex The inflictor index. * @param damageAmount The amount of damage inflicted. * @param damageBits The type of damage inflicted. **/ public Action OnTakeDamage(int victimIndex, int &attackerIndex, int &inflicterIndex, float &damageAmount, int &damageBits) { #pragma unused victimIndex, attackerIndex
// Returns whether or not an edict index is valid if (IsEntityLasermine(victimIndex)) { // Verify that the attacker is exist if (IsPlayerExist(attackerIndex)) { // If the attacker is human, then stop if (ZP_IsPlayerHuman(attackerIndex)) { // Block breaking return Plugin_Handled; }
// Allow breaking return Plugin_Continue; }
// Verify that the attacker is another lasermine else if (!IsEntityLasermine(inflicterIndex)) { // Block breaking return Plugin_Handled; } }
// Allow breaking return Plugin_Continue; }
/** * Called after select an extraitem in equipment menu. * * @param clientIndex The client index. * @param extraitemIndex The index of extraitem from ZP_RegisterExtraItem() native. * * @return Plugin_Handled or Plugin_Stop to block purhase. Anything else * (like Plugin_Continue) to allow purhase and taking ammopacks. **/ public Action ZP_OnExtraBuyCommand(int clientIndex, int extraitemIndex) { #pragma unused clientIndex
// Check the item's index if(extraitemIndex == iItem) { // If you don't allowed to buy, then return ammopacks if(ZP_IsPlayerZombie(clientIndex) || ZP_IsPlayerSurvivor(clientIndex)) { return Plugin_Handled; }
// Give lasermine GiveLasermine(clientIndex); }
// Allow buying return Plugin_Continue; }
/** * Called when a clients movement buttons are being processed. * * @param clientIndex The client index. * @param bitFlags Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc). * @param iImpulse Copyback buffer containing the current impulse command. * @param flVelocity Players desired velocity. * @param flAngles Players desired view angles. * @param weaponIndex Entity index of the new weapon if player switches weapon, 0 otherwise. * @param iSubType Weapon subtype when selected from a menu. * @param iCmdNum Command number. Increments from the first command sent. * @param iTickCount Tick count. A client's prediction based on the server's GetGameTickCount value. * @param iSeed Random seed. Used to determine weapon recoil, spread, and other predicted elements. * @param iMouse Mouse direction (x, y). **/ public Action OnPlayerRunCmd(int clientIndex, int &bitFlags, int &iImpulse, float flVelocity[3], float flAngles[3], int &weaponIndex, int &iSubType, int &iCmdNum, int &iTickCount, int &iSeed, int iMouse[2]) { #pragma unused clientIndex
/** * Called when a clients press 'SHIFT' button. * * @param clientIndex The client index. **/ void PlantLaserMine(int clientIndex) { #pragma unused clientIndex
// Do the trace Handle hTrace = TraceRay(clientIndex);
// If trace hit the wall if (TR_DidHit(hTrace) && TR_GetEntityIndex(hTrace) < 1) { // Create an lasermine entities int nMine = CreateEntityByName("prop_physics_override"); int nBeam = CreateEntityByName("env_beam");
// If entity aren't valid, then skip if(nMine && nBeam) {
// Set model for the lasermine SetEntityModel(nMine, MODEL_MINE);
// Set explosion fake damage for the lasermine DispatchKeyValue(nMine, "ExplodeDamage", "1"); DispatchKeyValue(nMine, "ExplodeRadius", "1");
// Spawn the lasermine into the world DispatchKeyValue(nMine, "spawnflags", "3"); DispatchSpawn(nMine);
// Disable any physics AcceptEntityInput(nMine, "DisableMotion"); SetEntityMoveType(nMine, MOVETYPE_NONE);
// Teleport the lasermine TeleportEntity(nMine, flOrigin, flNormal, NULL_VECTOR);
// Set modified flags on lasermine SetEntProp(nMine, Prop_Data, "m_nSolidType", 6); SetEntProp(nMine, Prop_Data, "m_CollisionGroup", 11);
// Set health for the lasermine if(GetConVarInt(gCvarList[CVAR_LASERMINE_HEALTH]) > 0) { SetEntProp(nMine, Prop_Data, "m_takedamage", 2); SetEntProp(nMine, Prop_Data, "m_iHealth", GetConVarInt(gCvarList[CVAR_LASERMINE_HEALTH])); }
// Turn off the beam AcceptEntityInput(nBeam, "TurnOff");
// Set model for the beam SetEntityModel(nBeam, MODEL_BEAM);
// Teleport the beam TeleportEntity(nBeam, flBeamEnd, NULL_VECTOR, NULL_VECTOR);
// Set size of the model SetEntPropVector(nBeam, Prop_Data, "m_vecEndPos", flOrigin); SetEntPropFloat(nBeam, Prop_Data, "m_fWidth", 3.0); SetEntPropFloat(nBeam, Prop_Data, "m_fEndWidth", 3.0);
// Sets the owner of the beam SetEntPropEnt(nBeam, Prop_Data, "m_hOwnerEntity", clientIndex); SetEntPropEnt(nMine, Prop_Data, "m_hMoveChild", nBeam); SetEntPropEnt(nBeam, Prop_Data, "m_hEffectEntity", nMine);
//********************************************************************* //* OTHER * //*********************************************************************
// Send data to the timer DataPack hPack = CreateDataPack(); WritePackCell(hPack, nMine); WritePackCell(hPack, nBeam); WritePackString(hPack, sClassname);
// Create activation time CreateTimer(GetConVarFloat(gCvarList[CVAR_LASERMINE_ACTIVE_TIME]), OnActivateLaser, hPack, TIMER_FLAG_NO_MAPCHANGE | TIMER_HNDL_CLOSE);
// Hook damage of the lasermine SDKHook(nMine, SDKHook_OnTakeDamage, OnTakeDamage);
/** * Called when a clients press 'R' button. * * @param clientIndex The client index. **/ void PickUpLasermine(int clientIndex) { #pragma unused clientIndex
// Do the trace Handle hTrace = TraceRay(clientIndex);
// Initialize entity index int nEntity = -1;
// If trace hit the lasermine if (TR_DidHit(hTrace) && (nEntity = TR_GetEntityIndex(hTrace)) > MaxClients) { // Validate client index and owner index, then pickup lasermine if (GetClientByLasermine(nEntity) == clientIndex) { // Give lasermine GiveLasermine(clientIndex);
/** * Called, when lasermine is activated. * * @param hTimer The timer handle. * @param hPack The data pack. **/ public Action OnActivateLaser(Handle hTimer, any hPack) { // Resets the position in a data pack ResetPack(hPack);
// Get values from datapack int nMine = ReadPackCell(hPack); int nBeam = ReadPackCell(hPack);
// Convert string from datapack ReadPackString(hPack, sClassname, sizeof(sClassname));
// If entity is valid, then emit activation sound if (IsValidEdict(nMine)) { EmitSoundToAll("*/zbm3/mine/mine_activate.mp3", nMine, SNDCHAN_STATIC); }
// If entity is valid, then activate it if(IsValidEdict(nBeam)) { // Iniliaze char char sDispatch[SMALL_LINE_LENGTH];
// Turn on the beam AcceptEntityInput(nBeam, "TurnOn");
// Set color for the beam model SetEntityRenderColor(nBeam, iColor[0], iColor[1], iColor[2]);
// Set modified flags on the beam Format(sDispatch, sizeof(sDispatch), "%s,TurnOff,,0.001,-1", sClassname); DispatchKeyValue(nBeam, "OnTouchedByEntity", sDispatch); Format(sDispatch, sizeof(sDispatch), "%s,TurnOn,,0.002,-1", sClassname); DispatchKeyValue(nBeam, "OnTouchedByEntity", sDispatch); }
// Destroy timer return Plugin_Stop; }
/** * Called when a clients touch env_beam entity. * * @param sOutput The output char. * @param nEntity The entity index. * @param activatorIndex The activator index. * @param flDelay The delay of updating. **/ public void EventBeamTouched(const char[] sOutput, int nEntity, int activatorIndex, float flDelay) { #pragma unused activatorIndex
// If round end, then stop if (ZP_GetRoundState(STATE_END_ROUND)) { return; }
// If entity isn't valid, then stop if(!IsValidEdict(nEntity)) { return; }
// Verify that the activator is exist if (!IsPlayerExist(activatorIndex)) { return; }
// Verify that the activator is zombie if(!ZP_IsPlayerZombie(activatorIndex)) { return; }
// Get the owner of the lasermine int ownerIndex = GetEntPropEnt(nEntity, Prop_Data, "m_hOwnerEntity");
// Verify that the owner is connected if (!IsPlayerExist(ownerIndex, false)) { return; }
/** * Return owner index from beam entity. * * @param nEntity The entity index. * @return The client index. **/ stock int GetClientByLasermine(int nEntity) { // Get beam index from lasermine int nBeam = GetBeamByLasermine(nEntity)
// If valid if (nBeam != -1) { return GetEntPropEnt(nBeam, Prop_Data, "m_hOwnerEntity"); }
// If didn't find, then stop return -1; }
/** * Return beam index from lasermine entity. * * @param nEntity The entity index. * @return The beam index. **/ stock int GetBeamByLasermine(int nEntity) { // If valid if (IsEntityLasermine(nEntity)) { return GetEntPropEnt(nEntity, Prop_Data, "m_hMoveChild"); }
// If didn't find, then stop return -1; }
/** * Check lasermine entity valid or not. * * @param nEntity The entity index. * @return True or false. **/ stock bool IsEntityLasermine(int nEntity) { // If entity isn't valid, then stop if (nEntity <= MaxClients || !IsValidEdict(nEntity)) { return false; }
// Return true, if found return (StrEqual(sModel, MODEL_MINE, false) && GetEntPropEnt(nEntity, Prop_Data, "m_hMoveChild") != -1) ? true : false; }
/** * Give lasermine to the player and send the info message. * * @param clientIndex The client index. **/ stock void GiveLasermine(int clientIndex) { // Give lasermine gLaserMine[clientIndex]++;
// Set translation target SetGlobalTransTarget(clientIndex);
// Show message PrintHintText(clientIndex, "%t", "@Buy lasermine", gLaserMine[clientIndex]); }
/** * Check all entities and remove lasermines. * * @param clientIndex The client index. **/ stock void RemoveLasermine(int clientIndex) { #pragma unused clientIndex
// Get max amount of entities int nGetMaxEnt = GetMaxEntities();
// nEntity = entity index for (int nEntity = 0; nEntity <= nGetMaxEnt; nEntity++) { // Validate client index and owner index, then delete entity if (GetClientByLasermine(nEntity) == clientIndex) { AcceptEntityInput(nEntity, "Kill"); } } }
/** * Delay function. * * @param clientIndex The client index. * @param flDelay The delay of updating. **/ stock bool IsDelay(int clientIndex, float flDelay) { // Initialize time array static float flTime[MAXPLAYERS+1];
// Returns the game time based on the game tick float flCurrentTime = GetEngineTime();
// Cooldown don't over yet, then stop if ((flCurrentTime - flTime[clientIndex]) < flDelay) { // Block usage return true; }
// Update countdown time flTime[clientIndex] = flCurrentTime;
// Allow usage return false; }
/* * Trace filtering functions */
/** * Starts up a new trace ray using a new trace result and a customized trace ray filter. * Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter function is currently not allowed and may not work. * * @param clientIndex The client index. **/ Handle TraceRay(int clientIndex) { #pragma unused clientIndex
I have probmel... entities randomly disappear in game (Start of round, mid and end): weapons, lasermines, new lights, etc. But disappering only freshly entities (10-30 seconds), and I don't know why.
I think you have this problem.
I have probmel... entities randomly disappear in game (Start of round, mid and end): weapons, lasermines, new lights, etc. But disappering only freshly entities (10-30 seconds), and I don't know why.
I think you have this problem.
Have seen only at lasermines, other entities didn't disappear. And not only freshly, i saw it after 1 -2 min. And i remember it was with source mode(zp 6.7) until i changed any code(maybe).Maybe not and it's my fault.
I have probmel... entities randomly disappear in game (Start of round, mid and end): weapons, lasermines, new lights, etc. But disappering only freshly entities (10-30 seconds), and I don't know why.
I think you have this problem.
You was right. Disappering only freshly entities. Do you know how to fix that?
You was right. Disappering only freshly entities. Do you know how to fix that?
I don't know... I spotted this problem 2 years ago. I was looking sourcecode for check removing entities, but not found.
m! Have you got GrenadeEffects on zp?
int GetAlivePlayers(int team = 0) { int alives = 0 for(int i = 1; i<=64; i++) { if(IsClientInGame(i) && GetClientTeam(i) > 1 && IsPlayerAlive(i) && ((team != 0) == (GetClientTeam(i) == team))) alives++ } return alives }
On windows I dont have that problem, also i check that mod on Linux on myarena hosting and didnt find that problem, i think problem can be caused by some cs go build
Small update
Quote:
- Version: 6.8 (Jule 29 2017)
* Fix with m4a1_silencer
* Added block of warmup in the core
I started updating my second mod (Zombie Mod Extension) , I already added human classes and want to create simple ZP 4.3 CS 1.6 Menu of buying in that mod, so it will be more comfortable for Zombie Escape Servers