14.02.2015, 14:12
I suppose you will first need to detect the player's velocity. For that, I'm going to paste the code I use for my own good.
Next, I would go around and create a timer or use a pre-existing timer that you are using. Usually, it's up to you to choose a perfect timer cycle. I would go with 1000 milliseconds (equilivant to 1 second). I'm using y_timers.inc and foreach.inc for loops for this, so use the search function if you don't have it, or if you wish to use any other timer platform, it's totally up to you.
Edit it considerably to adjust your liking. Also, ABroadCast may not be a function in your gamemode. Thus, you're going to need to edit to suit your gamemode (i.e. the way it detects admin levels, etc). This system uses MPH as an unit, if you're looking for KMH, it wouldn't be hard to convert it yourself.
pawn Код:
stock Float: player_get_speed(playerid)
{
new
Float: fVelocity[4];
GetVehicleVelocity(GetPlayerVehicleID(playerid), fVelocity[0], fVelocity[1], fVelocity[2]);
fVelocity[3] = floatsqroot((fVelocity[0] * fVelocity[0]) + (fVelocity[1] * fVelocity[1]) + (fVelocity[2] * fVelocity[2])) * 100;
fVelocity[3] += fVelocity[3] / 2;
return fVelocity[3];
}
pawn Код:
Timer:ServerHeartbeat[1000]()
{
foreach(Player, i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && AdminDuty[i] != 1 && !IsAPlane(GetPlayerVehicleID(i))) {
new Float:fCurrentSpeed, zName[MAX_PLAYER_NAME];
fCurrentSpeed = player_get_speed(i);
fVehSpeed[i] = fCurrentSpeed;
if(fCurrentSpeed > 200) {
new string[74 + MAX_PLAYER_NAME];
format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) may possibly be speed hacking (%.0f MPH).", szName, i, fCurrentSpeed);
ABroadCast(COLOR_YELLOW, string, 2);
}
}
}
}

