SA-MP Forums Archive
[Ajuda] Bug Coordenadas - 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] Bug Coordenadas (/showthread.php?tid=509787)



Bug Coordenadas - Gleisson_. - 28.04.2014

Criei um sistema de lanзar misseis mais ele esta meio bugado. O bug й que ele lanзa os misseis a qualquer lugar, sendo que й para ser na posiзгo Y + 40.

Vнdeo:

https://www.youtube.com/watch?v=JD79...ature=*********

Cуdigo:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( IsPlayerInAnyVehicle( playerid ) ) {
        if( BlockCMD[ playerid ] == 1 )
            return 0;
           
        new vehicleid = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        if( vehicleid == 578 && VeiculoU[ playerid ] == true ) {
            if( newkeys & KEY_FIRE ) {
                new
                    Float:poSS[ 3 ]
                ;
                GetPlayerPos(playerid, poSS[ 0 ], poSS[ 1 ], poSS[ 2 ]);
                CreateExplosion( poSS[ 0 ], poSS[ 1 ]+40, poSS[ 2 ], 0, 15 );
                Msg( playerid, -1, "{FFFF00}[INFO]: {FFFFFF}Vocк atirou um {BEBEBE}Missel {00FF00}40 {FFFFFF}metros a sua frente !" );
            }
        }
    }
       
    return 1;
}



Re: Bug Coordenadas - PT - 28.04.2014

usa esta funcao


pawn Код:
stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
@ OFF curti esse sv e a ideia, parabens.


Re: Bug Coordenadas - Gleisson_. - 28.04.2014

Quote:
Originally Posted by PT
Посмотреть сообщение
usa esta funcao


pawn Код:
stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
@ OFF curti esse sv e a ideia, parabens.
Valeu mano, mais o cуdigo devo usб-lo de que maneira ?

Assim:
pawn Код:
GetXYInFrontOfVehicle(vehicleid, poSS[ 0 ], poSS[ 1 ], 40);
CreateExplosion( poSS[ 0 ], poSS[ 1 ]+40, 0, 15 );
Obs: Sei que assim nгo vai dar certo pois da warning por falta de parвmetros. Mais dк um exemplo nessa situaзгo de como posso usб-lo.


Re: Bug Coordenadas - Gleisson_. - 28.04.2014

UP**


Re: Bug Coordenadas - hard_dalzot - 28.04.2014

eu axo q no lugar de getplayerpos deve ser assim
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( IsPlayerInAnyVehicle( playerid ) ) {
        if( BlockCMD[ playerid ] == 1 )
            return 0;
           
        new vehicleid = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        if( vehicleid == 578 && VeiculoU[ playerid ] == true ) {
            if( newkeys & KEY_FIRE ) {
                new
                    Float:poSS[ 2 ], Float:x, Float:y, Float:altura;
                GetPlayerPos(playerid, x, y, altura);
GetXYInFrontOfVehicle(vehicleid, poSS[ 0 ], poSS[ 1 ], 40)
                CreateExplosion( poSS[ 0 ], poSS[ 1 ], altura, 0, 15 );
                Msg( playerid, -1, "{FFFF00}[INFO]: {FFFFFF}Vocк atirou um {BEBEBE}Missel {00FF00}40 {FFFFFF}metros a sua frente !" );
            }
        }
    }
       
    return 1;
}
tenta assim


Re: Bug Coordenadas - Gleisson_. - 28.04.2014

O cуdigo ta ok, nenhum erro nem warning, mais no servidor, ele nгo cria nenhuma explosгo!

pawn Код:
if( IsPlayerInAnyVehicle( playerid ) ) {
        if( BlockCMD[ playerid ] == 1 )
            return 0;
           
        new vehicleid = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        if( vehicleid == 578 && VeiculoU[ playerid ] == true ) {
            if( newkeys & KEY_FIRE ) {
                new
                    Float:poSS[ 2 ], Float:x, Float:y, Float:altura
                ;
                GetVehiclePos(vehicleid, x, y, altura);
                GetXYInFrontOfVehicle(vehicleid, poSS[ 0 ], poSS[ 1 ], 40);
                CreateExplosion( poSS[ 0 ], poSS[ 1 ], altura, 0, 15 );
                Msg( playerid, -1, "{FFFF00}[INFO]: {FFFFFF}Vocк atirou um {BEBEBE}Missel {00FF00}40 {FFFFFF}metros a sua frente !" );
            }
        }
    }



Re: Bug Coordenadas - Input - 28.04.2014

Tente:
pawn Код:
GetVehiclePos(vehicleid, x, y, altura);
    GetXYInFrontOfVehicle(vehicleid, x, y, 40);
    CreateExplosion( x, y, altura, 0, 15 );



Re: Bug Coordenadas - Gleisson_. - 28.04.2014

Quote:
Originally Posted by Input
Посмотреть сообщение
Tente:
pawn Код:
GetVehiclePos(vehicleid, x, y, altura);
    GetXYInFrontOfVehicle(vehicleid, x, y, 40);
    CreateExplosion( x, y, altura, 0, 15 );
Cara nгo cria nenhuma explosгo..

Cуdigo atualizado:

pawn Код:
//
new RecarregarB[MAX_PLAYERS];
//

if( IsPlayerInAnyVehicle( playerid ) ) {
        if( BlockCMD[ playerid ] == 1 )
            return 0;
           
        new vehicleid = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        if( vehicleid == 578 && VeiculoU[ playerid ] == true ) {
            if( newkeys & KEY_FIRE ) {
                if(RecarregarB[playerid] > GetTickCount())
                    return 0;
                RecarregarB[playerid] = GetTickCount() + 40000;
                new
                    Float:x, Float:y, Float:altura
                ;
                GetVehiclePos(vehicleid, x, y, altura);
                GetXYInFrontOfVehicle(vehicleid, x, y, 40);
                CreateExplosion( x, y, altura, 0, 50 );
                Msg( playerid, -1, "{FFFF00}[INFO]: {FFFFFF}Vocк atirou um {BEBEBE}Missel {00FF00}40 {FFFFFF}metros a sua frente !" );
                Msg( playerid, -1, "{FFFF00}[INFO]: {FFFFFF}Agora as balas estгo sendo recarregadas, espere {00FF00}40 {FFFFFF}segundos !" );
            }
        }
    }



Re: Bug Coordenadas - arakuta - 28.04.2014

Tem certeza que nгo cria a explosгo?

Pode ser problema do eixo Z.


Re: Bug Coordenadas - Gleisson_. - 29.04.2014

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Tem certeza que nгo cria a explosгo?

Pode ser problema do eixo Z.
Arrumei, mais agora o tiro continua indo para os lados ¬'.

Cуdigo:

pawn Код:
if( IsPlayerInAnyVehicle( playerid ) ) {
        if( BlockCMD[ playerid ] == 1 )
            return 0;
           
        new vehicleid = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        if( vehicleid == 578 && VeiculoU[ playerid ] == true ) {
            if( newkeys & KEY_FIRE ) {
                if(RecarregarB[playerid] > GetTickCount())
                    return 0;
                RecarregarB[playerid] = GetTickCount() + 60000;
                new
                    Float:poSS[ 3 ]
                ;
                GetPlayerPos( playerid, poSS[ 0 ], poSS[ 1 ], poSS[ 2 ] );
                GetXYInFrontOfVehicle(vehicleid, poSS[ 0 ], poSS[ 1 ], 40);
                CreateExplosion( poSS[ 0 ], poSS[ 1 ], poSS[ 2 ], 0, 80.0 );
                Msg( playerid, -1, "{EE6AA7}[INFO]: {FFFFFF}Vocк atirou um {BEBEBE}Missel {00FF00}40 {FFFFFF}metros a sua frente !" );
                Msg( playerid, -1, "{EE6AA7}[INFO]: {FFFFFF}Agora as balas estгo sendo recarregadas, espere {00FF00}1 {FFFFFF}minuto !" );
            }
        }
    }