//===================================================================================================
// Timers
//===================================================================================================
forward UpdateCameras();
public UpdateCameras()
{
for(new a = 0;a<MAX_PLAYERS;a++)
{
if(!IsPlayerConnected(a)) continue;
if(!IsPlayerInAnyVehicle(a)) continue;
if(GetPVarInt(a,"PlayerHasBeenFlashed") == 1)
{
continue;
} else if (GetPVarInt(a,"PlayerHasBeenFlashed") == 2)
{
DeletePVar(a,"PlayerHasBeenFlashed");
continue;
}
for(new b = 0;b<loaded_cameras +1;b++)
{
if(SpeedCameras[b][_active] == false) continue;
if(IsPlayerInRangeOfPoint(a,SpeedCameras[b][_range],SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z]))
{
new speed = floatround(GetVehicleSpeed(GetPlayerVehicleID(a),SpeedCameras[b][_usemph]));
new limit = SpeedCameras[b][_limit];
if(speed > limit)
{
TextDrawShowForPlayer(a,flash);
#if CAMERA_PERSPECTIVE == true
SetPlayerCameraPos(a,SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z] + 5);
new Float:x,Float:y,Float:z;GetPlayerPos(a,x,y,z);
SetPlayerCameraLookAt(a,x,y,z);
#endif
SetPVarInt(a,"PlayerHasBeenFlashed",1);
SetTimerEx("RemoveFlash",CAMERA_FLASH_TIME,false,"i",a);
if(GetPlayerState(a) == PLAYER_STATE_DRIVER)
{
if(SpeedCameras[b][_usemph] == 0)
{
SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"kmh where you were allowed to drive ",limit, "kmh.");
SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],".");
} else {
SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"mph where you were allowed to drive ",limit, "mph.");
SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],".");
}
GivePlayerMoney(a, - SpeedCameras[b][_fine]);
}
}
}
}
}
}
forward RemoveFlash(playerid);
public RemoveFlash(playerid)
{
TextDrawHideForPlayer(playerid,flash);
SetPVarInt(playerid,"PlayerHasBeenFlashed",2);
#if CAMERA_PERSPECTIVE == true
SetCameraBehindPlayer(playerid);
#endif
}
stock IsPoliceVehicle(vehicleid) { new veh_id = GetVehicleModel(vehicleid); switch(veh_id) { case 427, 523, 528, 596, 597, 598, 599: return true; } return false; } forward UpdateCameras(); public UpdateCameras() { for(new a = 0; a < MAX_PLAYERS; a++) { if(!IsPlayerConnected(a)) continue; if(!IsPlayerInAnyVehicle(a)) continue; if(!IsPoliceVehicle(GetPlayerVehicleID(a)) continue; if(GetPVarInt(a,"PlayerHasBeenFlashed") == 1) { continue; } else if (GetPVarInt(a,"PlayerHasBeenFlashed") == 2) { DeletePVar(a,"PlayerHasBeenFlashed"); continue; } for(new b = 0;b<loaded_cameras +1;b++) { if(SpeedCameras[b][_active] == false) continue; if(IsPlayerInRangeOfPoint(a,SpeedCameras[b][_range],SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z])) { new speed = floatround(GetVehicleSpeed(GetPlayerVehicleID(a),SpeedCameras[b][_usemph])); new limit = SpeedCameras[b][_limit]; if(speed > limit) { TextDrawShowForPlayer(a,flash); #if CAMERA_PERSPECTIVE == true SetPlayerCameraPos(a,SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z] + 5); new Float:x,Float:y,Float:z;GetPlayerPos(a,x,y,z); SetPlayerCameraLookAt(a,x,y,z); #endif SetPVarInt(a,"PlayerHasBeenFlashed",1); SetTimerEx("RemoveFlash",CAMERA_FLASH_TIME,false,"i",a); if(GetPlayerState(a) == PLAYER_STATE_DRIVER) { if(SpeedCameras[b][_usemph] == 0) { SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"kmh where you were allowed to drive ",limit, "kmh."); SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],"."); } else { SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"mph where you were allowed to drive ",limit, "mph."); SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],"."); } GivePlayerMoney(a, - SpeedCameras[b][_fine]); } } } } } } forward RemoveFlash(playerid); public RemoveFlash(playerid) { TextDrawHideForPlayer(playerid,flash); SetPVarInt(playerid,"PlayerHasBeenFlashed",2); #if CAMERA_PERSPECTIVE == true SetCameraBehindPlayer(playerid); #endif }
if(GetVehicleModel(vehicleid) == the police car id here)
/*forward UpdateCameras();
public UpdateCameras()
{
for(new a = 0; a < MAX_PLAYERS; a++)
{
if(!IsPlayerConnected(a)) continue;
if(!IsPlayerInAnyVehicle(a)) continue;
if(GetVehicleModel(vehicleid) == the police car id here) return 0;
if(GetPVarInt(a,"PlayerHasBeenFlashed") == 1)
{
continue;
}
else if (GetPVarInt(a,"PlayerHasBeenFlashed") == 2)
{
DeletePVar(a,"PlayerHasBeenFlashed");
continue;
}
for(new b = 0;b<loaded_cameras +1;b++)
{
if(SpeedCameras[b][_active] == false) continue;
if(IsPlayerInRangeOfPoint(a,SpeedCameras[b][_range],SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z]))
{
new speed = floatround(GetVehicleSpeed(GetPlayerVehicleID(a),SpeedCameras[b][_usemph]));
new limit = SpeedCameras[b][_limit];
if(speed > limit)
{
TextDrawShowForPlayer(a,flash);
#if CAMERA_PERSPECTIVE == true
SetPlayerCameraPos(a,SpeedCameras[b][_x],SpeedCameras[b][_y],SpeedCameras[b][_z] + 5);
new Float:x,Float:y,Float:z;GetPlayerPos(a,x,y,z);
SetPlayerCameraLookAt(a,x,y,z);
#endif
SetPVarInt(a,"PlayerHasBeenFlashed",1);
SetTimerEx("RemoveFlash",CAMERA_FLASH_TIME,false,"i",a);
if(GetPlayerState(a) == PLAYER_STATE_DRIVER)
{
if(SpeedCameras[b][_usemph] == 0)
{
SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"kmh where you were allowed to drive ",limit, "kmh.");
SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],".");
} else {
SendClientMessageEx(a,0xFF1E00FF,"sisis","You are driving too fast! you got busted driving ",speed,"mph where you were allowed to drive ",limit, "mph.");
SendClientMessageEx(a,0xFF1E00FF,"sis","You got yourself a fine of $",SpeedCameras[b][_fine],".");
}
GivePlayerMoney(a, - SpeedCameras[b][_fine]);
}
}
}
}
}
}
forward RemoveFlash(playerid);
public RemoveFlash(playerid)
{
TextDrawHideForPlayer(playerid,flash);
SetPVarInt(playerid,"PlayerHasBeenFlashed",2);
#if CAMERA_PERSPECTIVE == true
SetCameraBehindPlayer(playerid);
#endif
}*/
FOR POLICE CARS, he means an exception, to make the speedcam work EXCEPT for police cars..
|