#1

Ok so i got a speedcamera script wich is actually working but i want to add something but i dont know how. I want to add that if you get trapped with more then 5 KPH you get a fine of 250 dollars when you drive 30 KPH too fast you get a fine of 500 etc etc. But i dont know how to do that since all i could think about is: If(PlayerSpeed = 5 > MaxSpeed) but i that wont work. this is my code where it should be implemented:
pawn Код:
// This function checks if the player is speeding near a speedcamera
CheckPlayerSpeeding(playerid)
{
    // Check if the player hasn't been caught speeding recently
    if (APlayerData[playerid][PlayerCaughtSpeeding] == 0)
    {
        // Loop through all speedcameras
        for (new CamID; CamID < MAX_CAMERAS; CamID++)
        {
            // Check if this camera has been created
            if (ACameras[CamID][CamSpeed] != 0)
            {
                // Check if the player is the driver of the vehicle
                if (GetPlayerVehicleSeat(playerid) == 0)
                {
                    // Check if the player's speed is greater than the speed allowed by this camera (no need to process a distance-check if not speeding)
                    if (APlayerData[playerid][PlayerSpeed] > ACameras[CamID][CamSpeed])
                    {
                        // Check if the player is near the camera
                        if (IsPlayerInRangeOfPoint(playerid, 50.0, ACameras[CamID][CamX], ACameras[CamID][CamY], ACameras[CamID][CamZ]))
                        {
                            new speed = random(4);
                            switch(speed)
                            {
                                case 0, 1, 2:
                                {
                                    APlayerData[playerid][PlayerCaughtSpeeding] = 20;
                                    APlayerData[playerid][Fines] += 500;
                                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You've been caught by a speedtrap, slow down!");
                                }
                                case 3:
                                {
                                    SendClientMessage(playerid, 0xFFFFFFFF, "You are being lucky! Speedtrap couldn't catch you.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    else // If the player has been caught before, reduce the value until it's 0 again, then he can be caught again
        APlayerData[playerid][PlayerCaughtSpeeding]--;
}
This thing runs every 1 second
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)