SA-MP Forums Archive
How to spawn from the air when teleporting - 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 spawn from the air when teleporting (/showthread.php?tid=420465)



How to spawn from the air when teleporting - Tommeh - 05.03.2013

I have this command called /fly which is exactly the same as i /goto. However whenever you teleport to the person, I want it to where you spawn from the sky with a parachute. How would i make that in my code?

Код:
	COMMAND:fly(playerid, params[])
	{
		new pname[MAX_PLAYER_NAME];
		new id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
		if(sscanf(params,"u",id)) SendClientMessage(playerid, COLOR_ORANGE, "/fly <id>"); /*Takes the ID you entered and makes it the "id" we defined. If no ID is entered the error message shows up*/
		{
			if(playerid == id) return SendClientMessage(playerid, COLOR_RED, "You can't teleport to yourself..."); /*Checks if the player id entered is not yours and if it is it shows the error message*/
   			else
			{
				if(!IsPlayerConnected(id)) SendClientMessage(playerid, COLOR_WHITE, "Player is Not Online"); /*Checks if the ID entered is a player that is online in the server, otherwise sends the error message*/
				else
				{
					new Float:x,Float:y,Float:z; //Defines the x,y, and z co-ordinates of the target player
					GetPlayerPos(id,Float:x,Float:y,Float:z);//Sets what the x,y, and z means
					GetPlayerName(id,pname,sizeof(pname)); //Gets the name of the player that is to be teleported to
					SetPlayerPos(playerid,x,y,z);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
				}
			}
		}

		return 1;
		}



Re: How to spawn from the air when teleporting - zDevon - 05.03.2013

Add to the Z coordinate when teleporting,
pawn Код:
SetPlayerPos(playerid,x,y,z+100);
100 being whatever height you want, then give them a parachute with https://sampwiki.blast.hk/wiki/GivePlayerWeapon and use https://sampwiki.blast.hk/wiki/SetPlayerArmedWeapon to make sure the skydiving animation starts.


Re: How to spawn from the air when teleporting - Tommeh - 05.03.2013

Thanks bro!!