VC:MP 0.4 (Beta) > Script Discussion

Rotating Sprites

<< < (2/3) > >>

Honey.:

--- Quote from: sseebbyy on October 02, 2014, 05:49:54 pm ---Maybe because you rotate the sprite when position is changed ?! (or in a speedometer script?)

--- End quote ---

If you mean the position of the player is changed then you're right.The player position is contantly changing while  it is driving.

thijn:
Post some more code. A sprite doesn't dance on your screen unless you tell it to.

Honey.:

--- Quote from: thijn on October 02, 2014, 08:06:15 pm ---Post some more code. A sprite doesn't dance on your screen unless you tell it to.

--- End quote ---

Here you go :


--- Code: ---
function onScriptLoad()
{
// Other Functions
NewTimer( "Speedometer", 1500, 0 );
s <-CreateSprite( "needle.png", 500, 500, 0, 0, 0,255 );
// other functions
}

function Speedometer()
{
for ( local i = 0; i < GetMaxPlayers(); i++ )
{
                local p = FindPlayer( i );
                if ( p )
                {
                        if ( p.IsSpawned )
                        {
                                local vehicle = p.Vehicle;
                                if ( vehicle )
                                {
                          local Speed = sqrt(vehicle.Speed.x*vehicle.Speed.x + vehicle.Speed.y * vehicle.Speed.y + vehicle.Speed.z * vehicle.Speed.z) * 50 * 3.6;
                          local output = round(Speed, 0);
  s.RotateForPlayer( p, output );
                                }
                        }
                }
         }
}

function onPlayerEnterVehicle( player, veh, isPassenger )
{
s.ShowForPlayer( player );
}
function onPlayerExitVehicle( player, veh )
{
s.HideFromPlayer( player );
}

--- End code ---

This is all of the code I have used.

Honey.:
Here is a video ( sorry for the bad quality, I compressed the video too much  :-\ ) :



Honey.:
Bump!!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version