SA-MP Forums Archive
Run into a Wall.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Run into a Wall.. (/showthread.php?tid=121211)



Run into a Wall.. - TheNotorius - 16.01.2010

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




Re: Run into a Wall.. - Fedee! - 16.01.2010

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


Re: Run into a Wall.. - [HiC]TheKiller - 16.01.2010

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


Re: Run into a Wall.. - SuperS82 - 16.01.2010

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);
}



Re: Run into a Wall.. - V1ceC1ty - 16.01.2010

IsPlayerInRangeOfPoint would be alot quicker


Re: Run into a Wall.. - TheNotorius - 16.01.2010

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

* [LvC]Lucifier Hands Everyone a HUGE Cookie




Re: Run into a Wall.. - jameskmonger - 16.01.2010

Код:
 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.


Re: Run into a Wall.. - TheNotorius - 16.01.2010

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]


Re: Run into a Wall.. - SuperS82 - 16.01.2010

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


Re: Run into a Wall.. - TheNotorius - 17.01.2010

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