Run into a Wall..
#1

Hello, Today i Would like to Know..

How i can run at a wall and it teleports me to somewhere else??

Like just say theres a door, i run into it, and it teleports me to a desired location?

Is it possible? Thanks


[LvC]Lucifier

Reply
#2

You could use this

Quote:

GetXYInFrontOfPlayer(playerid, &Float, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}

And this?

Quote:

new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
SetPlayerPos(playerid, x, y, z);

Im not sure
Reply
#3

Use https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint to check if the player is close enough and if they are then tele them .
Reply
#4

Try using PlayerToPoint by adding this function to your script
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
then adding the actual function
Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
Use it like so:
Код:
if(PlayerToPoint(20, i,1133.0699,-9.5731,1000.6797))
{//Restaurant Entrance
  GameTextForPlayer(i, "~Y~Restaurant, 5000, 1);
  SetPlayerInterior(i, 4);
  SetPlayerPos(i,1022.599975,-1123.699951,23.799999);
}
Reply
#5

IsPlayerInRangeOfPoint would be alot quicker
Reply
#6

Thank You So Much Guys!
Your Are The best!
Here, You can All have a Cookie ^^

* [LvC]Lucifier Hands Everyone a HUGE Cookie

Reply
#7

Код:
 if(IsPlayerInRangeOfPoint(playerid, 5.0, WALL COORD X, WALL COORD Y, WALL COORD Z)) 
        {
        SetPlayerPos(playerid,TELEPORT X,TELEPORT Y,TELEPORT Z);
        }
The "WALL COORD #" is the coordinates for the wall that you want to tele from.
The "TELEPORT #" is the coordinates that you want to tele to.
Reply
#8

Quote:
Originally Posted by jameskmonger
Код:
 if(IsPlayerInRangeOfPoint(playerid, 5.0, WALL COORD X, WALL COORD Y, WALL COORD Z)) 
        {
        SetPlayerPos(playerid,TELEPORT X,TELEPORT Y,TELEPORT Z);
        }
The "WALL COORD #" is the coordinates for the wall that you want to tele from.
The "TELEPORT #" is the coordinates that you want to tele to.
Thanks lol Where would i put that in my script?? :P
Cause i dont want it to be a command x]
Reply
#9

Most likely in OnPlayerStateChange. Not too sure, I've never used IsPlayerInRangeOfPoint.
Try this:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_ONFOOT)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 5.0, WALL COORD X, WALL COORD Y, WALL COORD Z))
		{
		  SetPlayerPos(playerid,TELEPORT X,TELEPORT Y,TELEPORT Z);
		}
Let me know if it works for ya
Reply
#10

Quote:
Originally Posted by SuperS82
Most likely in OnPlayerStateChange. Not too sure, I've never used IsPlayerInRangeOfPoint.
Try this:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_ONFOOT)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 5.0, WALL COORD X, WALL COORD Y, WALL COORD Z))
		{
		  SetPlayerPos(playerid,TELEPORT X,TELEPORT Y,TELEPORT Z);
		}
It Does Not Work

Let me know if it works for ya
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)