setting boundaries
#1

so i searched a little bit but i couldn't find anything that would make me understand on how to exactly set boundaries

i've made this

Код:
//At The Top Of The Script:
new lossantos;

//Under OnGameModeInit
lossantos = GangZoneCreate(1945.708984, -1910.893676, 2673.708984, -1342.893676);

//Under OnPlayerSpawn:
GangZoneShowForPlayer(playerid, lossantos, -16777017);
how do i set boundaries, for example if people try to go out from this specific zone they will get that warning they cant get out
Reply
#2

You could try using the area natives that Incognito's streamer plugin provides (if you are already using it).

https://github.com/samp-incognito/sa...Natives-(Areas)
and
https://github.com/samp-incognito/sa...wiki/Callbacks

Use CreateDynamicRectangle to define the area of the map (if it's a rectangle shape) and then use the OnPlayerLeaveDynamicArea callback to tell the player what you want.
Reply
#3

There is also a function called SetPlayerWorldBounds

https://sampwiki.blast.hk/wiki/SetPlayerWorldBounds
Reply
#4

i tried this

Код:
public OnPlayerSpawn(playerid)
{
	switch( MapChange ) {
		case 0: {

		   new gMap1 = random( sizeof ( gMapSpawns1 ));

		   SetPlayerPos(playerid, gMapSpawns1[gMap1][0], gMapSpawns1[gMap1][1], gMapSpawns1[gMap1][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns1[gMap1][2]);
		   
		   GangZoneShowForPlayer(playerid, gLosSantos, -16777017);
		   
		   SetPlayerWorldBounds(playerid, 1945.708984, -1910.893676, 2673.708984, -1342.893676);
	   }
	   case 1: {
but doesn't matter where i'm at it says im out of bounds (this is the gangzone coords)
Reply
#5

The order of the arguments is a bit different. Try this:
pawn Код:
SetPlayerWorldBounds(playerid, 2673.708984, 1945.708984, -1342.893676, -1910.893676);
Reply
#6

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
The order of the arguments is a bit different. Try this:
pawn Код:
SetPlayerWorldBounds(playerid, 2673.708984, 1945.708984, -1342.893676, -1910.893676);
thanks,

how did u do it tho?

btw, when I do /respawn (simple cmd with SpawnPlayer(playerid); only, it respawns but it shows out of bounds and dissappears)
Reply
#7

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
thanks,

how did u do it tho?

btw, when I do /respawn (simple cmd with SpawnPlayer(playerid); only, it respawns but it shows out of bounds and dissappears)
Do you set the position in OnPlayerSpawn?

If so, the spawn data in AddPlayerClass can be different from where you set the player position to when they spawn.
So, for a few milliseconds you may actually be out of bounds.
Reply
#8

well heres my onplayerspawn the only positions are set are those

Код:
public OnPlayerSpawn(playerid)
{
	switch( MapChange ) {
		case 0: {

		   new gMap1 = random( sizeof ( gMapSpawns1 ));

		   SetPlayerPos(playerid, gMapSpawns1[gMap1][0], gMapSpawns1[gMap1][1], gMapSpawns1[gMap1][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns1[gMap1][2]);
		   
		   GangZoneShowForPlayer(playerid, gLosSantos, -16777017);
		   
		   SetPlayerWorldBounds(playerid, 2673.708984, 1945.708984, -1342.893676, -1910.893676);
	   }
	   case 1: {

	       new gMap2 = random( sizeof ( gMapSpawns2 ));

		   SetPlayerPos(playerid, gMapSpawns2[gMap2][0], gMapSpawns2[gMap2][1], gMapSpawns2[gMap2][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns2[gMap2][2]);
		   
	  }
      case 2: {

	       new gMap3 = random( sizeof ( gMapSpawns3 ));

		   SetPlayerPos(playerid, gMapSpawns3[gMap3][0], gMapSpawns3[gMap3][1], gMapSpawns3[gMap3][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns3[gMap3][2]);
	  }
   }
    return 1;
}
Reply
#9

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
well heres my onplayerspawn the only positions are set are those

Код:
public OnPlayerSpawn(playerid)
{
	switch( MapChange ) {
		case 0: {

		   new gMap1 = random( sizeof ( gMapSpawns1 ));

		   SetPlayerPos(playerid, gMapSpawns1[gMap1][0], gMapSpawns1[gMap1][1], gMapSpawns1[gMap1][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns1[gMap1][2]);
		   
		   GangZoneShowForPlayer(playerid, gLosSantos, -16777017);
		   
		   SetPlayerWorldBounds(playerid, 2673.708984, 1945.708984, -1342.893676, -1910.893676);
	   }
	   case 1: {

	       new gMap2 = random( sizeof ( gMapSpawns2 ));

		   SetPlayerPos(playerid, gMapSpawns2[gMap2][0], gMapSpawns2[gMap2][1], gMapSpawns2[gMap2][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns2[gMap2][2]);
		   
	  }
      case 2: {

	       new gMap3 = random( sizeof ( gMapSpawns3 ));

		   SetPlayerPos(playerid, gMapSpawns3[gMap3][0], gMapSpawns3[gMap3][1], gMapSpawns3[gMap3][2]);

		   SetPlayerFacingAngle(playerid, gMapSpawns3[gMap3][2]);
	  }
   }
    return 1;
}
Yes exactly that is causing it.

You need to adjust the coordinates in AddPlayerClass to somewhere inside the boundaries.

You can also use SetSpawnInfo to update Player spawning positions at any time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)