Need your help
#1

Hello samp forum.

I have created this /enter & /exit command. There's two shops, there goes to the same place.

Here's the code

Код:
CMD:enter(playerid, params[])
{
	  if(IsPlayerInRangeOfPoint(playerid, 3.0, 1553.779052, -1675.300048, 16.195312))
		{
      SetPlayerPos(playerid, 246.6695, 65.8039, 1003.6406);//PD
      SetPlayerInterior(playerid, 6);
      }
      if(IsPlayerInRangeOfPoint(playerid, 3.0, 1929.604980, -1776.355957, 13.546875))
		{
	  	  SetPlayerPos(playerid, -25.7220, -187.8216, 1003.5469);//Shop1
	  	  SetPlayerInterior(playerid, 17);
		}
      if(IsPlayerInRangeOfPoint(playerid, 3.0, 2423.711181, -1742.248657, 13.546875))
		{
			SetPlayerPos(playerid, -25.7220, -187.8216, 1003.5469);//Shop2
  			SetPlayerInterior(playerid, 17);
	  }
	  return 1;
}

CMD:exit(playerid, params[])
{
	  if(IsPlayerInRangeOfPoint(playerid, 3.0, 246.6695, 65.8039, 1003.6406))
		{
      SetPlayerPos(playerid, 1553.779052, -1675.300048, 16.195312);//PD
      SetPlayerInterior(playerid, 0);
      }
      if(IsPlayerInRangeOfPoint(playerid, 3.0, -25.7220, -187.8216, 1003.5469))
		{
		    SetPlayerPos(playerid, 1929.604980, -1776.355957, 13.546875);//Shop1
		    SetPlayerInterior(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 3.0, -25.7220, -187.8216, 1003.5469))
		{
		    SetPlayerInterior(playerid, 0);
		    SetPlayerPos(playerid, 2423.711181, -1742.248657, 13.546875);//Shop2
	  }
	  return 1;
}
Is there anyway. I can make it so, it remeber the players last position?

Thanks for the help
Reply
#2

PHP код:
new Float:lastPos[3];
CMD:enter(playeridparams[])
{
    if(
IsPlayerInRangeOfPoint(playerid3.01553.779052, -1675.30004816.195312))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerPos(playerid246.669565.80391003.6406);//PD
        
SetPlayerInterior(playerid6);
    }
    else if(
IsPlayerInRangeOfPoint(playerid3.01929.604980, -1776.35595713.546875))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerPos(playerid, -25.7220, -187.82161003.5469);//Shop1
        
SetPlayerInterior(playerid17);
    }
    else if(
IsPlayerInRangeOfPoint(playerid3.02423.711181, -1742.24865713.546875))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerPos(playerid, -25.7220, -187.82161003.5469);//Shop2
        
SetPlayerInterior(playerid17);
    }
    return 
1;
}
CMD:exit(playeridparams[])
{
    if(
IsPlayerInRangeOfPoint(playerid3.0246.669565.80391003.6406))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerPos(playerid1553.779052, -1675.30004816.195312);//PD
        
SetPlayerInterior(playerid0);
    }
    else if(
IsPlayerInRangeOfPoint(playerid3.0, -25.7220, -187.82161003.5469))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerPos(playerid1929.604980, -1776.35595713.546875);//Shop1
        
SetPlayerInterior(playerid0);
    }
    else if(
IsPlayerInRangeOfPoint(playerid3.0, -25.7220, -187.82161003.5469))
    {
        
GetPlayerPos(playeridlastPos[0], lastPos[1], lastPos[2]);
        
SetPlayerInterior(playerid0);
        
SetPlayerPos(playerid2423.711181, -1742.24865713.546875);//Shop2
    
}
    return 
1;

Reply
#3

Hi, i try'ed it. Still the same. When i exit Shop1. I'll spawn outside Shop2

But thanks for your reply
Reply
#4

Thats pretty weird, sure that the mistake doesn't lie somehwere else? maybe in this
PHP код:
public OnPlayerInteriorChange(playeridnewinterioridoldinteriorid
i didnt change the cords just showed u how to get last player pos , changed the 2 last if to else if
Reply
#5

It's because you aren't tracking which shop the player is in when they are entering, yet using the same exit coords for the shops.

The gl_property FS will show an example of how to do this.

It uses
PHP код:
currentInt[playerid] = propId
to track which property they are in once they are put in.
Reply
#6

Can you show me a example?

Thanks for the help btw
Reply
#7

If you look in the filterscripts folder, gl_property.pwn is the example.

The enter/exit commands, and the usage of the currentInt array.

I've changed your original code to suit this addition.

Код:
new currentInt[MAX_PLAYERS]; // Put this up top of your script.

CMD:enter(playerid, params[])
{
	  if(IsPlayerInRangeOfPoint(playerid, 3.0, 1553.779052, -1675.300048, 16.195312))
		{
      SetPlayerPos(playerid, 246.6695, 65.8039, 1003.6406);//PD
      SetPlayerInterior(playerid, 6);
	  currentInt[playerid]=1
      }
      if(IsPlayerInRangeOfPoint(playerid, 3.0, 1929.604980, -1776.355957, 13.546875))
		{
	  	  SetPlayerPos(playerid, -25.7220, -187.8216, 1003.5469);//Shop1
	  	  SetPlayerInterior(playerid, 17);
		  currentInt[playerid]=2
		}
      if(IsPlayerInRangeOfPoint(playerid, 3.0, 2423.711181, -1742.248657, 13.546875))
		{
			SetPlayerPos(playerid, -25.7220, -187.8216, 1003.5469);//Shop2
  			SetPlayerInterior(playerid, 17);
			currentInt[playerid]=3
	  }
	  return 1;
}

CMD:exit(playerid, params[])
{
	  if(IsPlayerInRangeOfPoint(playerid, 3.0, 246.6695, 65.8039, 1003.6406)&&currentInt[playerid]==1)
		{
      SetPlayerPos(playerid, 1553.779052, -1675.300048, 16.195312);//PD
      SetPlayerInterior(playerid, 0);
      }
      if(IsPlayerInRangeOfPoint(playerid, 3.0, -25.7220, -187.8216, 1003.5469)&&currentInt[playerid]==2)
		{
		    SetPlayerPos(playerid, 1929.604980, -1776.355957, 13.546875);//Shop1
		    SetPlayerInterior(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 3.0, -25.7220, -187.8216, 1003.5469)&&currentInt[playerid]==3)
		{
		    SetPlayerInterior(playerid, 0);
		    SetPlayerPos(playerid, 2423.711181, -1742.248657, 13.546875);//Shop2
	  }
	  currentInt[playerid] = 0;
	  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)