Sistema de RADAR -
Hades12 - 08.03.2019
Seguinte, tenho um sistema de radar mas ele nгo puxa qual a velocidade que o player passou no radar, so mostra quele ele foi pego em alta velocidade.
estava tentando acrescentar esse recurso mas acabei fazendo merda e prejudiquei 9 comandos do server, queria a ajuda de alguйm.
PHP Code:
CheckPlayerSpeeding(playerid)
{
// Setup local variables
new Name[24], Msg[128];
// 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]))
{
// Prevent the player being caught multiple times by the same speed-camera
APlayerData[playerid][PlayerCaughtSpeeding] = 20;
// Increase the wanted-level of this player by 1 star
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
// Let the player know he's been caught speeding
SendClientMessage(playerid, 0xFFFFFFFF, "Voce passou a %d KM/H e o limite de velocidade permitido й %d KM/H");
// Get the name of the player
GetPlayerName(playerid, Name, sizeof(Name));
// Also inform all police players that this player is caught speeding
format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} foi pego no radar, persiga-o e multe-o", Name);
Police_SendMessage(Msg);
}
}
}
}
}
}
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]--;
}
Re: Sistema de RADAR -
Don_Speed - 08.03.2019
PHP Code:
CheckPlayerSpeeding(playerid)
{
new Name[24], Msg[128];
if (APlayerData[playerid][PlayerCaughtSpeeding] == 0)
{
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]))
{
// Prevent the player being caught multiple times by the same speed-camera
APlayerData[playerid][PlayerCaughtSpeeding] = 20;
// Increase the wanted-level of this player by 1 star
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
// Let the player know he's been caught speeding
new don[120];
format(don, sizeof don,"Voce passou a %d KM/H e o limite de velocidade permitido й %d KM/H",APlayerData[playerid][PlayerSpeed]);
SendClientMessage(playerid, 0xFFFFFFFF, don);
// Get the name of the player
GetPlayerName(playerid, Name, sizeof(Name));
// Also inform all police players that this player is caught speeding
format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} foi pego no radar, persiga-o e multe-o", Name);
Police_SendMessage(Msg);
}
}
}
}
}
}
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]--;
}
Re: Sistema de RADAR -
zHellSync - 08.03.2019
Para verificar com mais facilidade e menos codigo se o jogador estб de motorista recomendo
PHP Code:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
}
e para criar um radar, recomendo usar o Streamer criando uma area dinamica. bem mais facil usar e mais rapido.
basicamente o meu que uso estб assim
public OnPlayerEnterDynamicArea(playerid, areaid)
PHP Code:
if(areaid == AreaRadar1)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(GetPlayerSpeed(playerid) > MAX_KMS_RADAR1)
{
new str2[128], strvelo[128];
format(strvelo, sizeof(strvelo), "» {ffffff}Velocidade Registrada: {0080FF}%d{009D4F} KM/H", GetPlayerSpeed(playerid));
format(str2, sizeof(str2), "» {ffffff}Voce ultrapassou o limite de {FF0000}(%dKM/H) {ffffff}de velocidade e foi multado.", MAX_KMS_RADAR1);
SendClientMessage(playerid, Cor_Verde, "================================= RADAR =================================");
SendClientMessage(playerid, Cor_Verde, str2);
SendClientMessage(playerid, Cor_Verde, "» {ffffff}Voce acumulou {FF0000}+1 {ffffff}ponto em sua Carteira de Habilitacao.");
SendClientMessage(playerid, Cor_Verde, strvelo);
SendClientMessage(playerid, Cor_Verde, "{ff0000}ATENCAO: {ffffff}Ao acumular os pontos maximo de multas {00ff00}(21){ffffff} sua carteira sera suspensa.");
SendClientMessage(playerid, Cor_Verde, "================================= RADAR =================================");
PlayerPlaySound(playerid, 1132, 0, 0, 0);
}
else
{
new str[128];
format(str, sizeof(str), "» {ffffff}Velocidade Registrada: {0080FF}%d{009D4F} KM/H {ffffff}| {FF0000}(MAXIMA %d KM/H)", GetPlayerSpeed(playerid), MAX_KMS_RADAR1);
SendClientMessage(playerid, Cor_Verde, str);
}
}
}
Stock para receber velocidade:
PHP Code:
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 190.0;
return floatround(ST[3]);
}
Assim criaria a area na public OnGameModeInit
PHP Code:
AreaRadar1 = CreateDynamicCircle(1430.0851,-1732.2394, 22.70, -1, -1, -1, 0);
Observaзхes.. O
MAX_KMS_RADAR1 vocк define no topo da GM com o valor que seria a velocidade maxima do radar 1.. espero ter ajudado, de qualquer forma boa sorte.
e sobre as multas no caso eu nгo defini pois vocк pode definir seu proprio, apenas um exemplo
Re: Sistema de RADAR -
AutoMatic2 - 08.03.2019
PHP Code:
GetVehicleSpeed(vehicleid)
{
new Float:Pos[3];
GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
return floatround(floatsqroot(Pos[0] * Pos[0] + Pos[1] * Pos[1] + Pos[2] * Pos[2]) * 180.00);
}