SA-MP Forums Archive
[Ajuda] Erro Radar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Erro Radar (/showthread.php?tid=471609)



Erro Radar - CLANdok - 24.10.2013

Erro no Pawno
pawn Код:
C:\Documents and Settings\Administrador\Desktop\sa-mp\pawno\include\PPC_PlayerCommands.inc(2805) : warning 203: symbol is never used: "Float"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Cуdigo:
pawn Код:
COMMAND:criarradar(playerid, params[])
{
// Setup local variables
new Float, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/criarradar", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "i", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, "Digite: \"/criarradar <Velocidade>\"");
else
{
// Get player's position and facing angle
new xRL [ 50 ], Float:x ;  
GetPlayerFacingAngle(playerid, Angle);
format(xRL, sizeof(xRL), "Radar \nVelocidade Mбxima\n %i kmh", MaxSpeed);
Create3DTextLabel(xRL, 0xFFFFFFFF, x, y, z, 150.0, 0, 0);  
z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air)

// Move the player a bit, otherwise he could get stuck inside the camera-object
SetPlayerPos(playerid, x, y + 1.0, z + 1.0);

// Save the camera to a file
for (new CamID; CamID < MAX_CAMERAS; CamID++)
{
// Check if this index is free
if (ACameras[CamID][CamSpeed] == 0)
{
// Setup this camera (create the objects and store the data)
SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed);

// Save the file
format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file

PFile = fopen(file, io_write); // Open the camera-file for writing

format(LineForFile, 100, "CamX %f\r\n", x);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamY %f\r\n", y);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamZ %f\r\n", z);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamAngle %f\r\n", Angle);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamSpeed %i\r\n", MaxSpeed);
fwrite(PFile, LineForFile); // And save it to the file

fclose(PFile); // Close the file

// Let the player know he created a new camera
format(Msg, 128, "Voce Criou o Radar de ID: %i", CamID);
SendClientMessage(playerid, 0x00FF00FF, Msg);

// Exit the function
return 1;
}
}

// In case all camera-slots are occupied (100 camera's have been created already), let the player know about it
format(Msg, 128, "{FF0000}Voce nao Pode Criar mais de %i Radares", MAX_CAMERAS);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else
return 0;
}
else
return 0;

return 1;
}
Oque acontece й que quando crio o radar "/criarradar" ele me teleporta. e nгo cria o radar alguem ajuda please ?


Respuesta: Erro Radar - DartakousLien - 24.10.2013

tome atencao no seu codigo
pawn Код:
new Float, Float:y,
o erro estб no Float,
que й que ele estб fazendo ali sozinho?
olhando o resto do codigo vi que precisa de um x, entre troque Float, por Float,

segundo, sempre que voce criar uma variavel ela й igual a zero (no pawn) ou seja, repare, voce cria a variavel x,y,z mas nao lhe atribui nenhum valor, logo й 0, portanto quando usar SetPlayerPos (estб aн no seu codigo) serб teleportado para a posicao 0,0,0 ou seja, centro do mapa do San Andreas. Para isso voce deve usar um GetPlayerPos logo a seguir a GetPlayerFacingAngle

e quando fizer creio que irб funcionar


Re: Respuesta: Erro Radar - CLANdok - 24.10.2013

Quote:
Originally Posted by DartakousLien
Посмотреть сообщение
tome atencao no seu codigo
pawn Код:
new Float, Float:y,
o erro estб no Float,
que й que ele estб fazendo ali sozinho?
olhando o resto do codigo vi que precisa de um x, entre troque Float, por Float,

segundo, sempre que voce criar uma variavel ela й igual a zero (no pawn) ou seja, repare, voce cria a variavel x,y,z mas nao lhe atribui nenhum valor, logo й 0, portanto quando usar SetPlayerPos (estб aн no seu codigo) serб teleportado para a posicao 0,0,0 ou seja, centro do mapa do San Andreas. Para isso voce deve usar um GetPlayerPos logo a seguir a GetPlayerFacingAngle

e quando fizer creio que irб funcionar
Olha sou muito iniciante e do seu texto tirei 2% de proveito, da pra explicar de uma maneira que eu possa compreender por favor ?


Respuesta: Erro Radar - DartakousLien - 24.10.2013

pawn Код:
COMMAND:criarradar(playerid, params[])
{
// Setup local variables
new Float:x, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/criarradar", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "i", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, "Digite: \"/criarradar <Velocidade>\"");
else
{
// Get player's position and facing angle
new xRL [ 50 ], Float:x ;  
GetPlayerFacingAngle(playerid, Angle);
GetPlayerPos(playerid,x,y,z);
format(xRL, sizeof(xRL), "Radar \nVelocidade Mбxima\n %i kmh", MaxSpeed);
Create3DTextLabel(xRL, 0xFFFFFFFF, x, y, z, 150.0, 0, 0);  
z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air)

// Move the player a bit, otherwise he could get stuck inside the camera-object
SetPlayerPos(playerid, x, y + 1.0, z + 1.0);

// Save the camera to a file
for (new CamID; CamID < MAX_CAMERAS; CamID++)
{
// Check if this index is free
if (ACameras[CamID][CamSpeed] == 0)
{
// Setup this camera (create the objects and store the data)
SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed);

// Save the file
format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file

PFile = fopen(file, io_write); // Open the camera-file for writing

format(LineForFile, 100, "CamX %f\r\n", x);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamY %f\r\n", y);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamZ %f\r\n", z);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamAngle %f\r\n", Angle);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamSpeed %i\r\n", MaxSpeed);
fwrite(PFile, LineForFile); // And save it to the file

fclose(PFile); // Close the file

