17.05.2014, 09:31
pawn Код:
public IsACop(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
switch(PlayerInfo[playerid][pLeader])
case 1 .. 3, 5 .. 7, 11, 13: return 1;
switch(PlayerInfo[playerid][pMember])
case 1 .. 3, 5 .. 7, 11, 13: return 1;
return 0;
}
pawn Код:
CheckPlayerSpeeding(playerid)
{
// Check if the player hasn't been caught speeding recently
if(APlayerData[playerid][PlayerCaughtSpeeding]) return APlayerData[playerid][PlayerCaughtSpeeding]--;
if(IsACop(playerid)) return 1;
// Loop through all speedcameras
for(new CamID = 0; 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, 20.0, ACameras[CamID][CamX], ACameras[CamID][CamY], ACameras[CamID][CamZ]))
{
APlayerData[playerid][PlayerCaughtSpeeding] = 20;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Speed Cam has given you a ticket costing $2500, reason: High Speed");
GivePlayerCash(playerid, -2500);
break;
}
}
}
}
}
return 1;
}