#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#define PLUGIN "CT Score Penalty"
#define VERSION "3.4"
#define AUTHOR "TuttiFrutti"
// Max distance for penalty
#define MAX_DISTANCE 1000.0
// d2 locs - cat, ctspawn, tunnel, pit, tpsawn, bsite A and B
new const Float:catwalkMin[3] = {-1600.0, -50.0, -100.0};
new const Float:catwalkMax[3] = {500.0, -600.0, 100.0};
new const Float:ctSpawnMin[3] = {-2000.0, -200.0, -100.0};
new const Float:ctSpawnMax[3] = {-1500.0, 1500.0, 50.0};
new const Float:pitMin[3] = {-2200.0, 500.0, -100.0};
new const Float:pitMax[3] = {-1700.0, 1000.0, 200.0};
new const Float:tunnelMin[3] = {700.0, 200.0, -100.0};
new const Float:tunnelMax[3] = {1200.0, 500.0, 300.0};
new const Float:tSpawnMin[3] = {1400.0, 300.0, -100.0};
new const Float:tSpawnMax[3] = {1800.0, 800.0, 200.0};
new const Float:bombsiteA[3] = {-1800.0, 1250.0, 0.0};
new const Float:bombsiteB[3] = {950.0, 290.0, 0.0};
// track c4 explosion
new bool:g_bombExploded = false;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("HLTV", "on_bomb_exploded", "a", "1=3", "2=1"); // boom!
}
public on_bomb_exploded() {
g_bombExploded = true;
set_task(1.0, "checkCtPenaltyAfterExplosion", _, _, _, "b"); // check after 1 sec
}
public checkCtPenaltyAfterExplosion() {
// Only check if bomb exploded
if (!g_bombExploded) {
return;
}
// Check all CTs after explosion
for (new id = 1; id <= 32; id++) {
if (!is_user_connected(id) || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT) {
continue; // skip non-CTs
}
// Check if player is defusing
if (cs_get_user_defuse(id)) {
new defusePos[3];
pev(id, pev_origin, defusePos);
// Check if other CTs nearby and alive
bool isOtherCTNearby = false;
for (new otherId = 1; otherId <= 32; otherId++) {
if (otherId == id || !is_user_connected(otherId) || !is_user_alive(otherId) || cs_get_user_team(otherId) != CS_TEAM_CT) {
continue;
}
new Float:otherPos[3];
pev(otherId, pev_origin, otherPos);
// If any CT is close enough, no penalty
if (get_distance_f(defusePos, otherPos) <= MAX_DISTANCE) {
isOtherCTNearby = true;
break;
}
}
// No nearby CTs? Then check position for penalty
if (!isOtherCTNearby) {
new Float:pos[3];
pev(id, pev_origin, pos);
// If out of bounds or in the wrong areas
if (get_distance_f(pos, bombsiteA) > MAX_DISTANCE || isInArea(pos, catwalkMin, catwalkMax) ||
isInArea(pos, ctSpawnMin, ctSpawnMax) || isInArea(pos, pitMin, pitMax)) {
adjustScore(id, -1); // Penalize
}
// Same for bombsite B
if (get_distance_f(pos, bombsiteB) > MAX_DISTANCE || isInArea(pos, tunnelMin, tunnelMax) ||
isInArea(pos, tSpawnMin, tSpawnMax)) {
adjustScore(id, -1); // Penalize
}
}
}
}
}
// Check if player is in specific area
bool:isInArea(const Float:pos[3], const Float:min[3], const Float:max[3]) {
return (pos[0] >= min[0] && pos[0] <= max[0] &&
pos[1] >= min[1] && pos[1] <= max[1] &&
pos[2] >= min[2] && pos[2] <= max[2]);
}
// Give penalty score for not defusing
adjustScore(id, points) {
new score = get_user_frags(id) + points;
set_user_frags(id, score);
// Display to all about the penalty
if (points < 0) { // penalty
client_print(0, print_chat, "+1 death for '%s' for not defusing", get_user_name(id));
}
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