// Let the player know he created a new camera
format(Msg, 128, "Voce Criou o Radar de ID: %i", CamID);
SendClientMessage(playerid, 0x00FF00FF, Msg);

// Exit the function
return 1;
}
}

// In case all camera-slots are occupied (100 camera's have been created already), let the player know about it
format(Msg, 128, "{FF0000}Voce nao Pode Criar mais de %i Radares", MAX_CAMERAS);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else
return 0;
}
else
return 0;

return 1;
}



Re: Respuesta: Erro Radar - CLANdok - 24.10.2013

Quote:
Originally Posted by DartakousLien
Посмотреть сообщение
pawn Код:
COMMAND:criarradar(playerid, params[])
{
// Setup local variables
new Float:x, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/criarradar", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "i", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, "Digite: \"/criarradar <Velocidade>\"");
else
{
// Get player's position and facing angle
new xRL [ 50 ], Float:x ;  
GetPlayerFacingAngle(playerid, Angle);
GetPlayerPos(playerid,x,y,z);
format(xRL, sizeof(xRL), "Radar \nVelocidade Mбxima\n %i kmh", MaxSpeed);
Create3DTextLabel(xRL, 0xFFFFFFFF, x, y, z, 150.0, 0, 0);  
z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air)

// Move the player a bit, otherwise he could get stuck inside the camera-object
SetPlayerPos(playerid, x, y + 1.0, z + 1.0);

// Save the camera to a file
for (new CamID; CamID < MAX_CAMERAS; CamID++)
{
// Check if this index is free
if (ACameras[CamID][CamSpeed] == 0)
{
// Setup this camera (create the objects and store the data)
SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed);

// Save the file
format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file

PFile = fopen(file, io_write); // Open the camera-file for writing

format(LineForFile, 100, "CamX %f\r\n", x);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamY %f\r\n", y);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamZ %f\r\n", z);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamAngle %f\r\n", Angle);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CamSpeed %i\r\n", MaxSpeed);
fwrite(PFile, LineForFile); // And save it to the file

fclose(PFile); // Close the file

// Let the player know he created a new camera
format(Msg, 128, "Voce Criou o Radar de ID: %i", CamID);
SendClientMessage(playerid, 0x00FF00FF, Msg);

// Exit the function
return 1;
}
}

// In case all camera-slots are occupied (100 camera's have been created already), let the player know about it
format(Msg, 128, "{FF0000}Voce nao Pode Criar mais de %i Radares", MAX_CAMERAS);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else
return 0;
}
else
return 0;

return 1;
}
pawn Код:
C:\Documents and Settings\Administrador\Desktop\sa-mp\pawno\include\PPC_PlayerCommands.inc(2818) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Desktop\sa-mp\pawno\include\PPC_PlayerCommands.inc(2804) : warning 203: symbol is never used: "x"

2 Warnings
Mesmo com as Warning funcionou vlws!


Re: Erro Radar - iDreak - 24.10.2013

Tenta assim:

pawn Код:
COMMAND:criarradar(playerid, params[])
{
    // Setup local variables
    new Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128];
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/criarradar", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 5
        if (APlayerData[playerid][PlayerLevel] >= 5)
        {
            if (sscanf(params, "i", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, "Digite: \"/criarradar <Velocidade>\"");
            else
            {
                // Get player's position and facing angle
                new xRL [ 50 ], Float:x ;
                GetPlayerFacingAngle(playerid, Angle);
                GetPlayerPos(playerid,x,y,z);
                format(xRL, sizeof(xRL), "Radar \nVelocidade Mбxima\n %i kmh", MaxSpeed);
                Create3DTextLabel(xRL, 0xFFFFFFFF, x, y, z, 150.0, 0, 0);
                z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air)

                // Move the player a bit, otherwise he could get stuck inside the camera-object
                SetPlayerPos(playerid, x, y + 1.0, z + 1.0);

                // Save the camera to a file
                for (new CamID; CamID < MAX_CAMERAS; CamID++)
                {
                    // Check if this index is free
                    if (ACameras[CamID][CamSpeed] == 0)
                    {
                        // Setup this camera (create the objects and store the data)
                        SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed);

                        // Save the file
                        format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file

                        PFile = fopen(file, io_write); // Open the camera-file for writing

                        format(LineForFile, 100, "CamX %f\r\n", x);
                        fwrite(PFile, LineForFile); // And save it to the file
                        format(LineForFile, 100, "CamY %f\r\n", y);
                        fwrite(PFile, LineForFile); // And save it to the file
                        format(LineForFile, 100, "CamZ %f\r\n", z);
                        fwrite(PFile, LineForFile); // And save it to the file
                        format(LineForFile, 100, "CamAngle %f\r\n", Angle);
                        fwrite(PFile, LineForFile); // And save it to the file
                        format(LineForFile, 100, "CamSpeed %i\r\n", MaxSpeed);
                        fwrite(PFile, LineForFile); // And save it to the file

                        fclose(PFile); // Close the file

                        // Let the player know he created a new camera
                        format(Msg, 128, "Voce Criou o Radar de ID: %i", CamID);
                        SendClientMessage(playerid, 0x00FF00FF, Msg);

                        // Exit the function
                        return 1;
                    }
                }

                // In case all camera-slots are occupied (100 camera's have been created already), let the player know about it
                format(Msg, 128, "{FF0000}Voce nao Pode Criar mais de %i Radares", MAX_CAMERAS);
                SendClientMessage(playerid, 0xFFFFFFFF, Msg);
            }
        }
        else
        return 0;
    }
    else
    return 0;

    return 1;
}



Re: Erro Radar - CLANdok - 24.10.2013

Ta funcionando cara vlws, olha queria add um mapicon tbm quando criasse. Mais n to conseguindo rs