#include <amxmodx>
#include <amxmisc>
#include <engine_stocks>
#include <hamsandwich>
#define PLUGIN "AirSpeedLimit"
#define VERSION "1.0"
#define AUTHOR "Kova"
#define SPEEDLIMIT 600.0
new Float:NewVelocity[33][3];
new Float:VerticalVelocity[33];
new Float:speed[33];
new g_Alive[33];
new g_MaxPlayer;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
set_task(0.1, "Check",_,_,_,"b");
RegisterHam(Ham_Spawn, "player", "hamPlayerSpawn", 1);
register_event("DeathMsg", "eventPlayerDeath", "a");
g_MaxPlayer = get_maxplayers();
}
public Check()
{
for(new i = 0; i < g_MaxPlayer; i++)
{
if(!g_Alive[i])
continue;
SpeedTester(i);
}
}
public hamPlayerSpawn(id)
{
if(!is_user_alive(id))
return;
g_Alive[id] = true;
}
public eventPlayerDeath()
{
g_Alive[read_data(2)] = false;
}
public client_disconnected(id)
{
g_Alive[id] = false;
}
public SpeedTester(id)
{
get_user_velocity(id, NewVelocity[id]);
VerticalVelocity[id] = NewVelocity[id][2];
NewVelocity[id][2] = 0.0;
speed[id] = vector_length(NewVelocity[id]);
if(speed[id] > SPEEDLIMIT)
{
client_print(id, print_center, "Túl gyorsan mész! | Sebességed: %.2f", speed[id]);
NewVelocity[id][0] = NewVelocity[id][0] * (SPEEDLIMIT / speed[id]);
NewVelocity[id][1] = NewVelocity[id][1] * (SPEEDLIMIT / speed[id]);
NewVelocity[id][2] = VerticalVelocity[id];
set_user_velocity(id, NewVelocity[id]);
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/