vehicle anti speed
#1

fixed
Reply
#2

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.

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];
}
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.

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);
            }
        }
    }
}
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.
Reply
#3

Mai intai ai nevoie de define-ul asta pentru a evita erorile gen: "undefined symbol..."
PHP код:
#define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.8) 
Apoi trebuie sa stochezi functia GetPlayerSpeed.
PHP код:
stock GetPlayerSpeed(playeridget3d)
{
    new 
Float:xFloat:yFloat:z;
    if(
IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
    else 
GetPlayerVelocity(playeridxyz);
    return 
SpeedCheck(xyz100.0get3d);

Si acum trebe sa creezi acel "mesaj" care sa apara admilor. Asta o pui undeva la un timer sau creezi unu de o secunda(recomandat)

PHP код:
for(new i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            new 
string1[128], sendername[25];
            
GetPlayerName(isendernamesizeof(sendername));
            if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new 
speed=GetPlayerSpeed(i,0);
                
GetPlayerName(isendernamesizeof(sendername));
                if(
speed>225)
                {
                    
format(string1sizeof(string1), "*ATENTIE*: %s [%d] circula cu viteza de %.0d km/h intr-un %s"sendernameispeed,VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]);
                    
//Aici pui functia care le trimite mesah adminilor. ABroadCast sau cum ai tu in GameMode.
                
}
            }
        }
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)