mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 20:23:20 +00:00
Changes
This commit is contained in:
parent
832ab67665
commit
16868d3d51
12 changed files with 326 additions and 92 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -55,6 +55,7 @@ public void Event_PlayerUse(Event event, const char[] name, bool dontBroadcast)
|
|||
GetClientName(player_id, player_name, sizeof(player_name));
|
||||
GetEntityClassname(target_id, entity_name, sizeof(entity_name));
|
||||
|
||||
|
||||
if(StrEqual(entity_name,"upgrade_laser_sight")) {
|
||||
if(!bLasersUsed[target_id]) {
|
||||
bLasersUsed[target_id] = true;
|
||||
|
@ -94,9 +95,6 @@ public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prints human readable duration from milliseconds
|
||||
*
|
||||
|
|
159
scripting/include/jutils.inc
Normal file
159
scripting/include/jutils.inc
Normal file
|
@ -0,0 +1,159 @@
|
|||
#if defined _jutils_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _jutils_included
|
||||
|
||||
#define MODEL_FRANCIS "models/survivors/survivor_biker.mdl"
|
||||
#define MODEL_LOUIS "models/survivors/survivor_manager.mdl"
|
||||
#define MODEL_ZOEY "models/survivors/survivor_teenangst.mdl"
|
||||
#define MODEL_BILL "models/survivors/survivor_namvet.mdl"
|
||||
#define MODEL_NICK "models/survivors/survivor_gambler.mdl"
|
||||
#define MODEL_COACH "models/survivors/survivor_coach.mdl"
|
||||
#define MODEL_ELLIS "models/survivors/survivor_mechanic.mdl"
|
||||
#define MODEL_ROCHELLE "models/survivors/survivor_producer.mdl"
|
||||
#define MODEL_MINIGUN "models/w_models/weapons/w_minigun.mdl"
|
||||
|
||||
stock void GetHorizontalPositionFromOrigin(const float pos[3], const float ang[3], float units, float finalPosition[3]) {
|
||||
float theta = DegToRad(ang[1]);
|
||||
finalPosition[0] = units * Cosine(theta) + pos[0];
|
||||
finalPosition[1] = units * Sine(theta) + pos[1];
|
||||
finalPosition[2] = pos[2];
|
||||
}
|
||||
stock void GetHorizontalPositionFromClient(int client, float units, float finalPosition[3]) {
|
||||
float pos[3], ang[3];
|
||||
GetClientEyeAngles(client, ang);
|
||||
GetClientAbsOrigin(client, pos);
|
||||
|
||||
float theta = DegToRad(ang[1]);
|
||||
pos[0] += -150 * Cosine(theta);
|
||||
pos[1] += -150 * Sine(theta);
|
||||
finalPosition = pos;
|
||||
}
|
||||
|
||||
stock void L4D2_RunScript(const char[] sCode, any ...) {
|
||||
static int iScriptLogic = INVALID_ENT_REFERENCE;
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
|
||||
iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE|| !IsValidEntity(iScriptLogic))
|
||||
SetFailState("Could not create 'logic_script'");
|
||||
|
||||
DispatchSpawn(iScriptLogic);
|
||||
}
|
||||
|
||||
static char sBuffer[512];
|
||||
VFormat(sBuffer, sizeof(sBuffer), sCode, 2);
|
||||
|
||||
SetVariantString(sBuffer);
|
||||
AcceptEntityInput(iScriptLogic, "RunScriptCode");
|
||||
}
|
||||
stock void ShowDelayedHintToAll(const char[] format, any ...) {
|
||||
char buffer[254];
|
||||
VFormat(buffer, sizeof(buffer), format, 2);
|
||||
static int hintInt = 0;
|
||||
if(hintInt >= 7) {
|
||||
PrintHintTextToAll("%s",buffer);
|
||||
hintInt = 0;
|
||||
}
|
||||
hintInt++;
|
||||
}
|
||||
stock bool FindSurvivorModel(const char str[16], char[] model, int modelStrSize) {
|
||||
int possibleNumber = StringToInt(str, 10);
|
||||
if(modelStrSize == 1 && possibleNumber <= 7 && possibleNumber >= 0) {
|
||||
switch(possibleNumber) {
|
||||
case 0: {
|
||||
strcopy(model, modelStrSize, MODEL_NICK);
|
||||
} case 1: {
|
||||
strcopy(model, modelStrSize, MODEL_ELLIS);
|
||||
} case 2: {
|
||||
strcopy(model, modelStrSize, MODEL_COACH);
|
||||
} case 3: {
|
||||
strcopy(model, modelStrSize, MODEL_ROCHELLE);
|
||||
} case 4: {
|
||||
strcopy(model, modelStrSize, MODEL_BILL);
|
||||
} case 5: {
|
||||
strcopy(model, modelStrSize, MODEL_ZOEY);
|
||||
} case 6: {
|
||||
strcopy(model, modelStrSize, MODEL_FRANCIS);
|
||||
} case 7: {
|
||||
strcopy(model, modelStrSize, MODEL_LOUIS);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
if(possibleNumber == 0) {
|
||||
//try to parse str
|
||||
if(StrEqual(str, "bill", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_BILL);
|
||||
}else if(StrEqual(str, "zoey", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ZOEY);
|
||||
}else if(StrEqual(str, "francis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_FRANCIS);
|
||||
}else if(StrEqual(str, "louis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_LOUIS);
|
||||
}else if(StrEqual(str, "nick", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_NICK);
|
||||
}else if(StrEqual(str, "ellis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ELLIS);
|
||||
}else if(StrEqual(str, "rochelle", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ROCHELLE);
|
||||
}else if(StrEqual(str, "coach", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_COACH);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
stock bool GetGround(int client, float[3] vPos, float[3] vAng) {
|
||||
GetClientAbsOrigin(client, vPos);
|
||||
vAng = vPos;
|
||||
vAng[2] += 5.0;
|
||||
vPos[2] -= 500.0;
|
||||
|
||||
Handle trace = TR_TraceRayFilterEx(vAng, vPos, MASK_SHOT, RayType_EndPoint, TraceFilter);
|
||||
if(!TR_DidHit(trace))
|
||||
{
|
||||
delete trace;
|
||||
return false;
|
||||
}
|
||||
TR_GetEndPosition(vPos, trace);
|
||||
delete trace;
|
||||
|
||||
GetClientAbsAngles(client, vAng);
|
||||
return true;
|
||||
}
|
||||
stock bool SpawnMinigun(const float vPos[3], const float vAng[3]) {
|
||||
float vDir[3], newPos[3];
|
||||
GetAngleVectors(vAng, vDir, NULL_VECTOR, NULL_VECTOR);
|
||||
vDir[0] = vPos[0] + (vDir[0] * 50);
|
||||
vDir[1] = vPos[1] + (vDir[1] * 50);
|
||||
vDir[2] = vPos[2] + 20.0;
|
||||
newPos = vDir;
|
||||
newPos[2] -= 40.0;
|
||||
|
||||
Handle trace = TR_TraceRayFilterEx(vDir, newPos, MASK_SHOT, RayType_EndPoint, TraceFilter);
|
||||
if(TR_DidHit(trace)) {
|
||||
TR_GetEndPosition(vDir, trace);
|
||||
|
||||
int minigun = CreateEntityByName("prop_mounted_machine_gun");
|
||||
minigun = EntIndexToEntRef(minigun);
|
||||
SetEntityModel(minigun, MODEL_MINIGUN);
|
||||
DispatchKeyValue(minigun, "targetname", "louis_holdout");
|
||||
DispatchKeyValueFloat(minigun, "MaxPitch", 360.00);
|
||||
DispatchKeyValueFloat(minigun, "MinPitch", -360.00);
|
||||
DispatchKeyValueFloat(minigun, "MaxYaw", 90.00);
|
||||
newPos[2] += 0.1;
|
||||
TeleportEntity(minigun, vDir, vAng, NULL_VECTOR);
|
||||
DispatchSpawn(minigun);
|
||||
delete trace;
|
||||
return true;
|
||||
}else{
|
||||
LogError("Spawn minigun trace failure");
|
||||
delete trace;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,17 +1,26 @@
|
|||
#pragma semicolon 1
|
||||
|
||||
#define DEBUG
|
||||
#define debug false
|
||||
|
||||
#define PLUGIN_NAME "L4D2 Game Info"
|
||||
#define PLUGIN_DESCRIPTION ""
|
||||
#define PLUGIN_AUTHOR "jackzmc"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
#define PLUGIN_VERSION "1.1"
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
//#include <sdkhooks>
|
||||
#include <sdkhooks>
|
||||
|
||||
char g_icDifficulty[16] = "Normal";
|
||||
char g_icGamemode[16] = "coop";
|
||||
char g_icCurrentMap[32];
|
||||
|
||||
int g_icPlayerManager; //entid -> typically 25 (MaxClients+1)
|
||||
|
||||
bool g_icHealing[MAXPLAYERS+1]; //state
|
||||
bool g_icBeingHealed[MAXPLAYERS+1]; //state
|
||||
|
||||
ConVar g_icCouponCode, g_icCouponCoins;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
|
@ -22,6 +31,7 @@ public Plugin myinfo =
|
|||
url = ""
|
||||
};
|
||||
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
EngineVersion g_Game = GetEngineVersion();
|
||||
|
@ -29,14 +39,29 @@ public OnPluginStart()
|
|||
{
|
||||
SetFailState("This plugin is for L4D/L4D2 only.");
|
||||
}
|
||||
|
||||
//hook events & cmds
|
||||
RegConsoleCmd("sm_gameinfo", PrintGameInfo, "Show the director main menu");
|
||||
HookEvent("difficulty_changed", Event_DifficultyChanged);
|
||||
HookEvent("heal_begin", Event_HealStart);
|
||||
//HookEvent("heal_end", Event_HealStop);
|
||||
HookEvent("heal_success", Event_HealStop);
|
||||
HookEvent("heal_interrupted", Event_HealStop);
|
||||
|
||||
//hook cvars, game info states
|
||||
FindConVar("z_difficulty").GetString(g_icDifficulty, sizeof(g_icDifficulty));
|
||||
CreateTimer(300.0, Timer_PrintInfoMessage, _, TIMER_REPEAT);
|
||||
}
|
||||
public OnClientPutInServer(client)
|
||||
{
|
||||
PrintToChat(client, "Welcome to the Manual Director server! For information or access the panel go to l4d2.jackz.me");
|
||||
ConVar ic_gamemode = FindConVar("mp_gamemode");
|
||||
ic_gamemode.GetString(g_icGamemode, sizeof(g_icGamemode));
|
||||
if (ic_gamemode != null) ic_gamemode.AddChangeHook(Event_GamemodeChange);
|
||||
GetCurrentMap(g_icCurrentMap, sizeof(g_icCurrentMap));
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
//setup advertisement
|
||||
CreateConVar("l4d2_gameinfo_version", PLUGIN_VERSION, "plugin version", FCVAR_SPONLY | FCVAR_DONTRECORD);
|
||||
g_icCouponCode = CreateConVar("l4d2_gameinfo_code","","Provide a coupon code");
|
||||
g_icCouponCoins = CreateConVar("l4d2_gameinfo_coins","0","Provide a coupon code's zekoins", FCVAR_NONE, true, 0.0);
|
||||
CreateTimer(400.0, Timer_PrintInfoMessage, _, TIMER_REPEAT);
|
||||
}
|
||||
// print info
|
||||
public Action Timer_PrintInfoMessage(Handle timer)
|
||||
|
@ -46,28 +71,28 @@ public Action Timer_PrintInfoMessage(Handle timer)
|
|||
}
|
||||
public Action PrintGameInfo(int client, int args) {
|
||||
//print server info
|
||||
ReplyToCommand(client, ">map,diff");
|
||||
char map[32];
|
||||
|
||||
GetCurrentMap(map, sizeof(map));
|
||||
|
||||
ReplyToCommand(client, "%s,%s",map,g_icDifficulty);
|
||||
ReplyToCommand(client, ">map,diff,mode,tempoState,totalSeconds");
|
||||
int missionDuration = GetEntProp(g_icPlayerManager, Prop_Send, "m_missionDuration", 1);
|
||||
int tempoState = GetEntProp(g_icPlayerManager, Prop_Send, "m_tempoState", 1);
|
||||
ReplyToCommand(client, "%s,%s,%s,%d,%d",g_icCurrentMap,g_icDifficulty,g_icGamemode,tempoState,missionDuration);
|
||||
//print client info
|
||||
ReplyToCommand(client,">id,name,bot,health,status,throwSlot,kitSlot,pillSlot,modelName");
|
||||
ReplyToCommand(client,">id,name,bot,health,status,throwSlot,kitSlot,pillSlot,modelName,velocity");
|
||||
for (int i = 1; i < MaxClients;i++) {
|
||||
if (!IsClientInGame(i)) continue;
|
||||
if (GetClientTeam(i) != 2) continue;
|
||||
int hp = GetClientRealHealth(i);
|
||||
int bot = IsFakeClient(i);
|
||||
bool incap = IsPlayerIncapped(i);
|
||||
bool blackandwhite = IsPlayerNearDead(i);
|
||||
bool crouched = GetEntProp(i, Prop_Send, "m_bDucked", 1) == 1;
|
||||
bool incap = GetEntProp(i, Prop_Send, "m_isIncapacitated", 1) == 1;
|
||||
bool blackandwhite = GetEntProp(i, Prop_Send, "m_bIsOnThirdStrike", 1) == 1;
|
||||
int velocity = RoundFloat(GetPlayerSpeed(i));
|
||||
|
||||
char status[9];
|
||||
char name[32];
|
||||
char pillType[32];
|
||||
char kitType[32];
|
||||
char throwType[32];
|
||||
char survType[9];
|
||||
char pillItem[32];
|
||||
char kitItem[32];
|
||||
char throwItem[32];
|
||||
char character[9];
|
||||
|
||||
if(hp < 0) {
|
||||
status = "dead";
|
||||
|
@ -75,41 +100,98 @@ public Action PrintGameInfo(int client, int args) {
|
|||
status = "incap";
|
||||
}else if(blackandwhite) {
|
||||
status = "neardead";
|
||||
}else if(g_icHealing[i]) {
|
||||
status = "healing";
|
||||
}else if(g_icBeingHealed[i]) {
|
||||
status = "bheal";
|
||||
}else if(crouched) {
|
||||
status = "crouched";
|
||||
}else{
|
||||
status = "alive";
|
||||
}
|
||||
int pillWpn = GetPlayerWeaponSlot(i, 4); //pills slot
|
||||
int kitWpn = GetPlayerWeaponSlot(i, 3);
|
||||
int throwWpn = GetPlayerWeaponSlot(i, 2);
|
||||
if(pillWpn != -1) GetEdictClassname(pillWpn, pillType, sizeof(pillType));
|
||||
if(kitWpn != -1) GetEdictClassname(kitWpn, kitType, sizeof(kitType));
|
||||
if(throwWpn != -1) GetEdictClassname(throwWpn, throwType, sizeof(throwType));
|
||||
ReplaceString(pillType, sizeof(pillType), "weapon_", "");
|
||||
ReplaceString(kitType, sizeof(kitType), "weapon_", "");
|
||||
ReplaceString(throwType, sizeof(throwType), "weapon_", "");
|
||||
GetItemSlotClassName(i, 2, throwItem, sizeof(throwItem), true);
|
||||
GetItemSlotClassName(i, 3, kitItem, sizeof(kitItem), true);
|
||||
GetItemSlotClassName(i, 4, pillItem, sizeof(pillItem), true);
|
||||
|
||||
GetClientName(i, name, sizeof(name));
|
||||
GetModelName(i, survType, sizeof(survType));
|
||||
GetModelName(i, character, sizeof(character));
|
||||
|
||||
ReplyToCommand(client,"%d,%s,%d,%d,%s,%s,%s,%s,%s", i, name, bot, hp, status, throwType, kitType, pillType, survType);
|
||||
ReplyToCommand(client,"%d,%s,%d,%d,%s,%s,%s,%s,%s,%d", i, name, bot, hp, status, throwItem, kitItem, pillItem, character, velocity);
|
||||
}
|
||||
|
||||
}
|
||||
// EVENTS //
|
||||
public void Event_GamemodeChange(ConVar cvar, const char[] oldValue, const char[] newValue) {
|
||||
cvar.GetString(g_icGamemode, sizeof(g_icGamemode));
|
||||
}
|
||||
public void OnMapStart() {
|
||||
GetCurrentMap(g_icCurrentMap, sizeof(g_icCurrentMap));
|
||||
//grab the player_manager
|
||||
//int playerManager;
|
||||
for (int i = MaxClients + 1; i < GetMaxEntities(); i++) {
|
||||
if(Entity_ClassNameMatches(i, "_player_manager", true)) {
|
||||
g_icPlayerManager = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(g_icPlayerManager == -1) {
|
||||
SetFailState("Unable to find \"*_player_manager\" entity");
|
||||
}
|
||||
#if debug
|
||||
SDKHook(g_icPlayerManager, SDKHook_ThinkPost, PlayerManager_OnThinkPost);
|
||||
#endif
|
||||
}
|
||||
public void Event_DifficultyChanged(Event event, const char[] name, bool dontBroadcast) {
|
||||
event.GetString("newDifficulty",g_icDifficulty,sizeof(g_icDifficulty));
|
||||
}
|
||||
// METHODS //
|
||||
bool IsPlayerIncapped(int client)
|
||||
public void Event_HealStart(Event event, const char[] name, bool dontBroadcast) {
|
||||
int healer = GetClientOfUserId(event.GetInt("userid"));
|
||||
int healing = GetClientOfUserId(event.GetInt("subject"));
|
||||
g_icHealing[healer] = true;
|
||||
g_icBeingHealed[healing] = true;
|
||||
}
|
||||
public void Event_HealStop(Event event, const char[] name, bool dontBroadcast) {
|
||||
int healer = GetClientOfUserId(event.GetInt("userid"));
|
||||
int healing = GetClientOfUserId(event.GetInt("subject"));
|
||||
g_icHealing[healer] = false;
|
||||
g_icBeingHealed[healing] = false;
|
||||
}
|
||||
#if debug
|
||||
int g_ichuddelay = 0;
|
||||
public PlayerManager_OnThinkPost(int playerManager) {
|
||||
if(g_ichuddelay == 0) {
|
||||
int missionDuration = GetEntProp(playerManager, Prop_Send, "m_missionDuration", 1);
|
||||
int tempoState = GetEntProp(playerManager, Prop_Send, "m_tempoState", 1);
|
||||
PrintHintTextToAll("temp: %d | duration: %d", tempoState, missionDuration);
|
||||
}
|
||||
if (++g_ichuddelay >= 10) g_ichuddelay = 0;
|
||||
}
|
||||
#endif
|
||||
public OnClientPutInServer(client)
|
||||
{
|
||||
if (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1)) return true;
|
||||
return false;
|
||||
}
|
||||
bool IsPlayerNearDead(int client) {
|
||||
if (GetEntProp(client, Prop_Send, "m_bIsOnThirdStrike", 1)) return true;
|
||||
return false;
|
||||
}
|
||||
PrintToChat(client, "Welcome to the Manual Director server! For information or access the panel go to l4d2.jackz.me.");
|
||||
char coupon[9];
|
||||
g_icCouponCode.GetString(coupon, sizeof(coupon));
|
||||
if(strlen(coupon) > 0) {
|
||||
char coins[32] = "free";
|
||||
if (g_icCouponCoins.IntValue > 0) IntToString(g_icCouponCoins.IntValue, coins, sizeof(coins));
|
||||
PrintToChat(client, "Signup with redemption code '%s' for %s initial coins", coupon, coins);
|
||||
}
|
||||
|
||||
}
|
||||
// METHODS //
|
||||
stock float GetPlayerSpeed(int client) {
|
||||
int iVelocity = FindSendPropInfo("CTerrorPlayer", "m_vecVelocity[0]");
|
||||
float velocity[3];
|
||||
GetEntDataVector(client, iVelocity, velocity);
|
||||
return GetVectorLength(velocity, false);
|
||||
/*float x = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]", 0);
|
||||
float y = GetEntPropFloat(client, Prop_Send, "m_vecVelocity", 1);
|
||||
float z = GetEntPropFloat(client, Prop_Send, "m_vecVelocity", 2);
|
||||
|
||||
return SquareRoot(x * x + y * y + z * z);
|
||||
//eturn GetVectorLength(vector, false);*/
|
||||
}
|
||||
stock void GetModelName(int client, char[] buffer, int length) {
|
||||
char modelName[38];
|
||||
GetClientModel(client, modelName, sizeof(modelName));
|
||||
|
@ -131,6 +213,21 @@ stock void GetModelName(int client, char[] buffer, int length) {
|
|||
strcopy(buffer, length, "Ellis");
|
||||
}
|
||||
}
|
||||
stock bool Entity_ClassNameMatches(entity, const char[] className, partialMatch=false)
|
||||
{
|
||||
char entity_className[64];
|
||||
Entity_GetClassName(entity, entity_className, sizeof(entity_className));
|
||||
|
||||
if (partialMatch) {
|
||||
return (StrContains(entity_className, className) != -1);
|
||||
}
|
||||
|
||||
return StrEqual(entity_className, className);
|
||||
}
|
||||
stock Entity_GetClassName(entity, char[] buffer, size)
|
||||
{
|
||||
return GetEntPropString(entity, Prop_Data, "m_iClassname", buffer, size);
|
||||
}
|
||||
|
||||
stock GetClientRealHealth(client)
|
||||
{
|
||||
|
@ -189,3 +286,24 @@ stock GetClientRealHealth(client)
|
|||
//Return the value
|
||||
return RoundToFloor(PermHealth + TempHealth);
|
||||
}
|
||||
/**
|
||||
* Get the classname of an item in a slot
|
||||
*
|
||||
* @param client The client to check inventory from
|
||||
* @param slot The item slot index
|
||||
* @param buffer The char[] buffer to set text to
|
||||
* @param bufferSize The size of the buffer
|
||||
* @return True if item, false if no item
|
||||
*/
|
||||
stock bool GetItemSlotClassName(int client, int slot, char[] buffer, int bufferSize, bool excludeWpnPrefix = false) {
|
||||
int item = GetPlayerWeaponSlot(client, slot);
|
||||
if(item > -1) {
|
||||
GetEdictClassname(item, buffer, bufferSize);
|
||||
if(excludeWpnPrefix) {
|
||||
ReplaceString(buffer, bufferSize, "weapon_", "");
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -8,14 +8,13 @@
|
|||
#define PLUGIN_AUTHOR "jackzmc"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
#define PLUGIN_URL ""
|
||||
#define PI 3.14159265358
|
||||
#define UNITS_SPAWN -120.0
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include "jutils.inc"
|
||||
//#include <sdkhooks>
|
||||
|
||||
#define MODEL_MINIGUN "models/w_models/weapons/w_minigun.mdl"
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
|
@ -36,8 +35,12 @@ public void OnPluginStart()
|
|||
CreateTimer(2.0, CheckTimer, _, TIMER_REPEAT);
|
||||
}
|
||||
|
||||
//possible optimization: Only update player's position every X times, always check for bots
|
||||
public Action CheckTimer(Handle timer) {
|
||||
for(int i = 1; i < MaxClients; i++) {
|
||||
//Don't do any processing if no one is connected.
|
||||
if(GetClientCount(true) == 0) return Plugin_Continue;
|
||||
for(int i = 1; i < MaxClients; i++) {
|
||||
//possibly can optimize? check array if int is in it.
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) == 2) {
|
||||
bool usingMinigun = GetEntProp(i, Prop_Send, "m_usingMountedGun", 1) == 1;
|
||||
bool usingMountedWeapon = GetEntProp(i, Prop_Send, "m_usingMountedWeapon", 1) == 1;
|
||||
|
@ -68,49 +71,5 @@ public Action CheckTimer(Handle timer) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stock void GetHorizontalPositionFromOrigin(const float pos[3], const float ang[3], float units, float finalPosition[3]) {
|
||||
float theta = DegToRad(ang[1]);
|
||||
finalPosition[0] = units * Cosine(theta) + pos[0];
|
||||
finalPosition[1] = units * Sine(theta) + pos[1];
|
||||
finalPosition[2] = pos[2];
|
||||
}
|
||||
stock void GetHorizontalPositionFromClient(int client, float units, float finalPosition[3]) {
|
||||
float pos[3], ang[3];
|
||||
GetClientEyeAngles(client, ang);
|
||||
GetClientAbsOrigin(client, pos);
|
||||
|
||||
float theta = DegToRad(ang[1]);
|
||||
pos[0] += -150 * Cosine(theta);
|
||||
pos[1] += -150 * Sine(theta);
|
||||
finalPosition = pos;
|
||||
}
|
||||
|
||||
stock void L4D2_RunScript(const char[] sCode, any ...) {
|
||||
static int iScriptLogic = INVALID_ENT_REFERENCE;
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
|
||||
iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE|| !IsValidEntity(iScriptLogic))
|
||||
SetFailState("Could not create 'logic_script'");
|
||||
|
||||
DispatchSpawn(iScriptLogic);
|
||||
}
|
||||
|
||||
static char sBuffer[512];
|
||||
VFormat(sBuffer, sizeof(sBuffer), sCode, 2);
|
||||
|
||||
SetVariantString(sBuffer);
|
||||
AcceptEntityInput(iScriptLogic, "RunScriptCode");
|
||||
}
|
||||
stock void ShowDelayedHintToAll(const char[] format, any ...) {
|
||||
char buffer[254];
|
||||
VFormat(buffer, sizeof(buffer), format, 2);
|
||||
static int hintInt = 0;
|
||||
if(hintInt >= 7) {
|
||||
PrintHintTextToAll("%s",buffer);
|
||||
hintInt = 0;
|
||||
}
|
||||
hintInt++;
|
||||
return Plugin_Continue;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue