01.03.2012, 19:58
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]--;
}