Making simple entries and exits [Using pickups] -
Vanter - 10.02.2014
What is this tutorial? Making simple entries and exits for buildings, ammu-nations, stores..etc
What's the key for it? Checkpoints, Virtual Worlds, Interiors, or Pickups.
What will we use? We're going to use dynamic pickups, if you don't have the streamer installed, just remove the ''Dynamic'' in every word in the script.
Here we go
We're going to create the entry and exit pickups, in this case, ammunation.
PHP Code:
new AmmuEnt1;
new AmmuExt1;
Then under OnGameModeInIt(), we're gonna define the creation of them.
PHP Code:
//This one is in Come-A-Lot in LV
AmmuEnt1 = CreateDynamicPickup(1317, 1, 2159.53, 943.20, 9.82, 0); //usally make the the Z axis, is -1, so the pickup is slightly up the ground.
Create3DTextLabel("Ammunation\nEnterance", 0xFF0000AA, 2159.53, 943.28, 10.82, 20.0, 0, 1); //3D Text Label to define the entrance.
AmmuExt1 = CreateDynamicPickup(1317, 1, 315.71, -143.66, 998.0, 1); //Ammu-nation exit to the world. the last ''1'' is the Virtual world. which we will be setting as our first virtual world.
//What is a virtual world? It's a world where only people assigned to it be able to see each other.
Now, we'll come to where's the action of teleporting the player to the interior and virtual world we want.
PHP Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
if(pickupid == AmmuEnt1) //incase of Ammunation entry.
{
SetPlayerInterior(playerid, 7); //which is the Ammu-nation Interior.
SetPlayerVirtualWorld(playerid, 1); //which is the first virtual world we create for players, if you want to make another ammu-nation, make sure the virtual world is 2, or any number not repeated.
SetPlayerPos(playerid, 315.24, -140.89, 999.60); // Coordinates in Ammu-Nation
SetPlayerFacingAngle(playerid, 0); // You can edit the player's facing angle whatever you like.
return 1;
}
if(pickupid == AmmuExt1) //Incase of the ammu-nation exit
{
SetPlayerInterior(playerid, 0); //Setting the player to interior 0, which is the world.
SetPlayerVirtualWorld(playerid, 0); //As usual, normal virtual worlds are always 0.
SetPlayerPos(playerid, 2154.62, 942.78, 10.82); //Setting the player position, which must be outside the ammu-nation.
SetPlayerFacingAngle(playerid, 90); //Setting player's facing angle.
return 1;
}
return 1;
}
Where can I get the interior IDs? https://sampwiki.blast.hk/wiki/InteriorIDs
Useful links:
3D Text Label Structure: https://sampwiki.blast.hk/wiki/Create3DTextLabel
I hope this helps you creating entrances and exits in your gamemode
Thank You,
Vanter
Re: Making simple entries and exits -
Vince - 10.02.2014
While this may work for a handful of entrances, it doesn't aid expandability. Imagine doing this for more than 30 buildings. You're simply going to end up with bloated code that'll be very hard to maintain.
Re: Making simple entries and exits -
Vanter - 12.02.2014
I might make a program/command with dialogs to create interiors and with automatic posting to script, so you have no work to do just, /createentry - choose which interior - choose a text label for enterance. and done.
Expect it anytime soon.