Код: Выделить всё
#include <sourcemod>
#include <sdktools>
//#include "satellite.inc"
#define PLUGIN_VERSION "1.11"
#define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
#define DEFAULT_TIMER_FLAGS TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE
#define SOUND_IMPACT01 "animation/van_inside_hit_wall.wav"
#define SOUND_IMPACT02 "ambient/explosions/explode_3.wav"
#define SOUND_DEFROST "physics/glass/glass_sheet_break1.wav"
#define SPRITE_BEAM "materials/sprites/laserbeam.vmt"
#define SPRITE_HALO "materials/sprites/halo01.vmt"
#define ENTITY_GASCAN "models/props_junk/gascan001a.mdl"
#define ENTITY_PROPANE "models/props_junk/propanecanister001a.mdl"
#define ENTITY_OXYGEN "models/props_equipment/oxygentank01.mdl"
#define ENTITY_EXPLOSIVE "models/props_junk/explosive_box001.mdl"
#define OFF 0
#define ON 1
#define EXPLODE 1
new g_FreezeSerial[MAXPLAYERS+1] = { 0, ... };
new g_FreezeTime[MAXPLAYERS+1] = { 0, ... };
new g_FreezeBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_FreezeBombTime[MAXPLAYERS+1] = { 0, ... };
new g_Serial_Gen = 0;
new g_GameEngine = SOURCE_SDK_UNKNOWN;
new g_GlowSprite;
new g_BeamSprite;
new g_HaloSprite;
new freeze[MAXPLAYERS+1];
new Handle:l4d2_freeze_radius;
new Handle:l4d2_freeze_time = INVALID_HANDLE;
//new Float:trsPos[MAXPLAYERS+1][3];
new Handle:Special_Ammo_Count;
new Handle:Special_Ammo_Bonus_Count;
public Plugin:myinfo =
{
name = "[L4D2] Ammo Control MOD",
author = "AtomicStryker",
// + some functions from http://forums.alliedmods.net/showthread.php?p=1229450
description = " Allows Customization of some gun related game mechanics ",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net/showthread.php?p=1020236"
}
public OnPluginStart()
{
g_GameEngine = GuessSDKVersion();
HookEvent("upgrade_pack_added", Event_SpecialAmmo);
HookEvent("upgrade_pack_used", Event_UpgradePackUsed);
HookEvent("round_start", Event_RoundStart);
HookEvent("weapon_reload", Event_WeaponReload);
// HookEvent("player_death", Event_PlayerDeath);
Special_Ammo_Count = CreateConVar("l4d2_ammo_upgradepack_count", "15", "", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY);
Special_Ammo_Bonus_Count = CreateConVar("l4d2_ammo_upgradepack_bcount", "50", "", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY);
l4d2_freeze_radius = CreateConVar("l4d2_freeze_radius", "300.0", "Freeze Radius", FCVAR_NOTIFY);
l4d2_freeze_time = CreateConVar("l4d2_freeze_time", "15.0", "Freeze time", FCVAR_NOTIFY);
RegAdminCmd("sm_test", CMD_Test, ADMFLAG_CHEATS, "");
RegAdminCmd("sm_blizzard", CMD_Blizzard, ADMFLAG_CHEATS, "");
}
public Action:CMD_Blizzard(client, args)
{
Blizzard(client);
}
public Action:CMD_Test(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_give <args>");
return Plugin_Handled;
}
decl String:argstring[255];
GetCmdArgString(argstring, sizeof(argstring));
if (StrEqual(argstring, "blizzard", false))
{
Blizzard(client);
return Plugin_Continue;
}
if (StrEqual(argstring, "blizzard+ring", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
CreateRingEffect(client, 20, 20, 230, 230, position, 2.0, 1000.0);
Blizzard(client);
return Plugin_Continue;
}
if (StrEqual(argstring, "ring", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
CreateRingEffect(client, 20, 20, 230, 230, position, 2.0, 1000.0);
return Plugin_Continue;
}
if (StrEqual(argstring, "boom", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
Boom(position);
Boom(position);
Boom(position);
return Plugin_Continue;
}
if (StrEqual(argstring, "boom2", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
Boom2(position);
Boom2(position);
Boom2(position);
Boom2(position);
Boom2(position);
return Plugin_Continue;
}
if (StrEqual(argstring, "happy", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
//Happy(position);
return Plugin_Continue;
}
if (StrEqual(argstring, "fire", false))
{
new Float:position[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", position);
Fire(position);
return Plugin_Continue;
}
return Plugin_Continue;
}
public OnMapStart()
{
PrecacheSound(SOUND_FREEZE, true);
g_GlowSprite = PrecacheModel("sprites/blueglow2.vmt");
g_BeamSprite = PrecacheModel(SPRITE_BEAM);
g_HaloSprite = PrecacheModel(SPRITE_HALO);
}
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
KillAllFreezes();
}
public Action:Event_WeaponReload(Handle:event, const String:name[], bool:dontBroadcast)
{
new manual_reload = GetEventBool(event, "manual");
if (!manual_reload)
{
return Plugin_Continue;
}
new client = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:PrimaryWeaponName[64];
new entity = GetPlayerWeaponSlot(client, 0);
if (entity < 0)
{
return Plugin_Continue;
}
GetEdictClassname(entity, PrimaryWeaponName, sizeof(PrimaryWeaponName));
if (StrEqual(PrimaryWeaponName, "weapon_grenade_launcher", false))
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public SpawnItem(any:client, const String:ItemName[])
{
decl Float:VecOrigin[3], Float:VecAngles[3], Float:VecDirection[3];
new SpawnItemEntity = CreateEntityByName(ItemName);
if (SpawnItemEntity == -1)
{
ReplyToCommand(client, "\x05[SM] \x03 Spawn Failed (\x01%s\x03)", ItemName);
}
DispatchKeyValue(SpawnItemEntity, "model", "spawn_entity_1");
DispatchKeyValueFloat (SpawnItemEntity, "MaxPitch", 360.00);
DispatchKeyValueFloat (SpawnItemEntity, "MinPitch", -360.00);
DispatchKeyValueFloat (SpawnItemEntity, "MaxYaw", 90.00);
DispatchSpawn(SpawnItemEntity);
GetClientAbsOrigin(client, VecOrigin);
GetClientEyeAngles(client, VecAngles);
GetAngleVectors(VecAngles, VecDirection, NULL_VECTOR, NULL_VECTOR);
VecOrigin[0] += VecDirection[0] * 32;
VecOrigin[1] += VecDirection[1] * 32;
VecOrigin[2] += VecDirection[2] * 1;
VecAngles[0] = 0.0;
VecAngles[2] = 0.0;
DispatchKeyValueVector(SpawnItemEntity, "Angles", VecAngles);
DispatchSpawn(SpawnItemEntity);
TeleportEntity(SpawnItemEntity, VecOrigin, NULL_VECTOR, NULL_VECTOR);
}
public HealthBox(client)
{
new ItemNumber;
new String:ItemName[36];
for (new i = 0; i < 13; i++)
{
ItemNumber = GetRandomInt(1, 4);
switch (ItemNumber)
{
case 1: ItemName = "weapon_first_aid_kit";
case 2: ItemName = "weapon_defibrillator";
case 3: ItemName = "weapon_pain_pills";
case 4: ItemName = "weapon_adrenaline";
}
SpawnItem(client, ItemName)
}
}
public PushAway(Float:force, Float:radius, Float:position[3], Float:duration)
{
new push = CreateEntityByName("point_push");
DispatchKeyValueFloat (push, "magnitude", force);
DispatchKeyValueFloat (push, "radius", radius);
SetVariantString("spawnflags 24");
AcceptEntityInput(push, "AddOutput");
DispatchSpawn(push);
TeleportEntity(push, position, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(push, "Enable", -1, -1);
CreateTimer(duration, DeletePushForce, push);
}
public MoveTracePosition(client, Float:position[3], min, max)
{
new point = GetRandomInt(1, 4);
new xOffset = GetRandomInt(min, max);
new yOffset = GetRandomInt(min, max);
if (point == 1)
{
position[0] -= xOffset;
position[1] += yOffset;
}
else if(point == 2)
{
position[0] += xOffset;
position[1] += yOffset;
}
else if(point == 3)
{
position[0] -= xOffset;
position[1] -= yOffset;
}
else if(point == 4)
{
position[0] += xOffset;
position[1] -= yOffset;
}
}
public CreateRingEffect(client, colRed, colGre, colBlu, alpha, Float:position[3], Float:width, Float:duration)
{
decl color[4];
color[0] = colRed;
color[1] = colGre;
color[2] = colBlu;
color[3] = alpha;
// decl Float:trspos[3];
// GetClientEyePosition(client, trspos);
TE_SetupBeamRingPoint(position, 300.0, 10.0, g_BeamSprite, g_HaloSprite, 0, 10, 1.2, 4.0, 0.5, {150, 150, 230, 230}, 80, 0);
TE_SendToAll();
}
public ScreenFade(target, red, green, blue, alpha, duration, type)
{
new Handle:msg = StartMessageOne("Fade", target);
BfWriteShort(msg, 500);
BfWriteShort(msg, duration);
if (type == 0)
BfWriteShort(msg, (0x0002 | 0x0008));
else
BfWriteShort(msg, (0x0001 | 0x0010));
BfWriteByte(msg, red);
BfWriteByte(msg, green);
BfWriteByte(msg, blue);
BfWriteByte(msg, alpha);
EndMessage();
}
stock DamageEffect(target, Float:damage)
{
decl String:tName[20];
Format(tName, 20, "target%d", target);
new pointHurt = CreateEntityByName("point_hurt");
DispatchKeyValue(target, "targetname", tName);
DispatchKeyValueFloat(pointHurt, "Damage", damage);
DispatchKeyValue(pointHurt, "DamageTarget", tName);
DispatchKeyValue(pointHurt, "DamageType", "65536");
DispatchSpawn(pointHurt);
AcceptEntityInput(pointHurt, "Hurt");
AcceptEntityInput(pointHurt, "Kill");
}
public Action:DefrostPlayer(Handle:timer, any:entity)
{
if(IsValidEdict(entity) && IsValidEntity(entity))
{
decl Float:entPos[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entPos);
EmitAmbientSound(SOUND_DEFROST, entPos, entity, SNDLEVEL_RAIDSIREN);
SetEntityMoveType(entity, MOVETYPE_WALK);
SetEntityRenderColor(entity, 255, 255, 255, 255);
ScreenFade(entity, 0, 0, 0, 0, 0, 1);
freeze[entity] = OFF;
}
}
public FreezePlayer(entity, Float:pos[3], Float:time)
{
SetEntityMoveType(entity, MOVETYPE_NONE);
SetEntityRenderColor(entity, 102, 204, 255, 195);
ScreenFade(entity, 0, 128, 255, 192, RoundToZero(time * 1000), 1);
EmitAmbientSound(SOUND_FREEZE, pos, entity, SNDLEVEL_RAIDSIREN);
TE_SetupGlowSprite(pos, g_GlowSprite, time, 0.5, 130);
TE_SendToAll();
freeze[entity] = ON;
CreateTimer(time, DefrostPlayer, entity);
}
public Boom(Float:position[3])
{
new entity = CreateEntityByName("prop_physics");
if (!IsValidEntity(entity))
{
return;
}
DispatchKeyValue(entity, "model", ENTITY_PROPANE);
DispatchSpawn(entity);
SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
TeleportEntity(entity, position, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(entity, "break");
}
public Boom2(Float:position[3])
{
new entity = CreateEntityByName("prop_physics");
if (!IsValidEntity(entity))
{
return;
}
DispatchKeyValue(entity, "model", ENTITY_OXYGEN);
DispatchSpawn(entity);
SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
TeleportEntity(entity, position, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(entity, "break");
}
public Fire(Float:position[3])
{
new entity = CreateEntityByName("prop_physics");
if (!IsValidEntity(entity))
{
return;
}
DispatchKeyValue(entity, "model", ENTITY_GASCAN);
DispatchSpawn(entity);
SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
TeleportEntity(entity, position, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(entity, "break");
}
public LittleFlower(client, type)
{
decl Float:trspos[3];
GetClientEyePosition(client, trspos);
/* Cause fire(type=0) or explosion(type=1) */
new entity = CreateEntityByName("prop_physics");
if (IsValidEntity(entity))
{
trspos[2] += 20;
if (type == 0)
/* fire */
DispatchKeyValue(entity, "model", ENTITY_GASCAN);
else
/* explode */
DispatchKeyValue(entity, "model", ENTITY_PROPANE);
DispatchSpawn(entity);
SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
TeleportEntity(entity, trspos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(entity, "break");
}
}
public Action:DeletePushForce(Handle:timer, any:ent)
{
if (IsValidEntity(ent))
{
decl String:classname[64];
GetEdictClassname(ent, classname, sizeof(classname));
if (StrEqual(classname, "point_push", false))
{
AcceptEntityInput(ent, "Disable");
AcceptEntityInput(ent, "Kill");
RemoveEdict(ent);
}
}
}
public Blizzard(client)
{
decl Float:pos[3];
decl Float:trspos[3];
GetClientEyePosition(client, trspos);
/* Emit impact sound */
EmitAmbientSound(SOUND_IMPACT01, trspos);
EmitAmbientSound(SOUND_IMPACT02, trspos);
/* Laser effect */
// CreateLaserEffect(client, 80, 80, 230, 230, 6.0, 1.0, VARTICAL);
TE_SetupBeamRingPoint(trspos, 10.0, GetConVarFloat(l4d2_freeze_radius), g_BeamSprite, g_HaloSprite, 0, 10, 0.3, 10.0, 0.5, {40, 40, 230, 230}, 400, 0);
TE_SendToAll();
/* Freeze special infected and survivor in the radius */
for (new i = 1; i <= GetMaxClients(); i++)
{
if (!IsClientInGame(i) || !IsPlayerAlive(i))
continue;
GetClientEyePosition(i, pos);
if(GetVectorDistance(pos, trspos) < GetConVarFloat(l4d2_freeze_radius))
{
if(GetEntProp(i, Prop_Send, "m_zombieClass") != 8)
{
FreezePlayer(i, pos, GetConVarFloat(l4d2_freeze_time));
}
}
}
/* Freeze infected in the radius */
decl MaxEntities, String:mName[64], Float:entPos[3];
MaxEntities = GetMaxEntities();
for (new i = 1; i <= MaxEntities; i++)
{
if (IsValidEdict(i) && IsValidEntity(i))
{
GetEntPropString(i, Prop_Data, "m_ModelName", mName, sizeof(mName))
if (StrContains(mName, "infected") != -1)
{
GetEntPropVector(i, Prop_Send, "m_vecOrigin", entPos)
if (GetVectorDistance(trspos, entPos) < GetConVarFloat(l4d2_freeze_radius))
{
FreezePlayer(i, pos, GetConVarFloat(l4d2_freeze_time));
// EmitAmbientSound(SOUND_FREEZE, entPos, i, SNDLEVEL_RAIDSIREN);
// TE_SetupGlowSprite(entPos, g_GlowSprite, 5.0, 3.0, 130);
// TE_SendToAll();
// DamageEffect(i, 100.0);
}
}
}
}
}
FreezeClient(client, time)
{
if (g_FreezeSerial[client] != 0)
{
UnfreezeClient(client);
return;
}
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityRenderColor(client, 0, 128, 255, 192);
new Float:vec[3];
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
g_FreezeTime[client] = time;
g_FreezeSerial[client] = ++ g_Serial_Gen;
CreateTimer(1.0, Timer_Freeze, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
}
UnfreezeClient(client)
{
g_FreezeSerial[client] = 0;
g_FreezeTime[client] = 0;
if (IsClientInGame(client))
{
new Float:vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
SetEntityMoveType(client, MOVETYPE_WALK);
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
public Action:Timer_Freeze(Handle:timer, any:value)
{
new client = value & 0x7f;
new serial = value >> 7;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| g_FreezeSerial[client] != serial)
{
UnfreezeClient(client);
return Plugin_Stop;
}
if (g_FreezeTime[client] == 0)
{
UnfreezeClient(client);
/* HintText doesn't work on Dark Messiah */
if (g_GameEngine != SOURCE_SDK_DARKMESSIAH)
{
PrintHintText(client, "You are now unfrozen.");
}
else
{
PrintCenterText(client, "You are now unfrozen.");
}
return Plugin_Stop;
}
if (g_GameEngine != SOURCE_SDK_DARKMESSIAH)
{
PrintHintText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
}
else
{
PrintCenterText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
}
g_FreezeTime[client]--;
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityRenderColor(client, 0, 128, 255, 135);
new Float:vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupGlowSprite(vec, g_GlowSprite, 0.95, 1.5, 50);
TE_SendToAll();
return Plugin_Continue;
}
KillAllFreezes()
{
for(new i = 1; i <= MaxClients; i++)
{
if (g_FreezeSerial[i] != 0)
{
UnfreezeClient(i);
}
if (g_FreezeBombSerial[i] != 0)
{
KillFreezeBomb(i);
}
}
}
KillFreezeBomb(client)
{
g_FreezeBombSerial[client] = 0;
g_FreezeBombTime[client] = 0;
if (IsClientInGame(client))
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
public OnClientPostAdminCheck(client)
{
if (!IsFakeClient(client))
{
UnfreezeClient(client);
}
SetHealthMax(client, 100);
}
public Action:Kickbot(Handle:timer, any:client)
{ // code from l4d2_monsterbots.sp
if (IsClientInGame(client))
{
if (IsFakeClient(client))
{
KickClient(client);
}
}
}
public Action:Event_PlayerDeath(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if (client == 0)
return;
if (GetClientTeam(client) != 3)
return;
ChangeClientTeam(client, 2);
}
stock SpawnCommandEx(client, String:command[], String:arguments[] = "", count)
{ // code from l4d2_monsterbots.sp
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
for (new i = 1; i < count; i++)
{
FakeClientCommand(client, "%s %s", command, arguments);
}
SetCommandFlags(command, flags);
}
stock SpawnCommand(client, String:command[], String:arguments[] = "")
{ // code from l4d2_monsterbots.sp
if (client)
{
ChangeClientTeam(client, 3);
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "%s %s", command, arguments);
SetCommandFlags(command, flags);
CreateTimer(0.1, Kickbot, client);
}
}
stock SpawnCommandControl(client, String:command[], String:arguments[] = "")
{ // code from l4d2_monsterbots.sp
if (client)
{
ChangeClientTeam(client, 3);
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "%s %s", command, arguments);
SetCommandFlags(command, flags);
}
}
stock IsTankAlive()
{
decl String: classname[32];
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
if (GetClientTeam(i) == 3)
{
if (IsFakeClient(i))
{
GetClientModel(i, classname, sizeof(classname));
if (StrContains(classname, "tank"))
{
return 1;
}
}
}
}
}
return 0;
}
public Action:Event_SpecialAmmo(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new upgradeid = GetEventInt(event, "upgradeid");
decl String:class[256];
GetEdictClassname(upgradeid, class, sizeof(class));
if (StrEqual(class, "upgrade_laser_sight"))
{
if (GetRandomInt(1, 2) == 1)
{
RemoveEdict(upgradeid);
}
return;
}
// decl String:s_Weapon[32];
decl String:PrimaryWeaponName[64];
// GetClientWeapon(client, s_Weapon, sizeof(s_Weapon))
GetEdictClassname(GetPlayerWeaponSlot(client, 0), PrimaryWeaponName, sizeof(PrimaryWeaponName));
if (StrEqual(PrimaryWeaponName, "weapon_grenade_launcher", false))
{
new MaxAmmo = GetRandomInt(1, 10);
if (MaxAmmo == 1)
{
SetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1", GetConVarInt(Special_Ammo_Bonus_Count));
SetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", GetConVarInt(Special_Ammo_Bonus_Count), 1);
}
else
{
SetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1", GetConVarInt(Special_Ammo_Count));
SetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", GetConVarInt(Special_Ammo_Count), 1);
}
RemoveEdict(upgradeid);
return;
}
if (StrEqual(PrimaryWeaponName, "weapon_rifle_m60", false))
{
RemoveEdict(upgradeid);
return;
}
else if (GetSpecialAmmoInPlayerGun(client) > 1)
{
new AMMORND = GetRandomInt(1, 3);
SetSpecialAmmoInPlayerGun(client, AMMORND * GetSpecialAmmoInPlayerGun(client));
}
RemoveEdict(upgradeid);
}
//GetHealthMax(client) //Job Basis Health + Temp Health Skill
//{ // http://forums.alliedmods.net/showthread.php?p=1208492
// new entvalue;
// new m_Offset;
// m_Offset = FindSendPropOffs("CBasePlayer", "m_iHealth") //Find the offset
// if (m_Offset < 0)
// {
// return 0;
// }
// entvalue = GetEntData(client, m_Offset, 4) //Get the value of m_iHealth
// return entvalue;
//}
SetHealthMax(client, amount)
{ // http://forums.alliedmods.net/showthread.php?p=1208492
if (client != 0 && !IsFakeClient(client))
{
new m_Offset;
m_Offset = FindSendPropOffs("CBasePlayer", "m_iHealth") //Find the offset
SetEntData(client, m_Offset, amount, 4, true);
// SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), amount, 4, true)
}
// PrintToChatAll("HEALTH MAX :: %N :: %d", client, GetHealthMax(client));
}
public Action:Event_UpgradePackUsed(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new upgradeid = GetEventInt(event, "upgradeid");
new RND = GetRandomInt(1, 6);
if (RND == 1)
{
new LaserEntity = CreateEntityByName("upgrade_laser_sight");
if (LaserEntity == -1)
{
return;
}
PrintToChat(client, "\x05You have found a laser sight!");
new Float:vecOrigin[3];
new Float:angRotation[3];
GetEntPropVector(upgradeid, Prop_Send, "m_vecOrigin", vecOrigin);
GetEntPropVector(upgradeid, Prop_Send, "m_angRotation", angRotation);
RemoveEdict(upgradeid);
TeleportEntity(LaserEntity, vecOrigin, angRotation, NULL_VECTOR);
DispatchSpawn(LaserEntity);
return;
}
RND = GetRandomInt(1, 120);
if (RND < 3)
{
SpawnCommandEx(client, "z_spawn", "witch auto", 7);
PrintHintTextToAll("%N have found a witchbox!", client);
RemoveEdict(upgradeid);
return;
}
if (RND < 5)
{
if (!IsTankAlive())
{
new flags = GetCommandFlags("z_spawn");
SetCommandFlags("z_spawn", flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "z_spawn tank auto");
SetCommandFlags("z_spawn", flags);
if (IsTankAlive())
{
PrintHintTextToAll("%N have found a tankbox!", client);
RemoveEdict(upgradeid);
return;
}
}
}
if (RND < 6)
{
PrintHintTextToAll("%N have found a panicbox!", client);
new String:command[] = "director_force_panic_event";
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, command);
SetCommandFlags(command, flags);
RemoveEdict(upgradeid);
return;
}
if (RND < 10)
{
PrintHintTextToAll("%N have found a icebox!", client);
FreezeClient(client, 20);
RemoveEdict(upgradeid);
return;
}
if (RND < 12)
{
PrintHintTextToAll("%N have found a freezebox!", client);
new Float:position[3];
GetEntPropVector(upgradeid, Prop_Send, "m_vecOrigin", position);
Blizzard(client);
CreateRingEffect(client, 20, 20, 230, 230, position, 2.0, 1000.0);
RemoveEdict(upgradeid);
return;
}
if (RND < 16)
{
PrintHintTextToAll("%N have found a boombox!", client);
new Float:position[3];
GetEntPropVector(upgradeid, Prop_Send, "m_vecOrigin", position);
Boom2(position);
Boom2(position);
Boom2(position);
Boom2(position);
Boom2(position);
RemoveEdict(upgradeid);
return;
}
if (RND < 18)
{
PrintHintTextToAll("%N have found a firebox!", client);
new Float:position[3];
GetEntPropVector(upgradeid, Prop_Send, "m_vecOrigin", position);
Fire(position);
RemoveEdict(upgradeid);
return;
}
if (RND < 20)
{
PrintHintTextToAll("%N have found a medbox!", client);
switch (GetRandomInt(1, 2))
{
case 1: HealthBox(client);
case 2:
{
new flags = GetCommandFlags("give");
SetCommandFlags("give", flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "give health");
SetCommandFlags("give", flags);
}
}
RemoveEdict(upgradeid);
return;
}
// else if (RND < 50)
// {
// PrintHintTextToAll("%N have found a healthbox!", client);
// SetHealthMax(client, 75 + (GetRandomInt(0, 2) * 25));
// RemoveEdict(upgradeid);
// return;
// }
}
public give_laser_sight(client)
{
new flags = GetCommandFlags("upgrade_add");
SetCommandFlags("upgrade_add", flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "upgrade_add laser_sight");
SetCommandFlags("upgrade_add", flags);
}
stock GetSpecialAmmoInPlayerGun(client) //returns the amount of special rounds in your gun
{
if (!client)
{
// client = 1;
return 0;
}
new gunent = GetPlayerWeaponSlot(client, 0);
if (IsValidEdict(gunent))
return GetEntProp(gunent, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", 1);
else return 0;
}
SetSpecialAmmoInPlayerGun(client, amount)
{
if (!client)
{
// client = 1;
return;
}
new gunent = GetPlayerWeaponSlot(client, 0);
if (IsValidEdict(gunent))
SetEntProp(gunent, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", amount, 1);
}