mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-08 05:43:20 +00:00
Improve documentation, minor fixes
This commit is contained in:
parent
b799c1c632
commit
4f15ea5289
1 changed files with 33 additions and 19 deletions
|
@ -61,8 +61,8 @@ public void OnPluginStart() {
|
||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
HookEvent("player_entered_checkpoint", OnEnterSaferoom);
|
HookEvent("player_entered_checkpoint", OnEnterSaferoom);
|
||||||
HookEvent("player_left_checkpoint", OnLeaveSaferoom);
|
HookEvent("player_left_checkpoint", OnLeaveSaferoom);
|
||||||
HookEvent("player_bot_replace", Event_PlayerOutOfIdle );
|
HookEvent("player_bot_replace", Event_PlayerToIdle);
|
||||||
HookEvent("bot_player_replace", Event_PlayerToIdle);
|
HookEvent("bot_player_replace", Event_PlayerOutOfIdle);
|
||||||
|
|
||||||
RegConsoleCmd("sm_hat", Command_DoAHat, "Hats");
|
RegConsoleCmd("sm_hat", Command_DoAHat, "Hats");
|
||||||
RegAdminCmd("sm_mkwall", Command_MakeWall, ADMFLAG_CHEATS);
|
RegAdminCmd("sm_mkwall", Command_MakeWall, ADMFLAG_CHEATS);
|
||||||
|
@ -468,28 +468,45 @@ void ChooseRandomPosition(float pos[3], int ignoreClient = 0) {
|
||||||
|
|
||||||
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
||||||
float tick = GetGameTime();
|
float tick = GetGameTime();
|
||||||
|
//////////////////////////////
|
||||||
|
// OnPlayerRunCmd :: HATS
|
||||||
|
/////////////////////////////
|
||||||
if(IsHatsEnabled(client)) {
|
if(IsHatsEnabled(client)) {
|
||||||
int entity = GetHat(client);
|
int entity = GetHat(client);
|
||||||
int visibleEntity = EntRefToEntIndex(hatData[client].visibleEntity);
|
int visibleEntity = EntRefToEntIndex(hatData[client].visibleEntity);
|
||||||
///#HAT PROCESS
|
|
||||||
if(entity > 0) {
|
if(entity > 0) {
|
||||||
// try to tp hat to itys own pos
|
// Crash prevention: Prevent hat from touching ladder as that can cause server crashes
|
||||||
if(!onLadder[client] && GetEntityMoveType(client) == MOVETYPE_LADDER) {
|
if(!onLadder[client] && GetEntityMoveType(client) == MOVETYPE_LADDER) {
|
||||||
onLadder[client] = true;
|
onLadder[client] = true;
|
||||||
ClearParent(entity);
|
ClearParent(entity);
|
||||||
// Hide hat temporarily in void:
|
|
||||||
|
// If hat is not a player, we teleport them to the void (0, 0, 0)
|
||||||
|
// Otherwise, we just simply dismount the player while hatter is on ladder
|
||||||
if(entity >= MaxClients)
|
if(entity >= MaxClients)
|
||||||
|
|
||||||
TeleportEntity(entity, EMPTY_ANG, NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(entity, EMPTY_ANG, NULL_VECTOR, NULL_VECTOR);
|
||||||
if(visibleEntity > 0) {
|
if(visibleEntity > 0) {
|
||||||
hatData[client].visibleEntity = INVALID_ENT_REFERENCE;
|
hatData[client].visibleEntity = INVALID_ENT_REFERENCE;
|
||||||
RemoveEntity(visibleEntity);
|
RemoveEntity(visibleEntity);
|
||||||
}
|
}
|
||||||
} else if(onLadder[client] && GetEntityMoveType(client) != MOVETYPE_LADDER) {
|
}
|
||||||
|
// Player is no longer on ladder, restore hat:
|
||||||
|
else if(onLadder[client] && GetEntityMoveType(client) != MOVETYPE_LADDER) {
|
||||||
onLadder[client] = false;
|
onLadder[client] = false;
|
||||||
EquipHat(client, entity);
|
EquipHat(client, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do the same crash protection for the hat itself, just to be safe:
|
||||||
|
if(entity <= MaxClients) {
|
||||||
|
if(!onLadder[entity] && GetEntityMoveType(entity) == MOVETYPE_LADDER) {
|
||||||
|
onLadder[entity] = true;
|
||||||
|
ClearParent(entity);
|
||||||
|
} else if(onLadder[entity] && GetEntityMoveType(entity) != MOVETYPE_LADDER) {
|
||||||
|
onLadder[entity] = false;
|
||||||
|
EquipHat(client, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rainbow hat processing
|
||||||
if(HasFlag(client, HAT_RAINBOW)) {
|
if(HasFlag(client, HAT_RAINBOW)) {
|
||||||
// Decrement and flip, possibly when rainbowticks
|
// Decrement and flip, possibly when rainbowticks
|
||||||
if(hatData[client].rainbowReverse) {
|
if(hatData[client].rainbowReverse) {
|
||||||
|
@ -513,24 +530,18 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
EquipHat(client, entity);
|
EquipHat(client, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity <= MaxClients) {
|
// If bot is commandable and reversed (player reverse-hat common/survivor), change position:
|
||||||
if(!onLadder[entity] && GetEntityMoveType(entity) == MOVETYPE_LADDER) {
|
|
||||||
onLadder[entity] = true;
|
|
||||||
ClearParent(entity);
|
|
||||||
} else if(onLadder[entity] && GetEntityMoveType(entity) != MOVETYPE_LADDER) {
|
|
||||||
onLadder[entity] = false;
|
|
||||||
EquipHat(client, entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(HasFlag(client, HAT_COMMANDABLE | HAT_REVERSED) && tickcount % 200 == 0) {
|
if(HasFlag(client, HAT_COMMANDABLE | HAT_REVERSED) && tickcount % 200 == 0) {
|
||||||
float pos[3];
|
float pos[3];
|
||||||
ChooseRandomPosition(pos, client);
|
ChooseRandomPosition(pos, client);
|
||||||
L4D2_CommandABot(entity, client, BOT_CMD_MOVE, pos);
|
L4D2_CommandABot(entity, client, BOT_CMD_MOVE, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Detect E + R to offset hat or place down
|
||||||
if(buttons & IN_USE && buttons & IN_RELOAD) {
|
if(buttons & IN_USE && buttons & IN_RELOAD) {
|
||||||
if(entity > 0) {
|
if(entity > 0) {
|
||||||
if(buttons & IN_ZOOM) {
|
if(buttons & IN_ZOOM) {
|
||||||
|
// Offset controls:
|
||||||
if(buttons & IN_JUMP) hatData[client].offset[2] += 1.0;
|
if(buttons & IN_JUMP) hatData[client].offset[2] += 1.0;
|
||||||
if(buttons & IN_DUCK) hatData[client].offset[2] -= 1.0;
|
if(buttons & IN_DUCK) hatData[client].offset[2] -= 1.0;
|
||||||
if(buttons & IN_FORWARD) hatData[client].offset[0] += 1.0;
|
if(buttons & IN_FORWARD) hatData[client].offset[0] += 1.0;
|
||||||
|
@ -540,7 +551,7 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
TeleportEntity(entity, hatData[client].offset, angles, vel);
|
TeleportEntity(entity, hatData[client].offset, angles, vel);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
} else if(tick - cmdThrottle[client] > 0.25) {
|
} else if(tick - cmdThrottle[client] > 0.25) {
|
||||||
if(buttons & IN_ATTACK) {
|
if(buttons & IN_ATTACK) { // doesn't work reliably for some reason
|
||||||
ClientCommand(client, "sm_hat y");
|
ClientCommand(client, "sm_hat y");
|
||||||
} else if(buttons & IN_DUCK) {
|
} else if(buttons & IN_DUCK) {
|
||||||
ClientCommand(client, "sm_hat p");
|
ClientCommand(client, "sm_hat p");
|
||||||
|
@ -556,7 +567,9 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///#WALL BUILDER PROCESS
|
//////////////////////////////
|
||||||
|
// OnPlayerRunCmd :: ENTITY EDITOR
|
||||||
|
/////////////////////////////
|
||||||
if(WallBuilder[client].IsActive() && WallBuilder[client].CheckEntity(client)) {
|
if(WallBuilder[client].IsActive() && WallBuilder[client].CheckEntity(client)) {
|
||||||
if(buttons & IN_USE && buttons & IN_RELOAD) {
|
if(buttons & IN_USE && buttons & IN_RELOAD) {
|
||||||
ClientCommand(client, "sm_wall done");
|
ClientCommand(client, "sm_wall done");
|
||||||
|
@ -576,6 +589,7 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
if(buttons & IN_ATTACK) WallBuilder[client].CycleAxis(client, tick);
|
if(buttons & IN_ATTACK) WallBuilder[client].CycleAxis(client, tick);
|
||||||
else if(buttons & IN_ATTACK2) WallBuilder[client].CycleSnapAngle(client, tick);
|
else if(buttons & IN_ATTACK2) WallBuilder[client].CycleSnapAngle(client, tick);
|
||||||
|
|
||||||
|
// Rotation control:
|
||||||
if(tick - cmdThrottle[client] > 0.20) {
|
if(tick - cmdThrottle[client] > 0.20) {
|
||||||
if(WallBuilder[client].axis == 0) {
|
if(WallBuilder[client].axis == 0) {
|
||||||
if(mouse[1] > 10) WallBuilder[client].angles[0] += WallBuilder[client].snapAngle;
|
if(mouse[1] > 10) WallBuilder[client].angles[0] += WallBuilder[client].snapAngle;
|
||||||
|
@ -861,4 +875,4 @@ stock bool GetCursorLimited2(int client, float distance, float endPos[3], TraceE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue