[HELP] About the GetVehicleZAngle(vehicleid);
#1

Hello everyone, today I met one problem, you can understand from the topic title...

So, look how the car is standing:


But it should be standing like this:


Now, I'll show you some code, which loads the vehicles from the database:
pawn Код:
while( mysql_retrieve_row( ) )
        {
           
            mysql_get_field( "model", buffer );
            new model = strval( buffer );
           
            new vehid = CreateVehicle( model, 30.0, 40.0, 50.0, 60.0, 0, 0, 0 );
           
            mysql_get_field( "a", buffer );
            gVehData[ vehid ][ facingA ] = floatstr( buffer );

            mysql_get_field( "x", buffer );
            gVehData[ vehid ][ pos ][ 0 ] = floatstr( buffer );

            mysql_get_field( "y", buffer );
            gVehData[ vehid ][ pos ][ 1 ] = floatstr( buffer );

            mysql_get_field( "z", buffer );
            gVehData[ vehid ][ pos ][ 2 ] = floatstr( buffer );

            mysql_get_field( "color1", buffer );
            gVehData[ vehid ][ color ][ 0 ] = strval( buffer );

            mysql_get_field( "color2", buffer );
            gVehData[ vehid ][ color ][ 1 ] = strval( buffer );

            mysql_get_field( "fuel", buffer );
            gVehData[ vehid ][ fuel ] = strval( buffer );

            mysql_get_field( "locked", buffer );
            gVehData[ vehid ][ locked ] = strval( buffer );

            mysql_get_field( "owner", buffer );
            format( gVehData[ vehid ][ owner ], 25, "%s", buffer );

            SetVehiclePos( vehid, gVehData[ vehid ][ pos ][ 0 ], gVehData[ vehid ][ pos ][ 1 ], gVehData[ vehid ][ pos ][ 2 ] );
            SetVehicleZAngle( vehid, gVehData[ vehid ][ facingA ] );

            SetVehicleParamsEx( vehid, 0, 0, 0, gVehData[ vehid ][ locked ], 0, 0, 0 );
           
            ChangeVehicleColor( vehid, gVehData[ vehid ][ color ][ 0 ], gVehData[ vehid ][ color ][ 1 ] );

            gVehData[ vehid ][ loaded ] = true;

            printf( " >> Log: vehicle id %d which owner is %s has been loaded.", vehid, gVehData[ vehid ][ owner ] );
        }
Well, any ideas? Don't really understand why the fu*k its not working...
Thanks for help, looking forward.
Reply
#2

Why do you use SetVehiclePos, SetVehicleZAngle and ChangeVehicleColor anyway? Why don't you just wait until you have the vehicle information and then create the vehicle with the information you have obtained from the SQL database, for example:

pawn Код:
while( mysql_retrieve_row( ) )
{
    mysql_get_field( "model", buffer );
    new model = strval( buffer );
   
    mysql_get_field( "a", buffer );
    gVehData[ vehid ][ facingA ] = floatstr( buffer );

    mysql_get_field( "x", buffer );
    gVehData[ vehid ][ pos ][ 0 ] = floatstr( buffer );

    mysql_get_field( "y", buffer );
    gVehData[ vehid ][ pos ][ 1 ] = floatstr( buffer );

    mysql_get_field( "z", buffer );
    gVehData[ vehid ][ pos ][ 2 ] = floatstr( buffer );

    mysql_get_field( "color1", buffer );
    gVehData[ vehid ][ color ][ 0 ] = strval( buffer );

    mysql_get_field( "color2", buffer );
    gVehData[ vehid ][ color ][ 1 ] = strval( buffer );

    mysql_get_field( "fuel", buffer );
    gVehData[ vehid ][ fuel ] = strval( buffer );

    mysql_get_field( "locked", buffer );
    gVehData[ vehid ][ locked ] = strval( buffer );

    mysql_get_field( "owner", buffer );
    format( gVehData[ vehid ][ owner ], 25, "%s", buffer );

    new vehid = CreateVehicle( model, gVehData[ vehid ][ pos ][ 0 ], gVehData[ vehid ][ pos ][ 1 ], gVehData[ vehid ][ pos ][ 2 ], gVehData[ vehid ][ facingA ], gVehData[ vehid ][ color ][ 0 ], gVehData[ vehid ][ color ][ 1 ], 0 );

    SetVehicleParamsEx( vehid, 0, 0, 0, gVehData[ vehid ][ locked ], 0, 0, 0 );

    gVehData[ vehid ][ loaded ] = true;

    printf( " >> Log: vehicle id %d which owner is %s has been loaded.", vehid, gVehData[ vehid ][ owner ] );
}
See, doesn't that make a lot more sense?

Just an additional note, your respawn_delay in CreateVehicle will cause the vehicle to instantly re-spawn when someone exits it, if you wanted it so that the vehicle does not re-spawn from inactivity, then set the respawn_delay parameter to -1.
Reply
#3

SetVehicelZAngle doesnt work on empty vehicles.
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Why do you use SetVehiclePos, SetVehicleZAngle and ChangeVehicleColor anyway? Why don't you just wait until you have the vehicle information and then create the vehicle with the information you have obtained from the SQL database, for example:

pawn Код:
while( mysql_retrieve_row( ) )
{
    mysql_get_field( "model", buffer );
    new model = strval( buffer );
   
    mysql_get_field( "a", buffer );
    gVehData[ vehid ][ facingA ] = floatstr( buffer );

    mysql_get_field( "x", buffer );
    gVehData[ vehid ][ pos ][ 0 ] = floatstr( buffer );

    mysql_get_field( "y", buffer );
    gVehData[ vehid ][ pos ][ 1 ] = floatstr( buffer );

    mysql_get_field( "z", buffer );
    gVehData[ vehid ][ pos ][ 2 ] = floatstr( buffer );

    mysql_get_field( "color1", buffer );
    gVehData[ vehid ][ color ][ 0 ] = strval( buffer );

    mysql_get_field( "color2", buffer );
    gVehData[ vehid ][ color ][ 1 ] = strval( buffer );

    mysql_get_field( "fuel", buffer );
    gVehData[ vehid ][ fuel ] = strval( buffer );

    mysql_get_field( "locked", buffer );
    gVehData[ vehid ][ locked ] = strval( buffer );

    mysql_get_field( "owner", buffer );
    format( gVehData[ vehid ][ owner ], 25, "%s", buffer );

    new vehid = CreateVehicle( model, gVehData[ vehid ][ pos ][ 0 ], gVehData[ vehid ][ pos ][ 1 ], gVehData[ vehid ][ pos ][ 2 ], gVehData[ vehid ][ facingA ], gVehData[ vehid ][ color ][ 0 ], gVehData[ vehid ][ color ][ 1 ], 0 );

    SetVehicleParamsEx( vehid, 0, 0, 0, gVehData[ vehid ][ locked ], 0, 0, 0 );

    gVehData[ vehid ][ loaded ] = true;

    printf( " >> Log: vehicle id %d which owner is %s has been loaded.", vehid, gVehData[ vehid ][ owner ] );
}
See, doesn't that make a lot more sense?

Just an additional note, your respawn_delay in CreateVehicle will cause the vehicle to instantly re-spawn when someone exits it, if you wanted it so that the vehicle does not re-spawn from inactivity, then set the respawn_delay parameter to -1.
Im making this because, then I wont have the vehid to store vehicle information to. So I create it first, and the set the options to vehicle. But, its not that important isnt it? I guess I could do the other way you showed me, but will my way cause any error or lag? Is your code more better to use? If so, I'll change it.


And thanks for the reply about the GetVehicleZAngle(); I'll figure something out.

EDIT: Well I guess the SetVehicleZAngle isnt working either. So how should I get this to work?
Reply
#5

It's like that because of what the other poster said. So that's why I suggested using the CreateVehicle after you have gathered the information, but now after you've explained it, I do see your problem.

I guess you could just make some temporary variables and store the information in that, then after you have created the vehicle, put the information in the gVehData variable as intended
Reply
#6

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
It's like that because of what the other poster said. So that's why I suggested using the CreateVehicle after you have gathered the information, but now after you've explained it, I do see your problem.

I guess you could just make some temporary variables and store the information in that, then after you have created the vehicle, put the information in the gVehData variable as intended
Okay. Well I guess the SetVehicleZAngle isnt working either. So how should I get this to work? (I mean to make the car at normal facing angle )

I did this OnPlayerExitVehicle:
pawn Код:
if( gVehData[ vehicleid ][ loaded ] )
{
        GetVehicleZAngle( vehicleid, gVehData[ vehicleid ][ facingA ] );
}
And It saves that variable into the database, so next time the vehicle is loaded, it should be at that facing angle. But nooo.

So maybe I should make a command, like /buyparkingplace or /parkvehicle so, then it saves the position and the facing angle..? But I would like to make it more auto, more 0.3c style...
Reply
#7

Show us your enum.
Reply
#8

pawn Код:
enum vehEnum {
    owner[ MAX_PLAYER_NAME ],
    locked,
    engine,
    lights,
    alarm,
    trunk,
    hood,
    fuel,
    engineType,
    Float: pos[ 3 ],
    Float: facingA,
    bool: loaded,
    color[ 2 ] ,
    model
};
Here it is, chief.
Reply
#9

Quote:
Originally Posted by Macluawn
Посмотреть сообщение
SetVehicelZAngle doesnt work on empty vehicles.
SetVehicleZAngle works on empty vehicles.
Solution on this topic:
https://sampforum.blast.hk/showthread.php?tid=261730
Reply
#10

Quote:
Originally Posted by Skorch
Посмотреть сообщение
SetVehicleZAngle works on empty vehicles.
Solution on this topic:
https://sampforum.blast.hk/showthread.php?tid=261730
Oh nice, but I already did it. I just craeted the vehicle with the ZAngle... So there's no reason to change something, if it works. But thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)