SA-MP Forums Archive
How to make a custom interior dynamic? - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make a custom interior dynamic? (/showthread.php?tid=399609)



How to make a custom interior dynamic? - EAsT-OAK_510 - 15.12.2012

Okay, I know the title sounds weird and I will explain.

I have mapped a custom prison interior for my server. I have three different department buildings set for my prison, one for general population, one for juveniles and the other for isolation. I have the coords for the entrances for the prison cells, cafeteria, hallway and laundry room. I just want to use the interior separately for each department. Can someone help me out?


Re: How to make a custom interior dynamic? - FTLOG - 15.12.2012

What i do with my dynamic interior system is a bit more complicated than you need, but i'll try to make this as simple as i can.

I usually do it with enums. Like this:

Код:
enum prison_Interiors{ Float:entrance_Coords[ 3 ], Float:interior_Coords[ 3 ], interior_ID, virtual_World };

static const
        prison_Positions[ NUMBER_OF_PRISON_POSITIONS ][ prison_Interiors ] = {

        {{ Entrance_X, Entrance_Y, Entrance_Z }}, {{ Exit_X, Exit_Y, Exit_Z }}, Interior, Virtual World }, // Replace   this with coordinates, and then add positions just down here. NUMBER_OF_PRISON_INTERIORS must be the amount of lines here, you know that probably.

};

// Then you can use this example very easy, like the example below

for( new i = 0; i < sizeof( prison_Positions ); ++i ) {

     if( IsPlayerInRangeOfPoint( playerid, 5.0, prison_Positions[ i ][ entrance_Coords ][ 0 ], prison_Positions[ i ][ entrance_Coords ][ 1 ], prison_Positions[ i ][ entrance_Coords ][ 2 ] )) {

          SetPlayerPos( playerid, prison_Positions[ i ][ interiors_Coords ][ 0 ], prison_Positions[ i ][ interiors_Coords ][ 1 ], prison_Positions[ i ][ interiors_Coords ][ 2 ] );
          SetPlayerInterior( playerid, interior_Positions[ i ][ interior_ID ] );
          SetPlayerVirtualWorld( playerid, interior_Positions[ i ][ virtual_World ] );

          return true;
     }
}

// This will check if the player is in the entrance coords, put him to te interior coords, set interior id and virtual world.
// And you can do the reverse process to put the player back to entrance coords
Like i said, it's not one the easiest methods, but it's great if you are planning to add more interiors.