mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 19:23:20 +00:00
Improvements
This commit is contained in:
parent
a52f053082
commit
7d584e8379
4 changed files with 40 additions and 54 deletions
Binary file not shown.
Binary file not shown.
|
@ -116,7 +116,7 @@ public Action Cmd_ReleaseFreeze(client, args)
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_eReleaseFreeze[client] = StrEqual(sArg, "1") ? true : false;
|
g_eReleaseFreeze[client] = StrEqual(sArg, "1");
|
||||||
|
|
||||||
PrintToChat(client, "\x04[SM]\x01 Entities will now be \x05%s\x01 on Release!", g_eReleaseFreeze[client] == true ? "Frozen" : "Unfrozen");
|
PrintToChat(client, "\x04[SM]\x01 Entities will now be \x05%s\x01 on Release!", g_eReleaseFreeze[client] == true ? "Frozen" : "Unfrozen");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
@ -154,9 +154,7 @@ public Action Cmd_Grab(client, args) {
|
||||||
|
|
||||||
// Get the point at which the ray first hit the entity
|
// Get the point at which the ray first hit the entity
|
||||||
float initialRay[3];
|
float initialRay[3];
|
||||||
initialRay[0] = GetInitialRayPosition(client, 'x');
|
GetInitialRayPosition(client, initialRay);
|
||||||
initialRay[1] = GetInitialRayPosition(client, 'y');
|
|
||||||
initialRay[2] = GetInitialRayPosition(client, 'z');
|
|
||||||
|
|
||||||
// Calculate the offset between intitial ray hit and the entities origin
|
// Calculate the offset between intitial ray hit and the entities origin
|
||||||
g_fGrabOffset[client][0] = entOrigin[0] - initialRay[0];
|
g_fGrabOffset[client][0] = entOrigin[0] - initialRay[0];
|
||||||
|
@ -370,9 +368,10 @@ public Action Timer_UpdateGrab(Handle timer, DataPack pack) {
|
||||||
entNewPos[1] += g_fGrabOffset[client][1];
|
entNewPos[1] += g_fGrabOffset[client][1];
|
||||||
entNewPos[2] += g_fGrabOffset[client][2];
|
entNewPos[2] += g_fGrabOffset[client][2];
|
||||||
|
|
||||||
|
|
||||||
float mins[3];
|
float mins[3];
|
||||||
GetEntPropVector(g_pGrabbedEnt[client], Prop_Data, "m_vecMins", mins);
|
GetEntPropVector(g_pGrabbedEnt[client], Prop_Data, "m_vecMins", mins);
|
||||||
entNewPos[2] += mins[2];
|
entNewPos[2] -= mins[2];
|
||||||
|
|
||||||
TeleportEntity(g_pGrabbedEnt[client], entNewPos, NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(g_pGrabbedEnt[client], entNewPos, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
|
||||||
|
@ -427,7 +426,7 @@ int GetLookingEntity(int client, TraceEntityFilter filter) {
|
||||||
static float pos[3], ang[3];
|
static float pos[3], ang[3];
|
||||||
GetClientEyePosition(client, pos);
|
GetClientEyePosition(client, pos);
|
||||||
GetClientEyeAngles(client, ang);
|
GetClientEyeAngles(client, ang);
|
||||||
TR_TraceRayFilter(pos, ang, MASK_ALL, RayType_Infinite, filter, client);
|
TR_TraceRayFilter(pos, ang, MASK_OPAQUE, RayType_Infinite, filter, client);
|
||||||
if(TR_DidHit()) {
|
if(TR_DidHit()) {
|
||||||
return TR_GetEntityIndex();
|
return TR_GetEntityIndex();
|
||||||
}
|
}
|
||||||
|
@ -455,23 +454,19 @@ stock bool GetEntNewPosition(int client, float endPos[3])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/////
|
/////
|
||||||
stock float GetInitialRayPosition(int client, char axis)
|
stock bool GetInitialRayPosition(int client, float endPos[3])
|
||||||
{
|
{
|
||||||
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
|
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
|
||||||
float endPos[3], clientEye[3], clientAngle[3];
|
float clientEye[3], clientAngle[3];
|
||||||
GetClientEyePosition(client, clientEye);
|
GetClientEyePosition(client, clientEye);
|
||||||
GetClientEyeAngles(client, clientAngle);
|
GetClientEyeAngles(client, clientAngle);
|
||||||
|
|
||||||
TR_TraceRayFilter(clientEye, clientAngle, MASK_SOLID, RayType_Infinite, TraceRayFilterActivator, client);
|
TR_TraceRayFilter(clientEye, clientAngle, MASK_SOLID, RayType_Infinite, TraceRayFilterActivator, client);
|
||||||
if (TR_DidHit(INVALID_HANDLE))
|
if (TR_DidHit(INVALID_HANDLE))
|
||||||
TR_GetEndPosition(endPos);
|
TR_GetEndPosition(endPos);
|
||||||
|
return true;
|
||||||
if (axis == 'x') return endPos[0];
|
|
||||||
else if (axis == 'y') return endPos[1];
|
|
||||||
else if (axis == 'z') return endPos[2];
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
/////
|
/////
|
||||||
stock void SetWeaponDelay(int client, float delay)
|
stock void SetWeaponDelay(int client, float delay)
|
||||||
|
|
|
@ -101,7 +101,6 @@ enum wallMode {
|
||||||
INACTIVE = 0,
|
INACTIVE = 0,
|
||||||
MOVE_ORIGIN,
|
MOVE_ORIGIN,
|
||||||
SCALE,
|
SCALE,
|
||||||
ROTATE,
|
|
||||||
FREELOOK
|
FREELOOK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,27 +170,27 @@ enum struct WallBuilderData {
|
||||||
case MOVE_ORIGIN: {
|
case MOVE_ORIGIN: {
|
||||||
if(this.canScale) {
|
if(this.canScale) {
|
||||||
this.mode = SCALE;
|
this.mode = SCALE;
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01 (Press \x04RELOAD\x01 to change mode)");
|
||||||
} else {
|
} else {
|
||||||
this.mode = FREELOOK;
|
this.mode = FREELOOK;
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Freelook\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Freelook\x01 (Press \x04RELOAD\x01 to change mode)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SCALE: {
|
case SCALE: {
|
||||||
this.mode = FREELOOK;
|
this.mode = FREELOOK;
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Freelook\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Freelook\x01 (Press \x04RELOAD\x01 to change mode)");
|
||||||
}
|
}
|
||||||
case FREELOOK: {
|
case FREELOOK: {
|
||||||
this.mode = MOVE_ORIGIN;
|
this.mode = MOVE_ORIGIN;
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Move & Rotate\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Move & Rotate\x01 (Press \x04RELOAD\x01 to change mode)");
|
||||||
// PrintToChat(client, "Controls: \x05RELOAD\x01 to change mode");
|
// PrintToChat(client, "Hold \x04USE (E)\x01 to rotate, \x04WALK (SHIFT)\x01 to change speed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmdThrottle[client] = tick;
|
cmdThrottle[client] = tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CycleAxis(int client, float tick) {
|
void CycleAxis(int client, float tick) {
|
||||||
if(tick - cmdThrottle[client] <= 0.25) return;
|
if(tick - cmdThrottle[client] <= 0.20) return;
|
||||||
if(this.axis == 0) {
|
if(this.axis == 0) {
|
||||||
this.axis = 1;
|
this.axis = 1;
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Rotate Axis: \x05HEADING (Y)\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Rotate Axis: \x05HEADING (Y)\x01");
|
||||||
|
@ -203,7 +202,7 @@ enum struct WallBuilderData {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CycleSnapAngle(int client, float tick) {
|
void CycleSnapAngle(int client, float tick) {
|
||||||
if(tick - cmdThrottle[client] <= 0.25) return;
|
if(tick - cmdThrottle[client] <= 0.20) return;
|
||||||
switch(this.snapAngle) {
|
switch(this.snapAngle) {
|
||||||
case 1: this.snapAngle = 15;
|
case 1: this.snapAngle = 15;
|
||||||
case 15: this.snapAngle = 30;
|
case 15: this.snapAngle = 30;
|
||||||
|
@ -340,11 +339,9 @@ public void OnPluginStart() {
|
||||||
HookEvent("bot_player_replace", Event_PlayerToIdle);
|
HookEvent("bot_player_replace", Event_PlayerToIdle);
|
||||||
|
|
||||||
RegConsoleCmd("sm_hat", Command_DoAHat, "Hats");
|
RegConsoleCmd("sm_hat", Command_DoAHat, "Hats");
|
||||||
RegAdminCmd("sm_wall", Command_MakeWall, ADMFLAG_CHEATS);
|
RegAdminCmd("sm_mkwall", Command_MakeWall, ADMFLAG_CHEATS);
|
||||||
RegAdminCmd("sm_walls", Command_ManageWalls, ADMFLAG_CHEATS);
|
RegAdminCmd("sm_walls", Command_ManageWalls, ADMFLAG_CHEATS);
|
||||||
|
RegAdminCmd("sm_wall", Command_ManageWalls, ADMFLAG_CHEATS);
|
||||||
AddCommandListener(Command_ScrollWheelUp, "invnext");
|
|
||||||
AddCommandListener(Command_ScrollWheelDown, "invprev");
|
|
||||||
|
|
||||||
cvar_sm_hats_blacklist_enabled = CreateConVar("sm_hats_blacklist_enabled", "1", "Is the prop blacklist enabled", FCVAR_NONE, true, 0.0, true, 1.0);
|
cvar_sm_hats_blacklist_enabled = CreateConVar("sm_hats_blacklist_enabled", "1", "Is the prop blacklist enabled", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
cvar_sm_hats_enabled = CreateConVar("sm_hats_enabled", "1.0", "Enable hats.\n0=OFF, 1=Admins Only, 2=Any", FCVAR_NONE, true, 0.0, true, 2.0);
|
cvar_sm_hats_enabled = CreateConVar("sm_hats_enabled", "1.0", "Enable hats.\n0=OFF, 1=Admins Only, 2=Any", FCVAR_NONE, true, 0.0, true, 2.0);
|
||||||
|
@ -555,7 +552,7 @@ public Action Command_DoAHat(int client, int args) {
|
||||||
WallBuilder[client].Reset();
|
WallBuilder[client].Reset();
|
||||||
WallBuilder[client].entity = EntIndexToEntRef(entity);
|
WallBuilder[client].entity = EntIndexToEntRef(entity);
|
||||||
WallBuilder[client].canScale = false;
|
WallBuilder[client].canScale = false;
|
||||||
WallBuilder[client].SetMode(SCALE);
|
WallBuilder[client].SetMode(MOVE_ORIGIN);
|
||||||
PrintToChat(client, "\x04[Walls] \x01Beta Prop Mover active for \x04%d", entity);
|
PrintToChat(client, "\x04[Walls] \x01Beta Prop Mover active for \x04%d", entity);
|
||||||
} else {
|
} else {
|
||||||
PrintToChat(client, "[Hats] Restored hat to its original position.");
|
PrintToChat(client, "[Hats] Restored hat to its original position.");
|
||||||
|
@ -699,7 +696,7 @@ public Action Command_MakeWall(int client, int args) {
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Wall Creation: \x04Cancelled\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Wall Creation: \x04Cancelled\x01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ReplyToCommand(client, "\x04[Walls]\x01 Unknown option, try \x05/wall build\x01 to finish or \x04/wall cancel\x01 to cancel");
|
ReplyToCommand(client, "\x04[Walls]\x01 Unknown option, try \x05/mkwall build\x01 to finish or \x04/mkwall cancel\x01 to cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -729,7 +726,7 @@ public Action Command_MakeWall(int client, int args) {
|
||||||
}
|
}
|
||||||
WallBuilder[client].SetMode(SCALE);
|
WallBuilder[client].SetMode(SCALE);
|
||||||
GetCursorLimited(client, 100.0, WallBuilder[client].origin, Filter_IgnorePlayer);
|
GetCursorLimited(client, 100.0, WallBuilder[client].origin, Filter_IgnorePlayer);
|
||||||
PrintToChat(client, "\x04[Walls]\x01 New Wall Started. End with \x05/wall build\x01 or \x04/wall cancel\x01");
|
PrintToChat(client, "\x04[Walls]\x01 New Wall Started. End with \x05/mkwall build\x01 or \x04/mkwall cancel\x01");
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
||||||
}
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
@ -761,7 +758,7 @@ public Action Command_ManageWalls(int client, int args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(StrEqual(arg1, "create")) {
|
} else if(StrEqual(arg1, "create")) {
|
||||||
ReplyToCommand(client, "\x04[Walls]\x01 Syntax: /wall [size x] [size y] [size z]");
|
ReplyToCommand(client, "\x04[Walls]\x01 Syntax: /mkwall [size x] [size y] [size z]");
|
||||||
} else if(StrEqual(arg1, "toggle")) {
|
} else if(StrEqual(arg1, "toggle")) {
|
||||||
if(StrEqual(arg2, "all")) {
|
if(StrEqual(arg2, "all")) {
|
||||||
int walls = createdWalls.Length;
|
int walls = createdWalls.Length;
|
||||||
|
@ -811,16 +808,28 @@ public Action Command_ManageWalls(int client, int args) {
|
||||||
if(id > -1) {
|
if(id > -1) {
|
||||||
int entity = GetWallEntity(id);
|
int entity = GetWallEntity(id);
|
||||||
WallBuilder[client].Import(entity);
|
WallBuilder[client].Import(entity);
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Editing wall \x05%d\x01. End with \x05/wall build\x01 or \x04/wall cancel\x01", id);
|
PrintToChat(client, "\x04[Walls]\x01 Editing wall \x05%d\x01. End with \x05/mkwall build\x01 or \x04/mkwall cancel\x01", id);
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
||||||
}
|
}
|
||||||
|
} else if(StrEqual(arg1, "edite")) {
|
||||||
|
int index = StringToInt(arg2);
|
||||||
|
if(index > 0 && IsValidEntity(index)) {
|
||||||
|
WallBuilder[client].Reset();
|
||||||
|
WallBuilder[client].entity = EntIndexToEntRef(index);
|
||||||
|
WallBuilder[client].canScale = false;
|
||||||
|
WallBuilder[client].SetMode(MOVE_ORIGIN);
|
||||||
|
PrintToChat(client, "\x04[Walls]\x01 Editing wall \x05%d\x01. End with \x05/mkwall build\x01 or \x04/mkwall cancel\x01", index);
|
||||||
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Move & Rotate\x01");
|
||||||
|
} else {
|
||||||
|
ReplyToCommand(client, "\x04[Walls]\x01 Invalid or non existent entity");
|
||||||
|
}
|
||||||
} else if(StrEqual(arg1, "copy")) {
|
} else if(StrEqual(arg1, "copy")) {
|
||||||
int id = GetWallId(client, arg2);
|
int id = GetWallId(client, arg2);
|
||||||
if(id > -1) {
|
if(id > -1) {
|
||||||
int entity = GetWallEntity(id);
|
int entity = GetWallEntity(id);
|
||||||
WallBuilder[client].Import(entity, true);
|
WallBuilder[client].Import(entity, true);
|
||||||
GetCursorLimited(client, 100.0, WallBuilder[client].origin, Filter_IgnorePlayer);
|
GetCursorLimited(client, 100.0, WallBuilder[client].origin, Filter_IgnorePlayer);
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Editing copy of wall \x05%d\x01. End with \x05/wall build\x01 or \x04/wall cancel\x01", id);
|
PrintToChat(client, "\x04[Walls]\x01 Editing copy of wall \x05%d\x01. End with \x05/mkwall build\x01 or \x04/mkwall cancel\x01", id);
|
||||||
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
PrintToChat(client, "\x04[Walls]\x01 Mode: \x05Scale\x01");
|
||||||
}
|
}
|
||||||
} else if(StrEqual(arg1, "list")) {
|
} else if(StrEqual(arg1, "list")) {
|
||||||
|
@ -832,21 +841,6 @@ public Action Command_ManageWalls(int client, int args) {
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_ScrollWheelUp(int client, const char[] command, int args) {
|
|
||||||
if(WallBuilder[client].IsActive()) {
|
|
||||||
WallBuilder[client].moveDistance++;
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
|
||||||
public Action Command_ScrollWheelDown(int client, const char[] command, int args) {
|
|
||||||
if(WallBuilder[client].IsActive()) {
|
|
||||||
WallBuilder[client].moveDistance--;
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetWallId(int client, const char[] arg) {
|
int GetWallId(int client, const char[] arg) {
|
||||||
int id;
|
int id;
|
||||||
if(StringToIntEx(arg, id) > 0 && id > 0 && id <= createdWalls.Length) {
|
if(StringToIntEx(arg, id) > 0 && id > 0 && id <= createdWalls.Length) {
|
||||||
|
@ -1310,8 +1304,6 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
} else if(tick - cmdThrottle[client] > 0.25) {
|
} else if(tick - cmdThrottle[client] > 0.25) {
|
||||||
if(buttons & IN_ATTACK) {
|
if(buttons & IN_ATTACK) {
|
||||||
ClientCommand(client, "sm_hat %s", 'y');
|
ClientCommand(client, "sm_hat %s", 'y');
|
||||||
} else if(buttons & IN_SPEED) {
|
|
||||||
ClientCommand(client, "sm_hat %s", 'n');
|
|
||||||
} else if(buttons & IN_DUCK) {
|
} else if(buttons & IN_DUCK) {
|
||||||
ClientCommand(client, "sm_hat %s", 'p');
|
ClientCommand(client, "sm_hat %s", 'p');
|
||||||
}
|
}
|
||||||
|
@ -1331,10 +1323,9 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
switch(WallBuilder[client].mode) {
|
switch(WallBuilder[client].mode) {
|
||||||
case MOVE_ORIGIN: {
|
case MOVE_ORIGIN: {
|
||||||
SetWeaponDelay(client, 0.5);
|
SetWeaponDelay(client, 0.5);
|
||||||
switch(buttons) {
|
// switch(buttons) {
|
||||||
case IN_SCORE: WallBuilder[client].CycleMoveMode(client, tick);
|
// case IN_: WallBuilder[client].CycleSpeed(client, tick);
|
||||||
case IN_ZOOM: WallBuilder[client].CycleSpeed(client, tick);
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if(WallBuilder[client].movetype == 0) {
|
if(WallBuilder[client].movetype == 0) {
|
||||||
bool isRotate;
|
bool isRotate;
|
||||||
|
@ -1361,7 +1352,7 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
switch(buttons) {
|
switch(buttons) {
|
||||||
case IN_ATTACK: WallBuilder[client].moveDistance++;
|
case IN_ATTACK: WallBuilder[client].moveDistance++;
|
||||||
case IN_ATTACK2: WallBuilder[client].moveDistance--;
|
case IN_ATTACK2: WallBuilder[client].moveDistance--;
|
||||||
case IN_WALK: WallBuilder[client].CycleSnapAngle(client, tick);
|
case IN_WALK: WallBuilder[client].CycleMoveMode(client, tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isRotate && flags & FL_FROZEN) {
|
if(!isRotate && flags & FL_FROZEN) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue