PHP- Kodu:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#define MAX_PLAYERS 32
#define THROWING
#if !defined THROWING
#include <xs>
#endif
enum _:Room {
Room_G,
Room_M
};
new const gRoomNames[Room][] = {
"GU",
"M"
};
new const gRoomCvarNames[Room][] = {
"gu",
"ma"
};
enum _:Setting {
Setting_AbsMins,
Setting_AbsMaxs,
Setting_Throw_Origin,
Setting_Throw_Angles
};
new const Float:gRoomSettings[Room][Setting][3] = {
{
// absmins
{ -713.0, -990.0, -157.0},
{ 2375.0, 193.0, -2361.0},
}
};
new Float:gEnterRoomTime[MAX_PLAYERS + 1][Room];
new gCvarNoKill[Room];
new gCvarThrowTime[Room];
#if !defined THROWING_IS_TELEPORTING
new gCvarThrowSpeed[Room];
#endif
public plugin_init() {
register_plugin("No Killing Zones", "0.0.5", "Exolent");
RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage");
RegisterHam(Ham_TraceAttack, "player", "FwdPlayerTraceAttack");
new cvarName[64];
for(new room = 0; room < Room; room++) {
formatex(cvarName, charsmax(cvarName), "nkz_nokill_%s", gRoomCvarNames[room]);
gCvarNoKill[room] = register_cvar(cvarName, "1");
formatex(cvarName, charsmax(cvarName), "nkz_throw_%s_time", gRoomCvarNames[room]);
gCvarThrowTime[room] = register_cvar(cvarName, "10");
#if !defined THROWING_IS_TELEPORTING
formatex(cvarName, charsmax(cvarName), "nkz_throw_%s_speed", gRoomCvarNames[room]);
gCvarThrowSpeed[room] = register_cvar(cvarName, "1000");
#endif
}
}
public FwdPlayerDamage(victim, inflictor, attacker, Float:damage, damageBits) {
// if player is hit by a grenade?
if(inflictor != attacker) {
// check if player is in a room
for(new room = 0; room < Room; room++) {
// if player has entered the room
if(gEnterRoomTime[victim][room] > 0.0) {
// block damage
return HAM_SUPERCEDE;
}
}
}
return HAM_IGNORED;
}
public FwdPlayerTraceAttack(victim, attacker, Float:damage, Float:direction[3], trace, damageBits) {
// check if player or attacker are in a room
for(new room = 0; room < Room; room++) {
// if player or attacker have entered the room
if(gEnterRoomTime[victim][room] > 0.0 || gEnterRoomTime[attacker][room] > 0.0) {
// block damage
return HAM_SUPERCEDE;
}
}
return HAM_IGNORED;
}
public client_PreThink(id) {
static lastAlive[MAX_PLAYERS + 1];
static Float:lastMessage[MAX_PLAYERS + 1];
if(is_user_alive(id)) {
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
new Float:gametime = get_gametime();
new Float:throwtime;
new length[64];
#if !defined THROWING_IS_TELEPORTING
new Float:velocity[3];
#endif
for(new room = 0; room < Room; room++) {
if((gRoomSettings[room][Setting_AbsMins][0] <= origin[0] <= gRoomSettings[room][Setting_AbsMaxs][0])
&& (gRoomSettings[room][Setting_AbsMins][1] <= origin[1] <= gRoomSettings[room][Setting_AbsMaxs][1])
&& (gRoomSettings[room][Setting_AbsMins][2] <= origin[2] <= gRoomSettings[room][Setting_AbsMaxs][2])) {
if(gEnterRoomTime[id][room] == 0.0) {
gEnterRoomTime[id][room] = gametime;
}
throwtime = get_pcvar_float(gCvarThrowTime[room]);
if(throwtime > 0.0) {
// if they are not being thrown yet
if((gEnterRoomTime[id][room] + throwtime) >= gametime) {
// if they can be told they are here
if((lastMessage[id] + 0.2) < gametime) {
// get how long they have before they will be thrown
get_time_length(gEnterRoomTime[id][room] + throwtime - gametime, length, charsmax(length));
// tell player they are in the room
set_hudmessage(255, 0, 0, .holdtime = 0.3, .fadeintime = 0.0, .fadeouttime = 0.0, .channel = 2);
show_hudmessage(id, "Bulundugun Bolge %s, .Burada Beklemek YASAKTIR. Otomatik Isinlanmaya son %s", gRoomNames[room], length);
// save when last message was sent
lastMessage[id] = gametime;
}
} else {
#if !defined THROWING_IS_TELEPORTING
// grab player's current velocity
entity_get_vector(id, EV_VEC_velocity, velocity);
// store Z velocity
throwtime = velocity[2];
// calculate direction of player's position to throw position
xs_vec_sub(gRoomSettings[room][Setting_Throw_Origin], origin, velocity);
// remove any Z offsets
velocity[2] = 0.0;
// set the speed of the velocity
xs_vec_mul_scalar(velocity, get_pcvar_float(gCvarThrowSpeed[room]) / vector_length(velocity), velocity);
// restore the Z velocity
velocity[2] = throwtime;
// set player's velocity towards the throw position
entity_set_vector(id, EV_VEC_velocity, velocity);
#else
// set player's origin to teleport out
entity_set_origin(id, gRoomSettings[room][Setting_Throw_Origin]);
#endif
// set player's angles while being thrown?
entity_set_vector(id, EV_VEC_angles, gRoomSettings[room][Setting_Throw_Angles]);
entity_set_int(id, EV_INT_fixangle, 1);
}
}
} else {
gEnterRoomTime[id][room] = 0.0;
}
}
lastAlive[id] = 1;
} else if(lastAlive[id]) {
arrayset(_:gEnterRoomTime[id], _:0.0, Room);
lastAlive[id] = 0;
}
}
get_time_length(Float:Saniyes, output[], output_len) {
new _Saniyes = floatround(Saniyes, floatround_ceil);
new const unit_mults[] = {
60,
1
};
new const unit_names[sizeof(unit_mults)][2][] = {
{"Dakika", "Dakikas"},
{"Saniye", "Saniyes"}
};
new unit_values[sizeof(unit_mults)][2];
new num_units;
for(new i = 0, val; i < sizeof(unit_mults); i++) {
val = _Saniyes / unit_mults[i];
if(val) {
unit_values[num_units][0] = val;
unit_values[num_units][1] = i;
num_units++;
_Saniyes %= unit_mults[i];
}
}
new len = output[0] = 0;
for(new i = 0; i < num_units; i++) {
len += formatex(output[len], output_len - len, "%s%s%d %s",
(i > 0 && num_units > 2) ? ", " : "",
((i == (num_units - 1) && num_units > 1) ? (num_units > 2 ? "and " : " and ") : ""),
unit_values[i][0],
unit_names[unit_values[i][1]][unit_values[i][0] != 1]
);
}
return len;
}