[Tutorial] Quick interior doors
#1

Hello guys. This is my second tutorial called quick interior doors.

In this tutorial I'm going to teach you how to script quick doors that require 1 neccessary function and 1 optional function.

Step 1)
Importing the functions.

In the first step, we are adding the function that will allow you to add as many doors as you want:

PHP Code:
stock InteriorDoor(playeridFloat:xFloat:zFloat:yFloat:x2Float:z2Float:y2Float:anglevwidinteriorid)
{
    if(
IsPlayerInRangeOfPoint(playeridINTERIOR_ENTEREXIT_RANGEFloat:xFloat:zFloat:y))
    {
        
SetPlayerVirtualWorld(playeridvwid);
        
SetPlayerInterior(playeridinteriorid);
        
SetPlayerPos(playeridFloat:x2Float:z2Float:y2);
        
SetPlayerFacingAngle(playeridFloat:angle);
        
SetCameraBehindPlayer(playerid);
        
loadingobj(playerid);
    }
    return 
1;

As you can see, we have X, Y, Z and X2, Y2, Z2.
The X, Y, Z is the entrance and the X2, Y2, Z2 is the finishing position.
We also have the angle, virtual world ID and interior ID.
SetCameraBehindPlayer sets the camera behind the player obviously.
Now we add the optional loadingobj(playerid) function. It will freeze you for 2 seconds and display some gametexts.

Here it is:

PHP Code:
stock loadingobj(playerid)
{
        
TogglePlayerControllable(playerid0);
    
GameTextForPlayer(playerid"~r~LOADING OBJECTS..."20003);
    
SetTimerEx("loadingobjects"2000false"i"playerid);

And the timer:

PHP Code:
forward loadingobjects(playerid);
public 
loadingobjects(playerid)
{
    
TogglePlayerControllable(playerid1);
    
GameTextForPlayer(playerid"~g~OBJECTS LOADED!"20003);

You can change the gametext however you want. Now after we all got that all set up, we can finally add our interiors.

Step 2)
Adding the interiors.

Define PRESSED:

PHP Code:
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) 
Under OnPlayerKeyStateChange, add the key that you want to enter/exit your interiors with. You can learn more about keys here. I personally use Y to enter or exit interiors:

PHP Code:
if(PRESSEDKEY_YES ))
{
    
InteriorDoor(playerid1259.0759,-785.4166,92.03021262.2357,-785.3707,1091.9063270.0000695); // back door entrance
        
InteriorDoor(playerid1261.2383,-785.3589,1091.90631256.9819,-785.3765,92.030290.000000); // back door exit

As you can see above, I added a custom interior that will allow us to enter and exit Madd Dogg's mansion from the back door. The entrance is at 1259.0759,-785.4166,92.0302, and it will get us to: 1262.2357,-785.3707,1091.9063. The facing angle the player is going to face is: 270.0000. The virtual world will be 69 and the interior will be 5.
The exit is at 1261.2383,-785.3589,1091.9063 and it will get us to: 1256.9819,-785.3765,92.0302. It will also set our facing angle to 90.0000, our virtual world to 0 and our interior to 0.
You can also define your virtual world and interior so you can use them later like so:

PHP Code:
#define MADDDOGG_INT 5
#define MADDDOGG_VW 69 
and then it will be:

PHP Code:
InteriorDoor(playerid1259.0759,-785.4166,92.03021262.2357,-785.3707,1091.9063270.0000MADDDOGG_VWMADDDOGG_INT);
InteriorDoor(playerid1261.2383,-785.3589,1091.90631256.9819,-785.3765,92.030290.000000); 
Step 3)
Adding some pickups and 3D labels.

Add this under OnGameModeInit or under your custom pickup/label loading function:

PHP Code:
CreatePickup(125411259.0759,-785.4166,92.0302, -1); // madd dogg back door
CreatePickup(131811261.2383,-785.3589,1091.9063, -1); // boss house back exit
Create3DTextLabel("Back door"COLORNOTIF1261.2383,-785.3589,1091.906315.0BOSS_VW1); // madd dogg back exit
Create3DTextLabel("Madd Dogg's mansion\nBack door"COLORNOTIF1259.0759,-785.4166,92.030215.001); // madd dogg back door entrance 
You can change the pickupid, coordinates, color, text, etc. how you want. This is just an example for Madd Dogg's mansion back door.

That's pretty much it. I hope you guys like it!
Reply
#2

I don't want to be mean, but I think you should have a look here https://sampforum.blast.hk/showthread.php?tid=570981 and here https://sampforum.blast.hk/showthread.php?tid=570635.
Reply
#3

Quote:
Originally Posted by GoldenLion
View Post
I don't want to be mean, but I think you should have a look here https://sampforum.blast.hk/showthread.php?tid=570981 and here https://sampforum.blast.hk/showthread.php?tid=570635.
I think I have explained this well, mate...
And thanks for that stock explanation!
Reply
#4

Quote:
Originally Posted by iamjems
View Post
I think I have explained this well, mate...
And thanks for that stock explanation!
It's not that bad, but you just could explain more. :P
Also I see you removed these "stock function" things, you should also remove the stock keyword from the functions, because it's not needed.
Reply
#5

Quote:
Originally Posted by GoldenLion
View Post
It's not that bad, but you just could explain more. :P
Also I see you removed these "stock function" things, you should also remove the stock keyword from the functions, because it's not needed.
Updated
Reply
#6

Well, you can enter interiors by default if you don't use this:
Code:
DisableInteriorEnterExits();
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)