Help with fines script
#1

Hello so i created a speedcamera script but i want to do that if hes like 10 KPH too fast he gets 250$ fines and about 30 KPH 500$ and at 50 KPH 750. But i dont know how. Can anyone show me it? this is my code so far:
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]--;
}
Reply
#2

Make a timer to call that function.
Reply
#3

i know -_-" but it now only fines 500$ always when u get caught but i want it when u drive 10 KPH too fast u get fined 250 and when u drive 30 KPH too fast u get fined 500 and when you drive 50 KPH too fast you get 100 fines. But i dont know how to do this :S
Reply
#4

Err bump? :S
Reply
#5

maybe you can use this? XD dont know if this is what you mean
pawn Код:
SetTimer("10kph", 500, 1);

forward 10kph();
public 10kph()
{
GivePlayerMoney(playerid, -250);
return 1;
}
i dont know if the time of timer is right but you could make something like this.

EDIT: you could also use this to get the speed of the player:
pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh) // by misco
{
  new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
Reply
#6

I want it to be like if(PlayerSpeed = 10 above Maxspeed)... But how to use that? XD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)