[Ajuda] Sistema de RADAR
#1

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 CamIDCamID MAX_CAMERASCamID++)
        {
            
// 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(playerid50.0ACameras[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(playeridGetPlayerWantedLevel(playerid) + 1);
                            
// Let the player know he's been caught speeding
                            
SendClientMessage(playerid0xFFFFFFFF"Voce passou a %d KM/H e o limite de velocidade permitido й %d KM/H");
                            
// Get the name of the player
                            
GetPlayerName(playeridNamesizeof(Name));
                            
// Also inform all police players that this player is caught speeding
                            
format(Msg128"{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]--;

Reply
#2

PHP Code:
CheckPlayerSpeeding(playerid)
{
    new 
Name[24], Msg[128];
    if (
APlayerData[playerid][PlayerCaughtSpeeding] == 0)
    {
        for (new 
CamIDCamID MAX_CAMERASCamID++)
        {
            
// 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(playerid50.0ACameras[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(playeridGetPlayerWantedLevel(playerid) + 1);
                            
// Let the player know he's been caught speeding
                            
new don[120];
                            
format(donsizeof don,"Voce passou a %d KM/H e o limite de velocidade permitido й %d KM/H",APlayerData[playerid][PlayerSpeed]);
                            
SendClientMessage(playerid0xFFFFFFFFdon);

                            
// Get the name of the player
                            
GetPlayerName(playeridNamesizeof(Name));
                            
// Also inform all police players that this player is caught speeding
                            
format(Msg128"{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]--;

Reply
#3

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(strvelosizeof(strvelo), "» {ffffff}Velocidade Registrada: {0080FF}%d{009D4F} KM/H"GetPlayerSpeed(playerid));
                
format(str2sizeof(str2), "» {ffffff}Voce ultrapassou o limite de {FF0000}(%dKM/H) {ffffff}de velocidade e foi multado."MAX_KMS_RADAR1);
                
SendClientMessage(playeridCor_Verde"================================= RADAR =================================");
                
SendClientMessage(playeridCor_Verdestr2);
                
SendClientMessage(playeridCor_Verde"» {ffffff}Voce acumulou {FF0000}+1 {ffffff}ponto em sua Carteira de Habilitacao.");
                
SendClientMessage(playeridCor_Verdestrvelo);
                
SendClientMessage(playeridCor_Verde"{ff0000}ATENCAO: {ffffff}Ao acumular os pontos maximo de multas {00ff00}(21){ffffff} sua carteira sera suspensa.");
                
SendClientMessage(playeridCor_Verde"================================= RADAR =================================");
                
PlayerPlaySound(playerid1132000);
            }
            else
            {
                new 
str[128];
                
format(strsizeof(str), "» {ffffff}Velocidade Registrada: {0080FF}%d{009D4F} KM/H {ffffff}| {FF0000}(MAXIMA %d KM/H)"GetPlayerSpeed(playerid), MAX_KMS_RADAR1);
                
SendClientMessage(playeridCor_Verdestr);
            }
        }
    } 
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.239422.70, -1, -1, -10); 
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
Reply
#4

PHP Code:
GetVehicleSpeed(vehicleid)
{
    new 
Float:Pos[3];
    
GetVehicleVelocity(vehicleidPos[0], Pos[1], Pos[2]);
    return 
floatround(floatsqroot(Pos[0] * Pos[0] + Pos[1] * Pos[1] + Pos[2] * Pos[2]) * 180.00);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)