may this helps
Read the comments with care:
Code:
#define MAXPLAYERS 32
#define SECDIST 230 //Sensitivity, may need to be adjusted
#define MAXOFFENCE 700 //Sensitivity, may need to be adjusted
new gmaxplayers;
new g_OldPos[3][MAXPLAYERS+1];
new g_Detections[MAXPLAYERS+1];
new g_Warning[MAXPLAYERS+1];
public plugin_init()
{
set_timer("check_speedhack",1.0,99999,"");
gmaxplayers = maxplayercount();
}
public plugin_connect(. ..)
{
// we need "id" (index of user) as a 2nd PARAM;
g_OldPos[0][id] = 0;
g_OldPos[1][id] = 0;
g_OldPos[2][id] = 0;
// also index is "id"
g_Detections[id] = 0;
g_Warning[id] = 0;
}
public check_speedhack()
{
for(new i=1; <= gmaxplayers; i++)
{
// num to str i;
// not sure if exists, but a check for is user alive ? (pursupose exists)
if(is_user_alive(i) )
{
new origin[3];
new oldorigin[3];
new dist;
//Get origins
// I don't know exactly how to get get_userorigin in correct way, but this i used on my AMXX Plugin
get_user_origin(i, origin);
oldorigin[0] = g_OldPos[0][i];
oldorigin[1] = g_OldPos[1][i];
oldorigin[2] = g_OldPos[2][i];
// another problem i don't know if exists a function to get distance between 2 origins
// in amxx exists, is called "get_distance(org1,org2)
// pursopose exists
dist = get_distance(origin, oldorigin);
if (dist > SECDIST)
g_Detections[i] = g_Detections[i] + dist - SECDIST;
// not really required, but it's a good point to check if user is on buyzone
// i know, in adminmod doesen't exists a function like that ( exits ? )
if(is_user_in_buyzone(i) )
{
clearSpecificAlertValue(i);
}
if (g_Detections[i] > SECDIST)
{
g_Warning[i]++
if (g_Warning[i] > 1)
if (g_Detections[i] > MAXOFFENCE)
RegisterOffense(i)
}
g_OldPos[0][i] = origin[0]
g_OldPos[1][i] = origin[1]
g_OldPos[2][i] = origin[2]
}
else
{
clearSpecificAlertValue(i)
}
}
}
public clearSpecificAlertValue(id)
{
g_Detections[id] = 0;
g_Warning[id] = 0;
}
public RegisterOffense(...)
{
// log the player or something;
// a good to punish players;
// do a loop, check if no admin on server and ban player
// if exits an admin on server, just print a message to chat
}