This plugin works when the player's speed exceeds 600 and stops the player. Can I use this plugin? are the codes healthy?
Код:
#pragma semicolon 1
#include <amxmodx>
#include <reapi>
const Float:maxspeed=600.0;
new Float:g_velocity[MAX_CLIENTS+1][3],Float:g_verticvelo[MAX_CLIENTS+1],Float:g_speed[MAX_CLIENTS+1];
public plugin_init(){
register_plugin
(
.plugin_name = "Speed Check",
.version = "0.1",
.author = "Anonim"
);
RegisterHookChain(RG_CBasePlayer_Spawn,"@rSpawn",.post=true);
RegisterHookChain(RG_CBasePlayer_Killed,"@rKilled",.post=true);
}
public client_disconnected(id){
remove_task(this);
}
@rSpawn(const this){
set_task(2.0,"@checkspeed",this,.flags="b");
}
@rKilled(const this, pevAttacker, iGib){
#pragma unused pevAttacker,iGib
remove_task(this);
}
@checkspeed(const id){
get_entvar(id,var_velocity,g_velocity[id]);
g_verticvelo[id]=g_velocity[id][2];
g_velocity[id][2]=0.0;
g_speed[id]=vector_length(g_velocity[id]);
if(g_speed[id]>maxspeed){
client_print(id,print_center,"Ulasabilecegin max hiz degeri [%.2f] | Senin hizin: %.2f",maxspeed,g_speed[id]);
g_velocity[id][0]=g_velocity[id][0]*(maxspeed/g_speed[id]);
g_velocity[id][1]=g_velocity[id][1]*(maxspeed/g_speed[id]);
g_velocity[id][2]=g_verticvelo[id];
set_entvar(id,var_velocity,g_velocity[id]);
}
}