PDA

View Full Version : Pickup Teleports - Return To Location


Swiftyy
11/10/2013, 04:55 AM
Okay well, I have scripted up a pickup which teleports me to an interior and there is one problem.

So I am in the interior and when I exit, I get teleported to the ORIGINAL location.

This is my script: // This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

new ammu1;

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" My Teleports");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" SWIFT DRIFT");
print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
ammu1 = CreatePickup(1318,23,-2398.0510,-575.4337,132.3125);

return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if (pickupid == ammu1)
{
GameTextForPlayer(playerid,"~r~Ammunation", 6000,1);
SetPlayerPos(playerid, 286.800994,-82.547599,1001.515625);
SetPlayerInterior(playerid, 4);
}
return 1;
}



In this script I set up a teleport to Ammunation, and when I exit Ammunation I get sent to a different location then where I inserted the pickup.

If anyone could help, that'd be great! :)

Regards,
Swift.

Swiftyy
11/10/2013, 11:07 PM
Anyone?

xVIP3Rx
11/10/2013, 11:14 PM
You could use OnPlayerInteriorChange (http://wiki.sa-mp.com/wiki/OnPlayerInteriorChange) and teleport him to the location you want... If that want you want..

Swiftyy
11/10/2013, 11:17 PM
An example mate?

xVIP3Rx
11/10/2013, 11:36 PM
An example mate?


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
if(oldinteriorid == old interoior id) //Change old interior id
{
SetPlayerPos(playerid, X, Y, Z); // New position
}
return 1;
}
Replace the coords and the interior id..

Swiftyy
11/10/2013, 11:48 PM
Okay will test this out. Thanks mate.

Threshold
12/10/2013, 03:24 AM
That's not a very efficient way of doing it, because then each time you change interior, you have the chance of being teleported to the same location, even when you don't want to do so. First of all, add the following under OnGameModeInit()...

public OnGameModeInit()
{
DisableInteriorEnterExits();
return 1;
}

Then, you may need to add another pickup for the EXIT of ammunition. A better way would be to use a checkpoint system of some sort. I would recommend Incognito's Streamer plugin for such a method. Just make sure, when you enter the ammunation, that you are teleporting them away from the exit, so that when you enter, you're not spawning on top of the exit pickup. Same applies for when you exit and in vice versa.

Swiftyy
12/10/2013, 04:35 AM
thanks mate, I understand it. It should work, will test it now. :)

Also will this disable ALL other default interiors? e.g - 24/7s, bars, cluckin' bells, etc. ?

Tuntun
12/10/2013, 05:14 AM
It will be more easy if you make one more pickup in ammunition.. front of the exit door to exit. And set pos to out side.hope you understand.