SA-MP Forums Archive
[FilterScript] Dashboards! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Dashboards! (/showthread.php?tid=324256)



Dashboards! - clavador - 08.03.2012

Yeah! Finally!

I waited so long for a good camera control in SAMP to get this to work and now finally it's here.

I took Blantas function posted on https://sampforum.blast.hk/showthread.php?tid=323271&page=21, so some credits go to him. The function itself does what it has to do, so I didn't have to make one of my own.

What I did is center the camera in most of the cars, but not all of them. I'm not planning to expand it right now, but you will see that is very easy to customize.

Known bugs:

- Checkpoints can't be seen through the windshield or side windows (this is a GTA thing, nothing to do with the script itself).

SAMP version: 0.3e

First of all, you need this:

pawn Код:
enum CameraObjects
{
    camobj
};

new Player[MAX_PLAYERS][CameraObjects];

enum DashBoardEnum
{
    modelid,
    Float:cam_x,
    Float:cam_y,
    Float:cam_z
};

new DashBoards[][DashBoardEnum] =
{
    { 410, -0.30, -0.25, 0.55 }, // Manana
    { 404, -0.35, -0.15, 0.68 }, // Perreniel
    { 575, -0.35, -0.15, 0.68 }, // Broadway
    { 466, -0.38, -0.15, 0.60 }, // Glendale
    { 401, -0.40, -0.15, 0.52 }, // Bravura
    { 419, -0.40, -0.25, 0.40 }, // Esperanto
    { 474, -0.47, -0.30, 0.52 }, // Hermes
    { 518, -0.53, -0.22, 0.43 }, // Buccaneer
    { 516, -0.47, -0.15, 0.55 }, // Nebula
    { 491, -0.40, -0.25, 0.44 }, // Virgo  
    { 479, -0.35, -0.30, 0.65 }, // Regina  
    { 566, -0.45, -0.25, 0.55 }, // Tahoma
    { 535, -0.35, -0.15, 0.62 }, // Slamvan
    { 467, -0.45, -0.25, 0.54 }, // Oceanic
    { 492, -0.45, -0.25, 0.54 }, // Greenwood
    { 426, -0.45, -0.25, 0.54 }, // Premier
    { 505, -0.45, -0.35, 0.68 }, // Rancher
    { 546, -0.45, -0.33, 0.56 }, // Intruder
    { 533, -0.45, -0.33, 0.56 }, // Feltzer
    { 496, -0.45, -0.37, 0.51 }, // Blista
    { 542, -0.45, -0.37, 0.51 }, // Clover
    { 589, -0.45, -0.31, 0.73 }, // Club
    { 565, -0.45, -0.25, 0.42 }, // Flash
    { 587, -0.45, -0.38, 0.44 }, // Euros
    { 412, -0.45, -0.27, 0.44 }, // Voodoo
    { 439, -0.45, -0.47, 0.45 }, // Stallion
    { 534, -0.50,  -0.2, 0.42 }, // Remington
    { 602, -0.45, -0.25, 0.40 }, // Alpha
    { 536, -0.45, -0.25, 0.42 }, // Blade
    { 475, -0.45, -0.25, 0.44 }, // Sabre
    { 436, -0.34, -0.35, 0.52 }, // Previon
    { 585, -0.45, -0.26, 0.66 }, // Emperor
    { 600, -0.45, -0.18, 0.51 }, // Picador
    { 421, -0.38, -0.07, 0.45 }, // Washington
    { 580, -0.45, -0.26, 0.69 }, // Stafford
    { 458, -0.45, -0.12, 0.43 }, // Solair
    { 561, -0.37, -0.08, 0.52 }, // Stratum
    { 517, -0.45, -0.26, 0.54 }, // Majestic
    { 526, -0.40, -0.25, 0.37 }, // Fortune
    { 576, -0.35, -0.30, 0.58 }, // Tornado
    { 579, -0.45, -0.33, 0.85 }, // Huntley
    { 558, -0.37, -0.34, 0.59 }, // Uranus
    { 603, -0.47, -0.44, 0.35 }, // Phoenix
    { 560, -0.37, -0.20, 0.58 }, // Sultan
    { 559, -0.40, -0.40, 0.50 }, // Jester
    { 506, -0.39, -0.43, 0.37 }, // Super GT
    { 562, -0.36, -0.34, 0.53 }, // Elegy
    { 477, -0.40, -0.35, 0.47 }, // ZR-350
    { 402, -0.44, -0.49, 0.50 }, // Buffalo
    { 415, -0.36, -0.32, 0.32 }, // Cheetah
    { 451, -0.36, -0.32, 0.32 }, // Turismo
    { 541, -0.36, -0.20, 0.40 }, // Bullet
    { 429, -0.40, -0.65, 0.45 }, // Banshee
    { 411, -0.39, -0.21, 0.40 } //  Infernus
};
Then just add this to your OnPlayerStateChange or copy the whole function as you need:

pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( IsPlayerNPC( playerid ) ) return 1;
   
    switch( newstate )
    {
        case PLAYER_STATE_DRIVER:
        {
            new Float:x, Float:y, Float:z, vehicleid = GetPlayerVehicleID(playerid), vehmodel = GetVehicleModel(vehicleid), bool:found;
       
            for( new i;i<sizeof(DashBoards);i++ )
            {
                if( vehmodel == DashBoards[i][modelid] )
                {
                    x = DashBoards[i][cam_x];
                    y = DashBoards[i][cam_y];
                    z = DashBoards[i][cam_z];
                    found = true;
                    break;
                }
            }
           
            if( found )
            {
                Player[playerid][camobj] = CreateObject(19254,x,y,z,0.0,0.0,0.0,200.0);
                AttachObjectToVehicle( Player[playerid][camobj], vehicleid, x,y,z, 0, 0, 0);
                AttachCameraToObject(playerid, Player[playerid][camobj]);
            }
        }
        case PLAYER_STATE_ONFOOT:
        {
            if(IsValidObject( Player[playerid][camobj] ) )
            {
                SetCameraBehindPlayer( playerid );
                DestroyObject( Player[playerid][camobj] );
            }
        }
    }
   
    return 1;
}
And you're done!

Pics:

http://i.imgur.com/HYCk9.jpg
http://i.imgur.com/B9KV1.jpg
http://i.imgur.com/NTIe0.jpg

If you want it wth a command only:

pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( IsPlayerNPC( playerid ) ) return 1;
   
    switch( newstate )
    {      
        case PLAYER_STATE_ONFOOT:
        {
            if(IsValidObject( Player[playerid][camobj] ) )
            {
                SetCameraBehindPlayer( playerid );
                DestroyObject( Player[playerid][camobj] );
            }
        }
    }
   
    return 1;
}
Inside public OnPlayerCommandText(playerid,cmdtext[])

pawn Код:
if(!strcmp(cmdtext,"/dashboard",true) )
{
    new Float:x, Float:y, Float:z, vehicleid = GetPlayerVehicleID(playerid), vehmodel = GetVehicleModel(vehicleid), bool:found;

    for( new i;i<sizeof(DashBoards);i++ )
    {
        if( vehmodel == DashBoards[i][modelid] )
        {
            x = DashBoards[i][cam_x];
            y = DashBoards[i][cam_y];
            z = DashBoards[i][cam_z];
            found = true;
            break;
        }
    }
   
    if( found )
    {
        Player[playerid][camobj] = CreateObject(19254,x,y,z,0.0,0.0,0.0,200.0);
        AttachObjectToVehicle( Player[playerid][camobj], vehicleid, x,y,z, 0, 0, 0);
        AttachCameraToObject(playerid, Player[playerid][camobj]);
    }
   
    return 1;
}
Edit: I forgot to paste some code. Added now!


Re: Dashboards! - NAPSTER21 - 08.03.2012

can you pm when you have finished this

ive been trying to find something like this for ages

i like the idea of when every player enters a vehicle it auto puts them inside to make it look more like real life

if you finish all the vehicles pm me and then ill download and rep you

thanks


Re: Dashboards! - Scrillex - 09.03.2012

Gj probably I will use this Thanks for shearing .. I will add your credits


Re: Dashboards! - T0pAz - 09.03.2012

The code looks fine. Post few videos.


Re: Dashboards! - Gamer_Z - 09.03.2012

if you rotate the object, will the camera rotate too?


Re: Dashboards! - 2Kg Siika - 10.03.2012

Dude, that looks awesome! when can we dl it somewhere?


Re: Dashboards! - clavador - 10.03.2012

Quote:
Originally Posted by 2Kg Siika
Посмотреть сообщение
Dude, that looks awesome! when can we dl it somewhere?
The code is pasted in the first post. You have to add it to your gamemode/filterscript.

I didn't make a file because maybe you want to just display the camera with a command, etc...

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
if you rotate the object, will the camera rotate too?
Nope.

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
The code looks fine. Post few videos.
I'll try. I had a video but didn't have time to upload it that day, so I deleted it.

I'll record another one.

There are another FS that uses 1st person view inside cars, but they just center the camera in the player's head. Didn't try them, but seeing some videos I prefer this one that centers the camera for each vehicle on the list (I tried to make so if you look around you won't see parts of the car turning invisible, although I couldn't accomplish that will all the cars)


Re: Dashboards! - 2Kg Siika - 11.03.2012

Idk how to put codes on gamemode/filterscript, can you do it for me?


Re: Dashboards! - _DownLoaD_ - 11.03.2012

Simple: http://pastebin.com/FqDfkRV9


Re: Dashboards! - 2Kg Siika - 11.03.2012

Its 0.3e? ;s