SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/02/2020, 02:05 PM   #11
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Are the data in `point_muerte` array correct? I am not sure how any distance returned by `GetPlayerDistanceFromPoint` function will be greater than 99999.0 to fail the if statement but I can tell you how to prevent the run time error.

pawn Code:
new id = is_player_spawn(playerid);
if (id != -1)
{
    set_pos(playerid, point_muerte[id][x_spawn], point_muerte[id][y_spawn], point_muerte[id][z_spawn], point_muerte[id][angle_spawn], 0, 0);
}
else
{
    // set a default spawn point in case it returns -1 again.
}
Code:
static const point_muerte[][spawn_point2] =
{
	{0,	0000.0000	, 0000.0000	 , 000.0000	, 0000.0000	,	"none_none"},		//
	/*  	X   -       Y   	 -   	Z	-     R     -	NAME  */
	{1,	1182.8849	, -1328.0951 , 13.5814	, 266.6024	,	"H. Market"},	// MARKET
	{2,	2012.3899	, -1434.3098 , 13.5558	, 151.8842	,	"H. Jefferson"},	// JEFFERSON
	{3,	2012.3899	, -1434.3098 , 13.5558	, 151.8842	,	"H. Jefferson"}	// JEFFERSON
};
data
murilo2929 is offline   Reply With Quote
Old 16/02/2020, 02:26 PM   #12
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Are the data in `point_muerte` array correct? I am not sure how any distance returned by `GetPlayerDistanceFromPoint` function will be greater than 99999.0 to fail the if statement but I can tell you how to prevent the run time error.

pawn Code:
new id = is_player_spawn(playerid);
if (id != -1)
{
    set_pos(playerid, point_muerte[id][x_spawn], point_muerte[id][y_spawn], point_muerte[id][z_spawn], point_muerte[id][angle_spawn], 0, 0);
}
else
{
    // set a default spawn point in case it returns -1 again.
}
so I put it the way you said it and the error didn't show up anymore, but it still gives the same problem inside the game, like it gets too slow and I can't move anything I can hear the sounds of the game and everything but that.

see how the game looks:
murilo2929 is offline   Reply With Quote
Old 16/02/2020, 03:30 PM   #13
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,085
Reputation: 174
Default Re: Error when die

Do you have at least one class in server (using `AddPlayerClass` function)? If not, you should add one in `OnGameModeInit` callback.

Your array has a duplicate, it does not use the first index for an unknown reason and uses an extra item for the index when you already know it.

pawn Code:
enum spawn_point2
{
    Float: x_spawn,
    Float: y_spawn,
    Float: z_spawn,
    Float: angle_spawn,
    name_spawn[21] // change this to the name and size you already have
};

static const point_muerte[][spawn_point2] =
{
/*
     X              Y               Z           R           NAME
*/

    {1182.8849,     -1328.0951,     13.5814,    266.6024,   "H. Market"},   // MARKET
    {2012.3899,     -1434.3098,     13.5558,    151.8842,   "H. Jefferson"} // JEFFERSON
};

is_player_spawn(playerid) // GetClosestSpawnPointForPlayer would be a better name
{
    new Float: distance = GetPlayerDistanceFromPoint(playerid, point_muerte[0][x_spawn], point_muerte[0][y_spawn], point_muerte[0][z_spawn]),
        Float: tmp_distance,
        closest;

    for (new i = 1; i < sizeof (point_muerte); i++)
    {
        tmp_distance = GetPlayerDistanceFromPoint(playerid, point_muerte[i][x_spawn], point_muerte[i][y_spawn], point_muerte[i][z_spawn]);

        if (tmp_distance < distance)
        {
            distance = tmp_distance;
            closest = i;
        }
    }
    return closest;
}

Now it will never return invalid array index and it will return 0 if the player is not connected.
__________________
Calisthenics is offline   Reply With Quote
Old 16/02/2020, 04:06 PM   #14
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Do you have at least one class in server (using `AddPlayerClass` function)? If not, you should add one in `OnGameModeInit` callback.

Your array has a duplicate, it does not use the first index for an unknown reason and uses an extra item for the index when you already know it.

pawn Code:
enum spawn_point2
{
    Float: x_spawn,
    Float: y_spawn,
    Float: z_spawn,
    Float: angle_spawn,
    name_spawn[21] // change this to the name and size you already have
};

static const point_muerte[][spawn_point2] =
{
/*
     X              Y               Z           R           NAME
*/

    {1182.8849,     -1328.0951,     13.5814,    266.6024,   "H. Market"},   // MARKET
    {2012.3899,     -1434.3098,     13.5558,    151.8842,   "H. Jefferson"} // JEFFERSON
};

is_player_spawn(playerid) // GetClosestSpawnPointForPlayer would be a better name
{
    new Float: distance = GetPlayerDistanceFromPoint(playerid, point_muerte[0][x_spawn], point_muerte[0][y_spawn], point_muerte[0][z_spawn]),
        Float: tmp_distance,
        closest;

    for (new i = 1; i < sizeof (point_muerte); i++)
    {
        tmp_distance = GetPlayerDistanceFromPoint(playerid, point_muerte[i][x_spawn], point_muerte[i][y_spawn], point_muerte[i][z_spawn]);

        if (tmp_distance < distance)
        {
            distance = tmp_distance;
            closest = i;
        }
    }
    return closest;
}

Now it will never return invalid array index and it will return 0 if the player is not connected.
Code:
static const point_muerte[][spawn_point2] =
{
	{0,	0000.0000	, 0000.0000	 , 000.0000	, 0000.0000	,	"none_none"},		//
	/*  	X   -       Y   	 -   	Z	-     R     -	NAME  */
	{1,	1182.8849	, -1328.0951 , 13.5814	, 266.6024	,	"H. Market"},	// MARKET
	{2,	2012.3899	, -1434.3098 , 13.5558	, 151.8842	,	"H. Jefferson"},	// JEFFERSON
	{3,	2012.3899	, -1434.3098 , 13.5558	, 151.8842	,	"H. Jefferson"}	// JEFFERSON
};

static const point_pf[][spawn_point3] =
{
	{0,	0000.0000	, 0000.0000	, 0000.0000	, 0000.0000	,	"none_none", 0},		//
	/*  	X   -       Y   	-   	Z	-     R     -	NAME  */
	{1,	281.8730, 1410.9673, 10.4947, 0000.0000, "exterior", 0},
	{2,	332.6335, 857.6257, 1001.8348, 0000.0000, "Bloque A", 41},              //listo
	{3,	322.5409, 849.2936, 1001.4407, 0000.0000, "bloque B", 42},
	{4,	299.8500, 792.6138, 1000.6696, 0000.0000, "Aislamiento", 43},           //listo
	{5,	321.0114, 845.2800, 1001.0607, 0000.0000, "Arsenal e int", 44},
	{6,	302.7928, 853.6814, 1001.3047, 0000.0000, "comedor", 45},
	{7,	339.4486, 842.1990, 1001.2888, 0000.0000, "Economato", 46},             //listo
	{8,	316.9902, 846.9445, 1001.2867, 0000.0000, "enfermería", 47},
	{9,	352.9106, 820.6122, 1001.3773, 0000.0000, "ingresos", 48},
	{10, 334.8763, 829.7776, 1001.2772, 0000.0000, "pasillo", 49},
	{11, 316.5503, 800.8280, 998.5923, 0000.0000, "piso 2", 50},
	{12, 331.7956, 811.5309, 1001.4646, 0000.0000, "recepción", 51},
	{13, 318.4765, 875.4935, 1001.1189, 0000.0000, "Oficina", 52},
	{14, 317.1117, 814.6857, 1001.2343, 0000.0000, "taquillas", 53},
	{15, 335.5027, 821.1790, 1001.1994, 0000.0000, "visitas", 54}
};

static const point_spawn[][spawn_point] =
{
	{0,	0000.0000	, 0000.0000	, 0000.0000	, 0000.0000	,	"none_none"},		//
	/*  	X   -       Y   	-   	Z	-     R     -	NAME  */
	{1,	2292.8088	, -1667.6168, 14.9521	, 316.0630	,	"Ganton"},
	{2,	2141.7285	, -1205.6992, 23.9883	, 323.2699	,	"Jefferson"},
	{3,	1514.3511	, -1281.0023, 14.5642	, 139.9915	,	"Downtown LS"},
	{4,	1808.7881	, -1938.6620, 13.5469	, 42.5674	,	"El courona"},
	{5,	2129.8027	, -1938.1482, 13.5469	, 34.3973	,	"Willowfield"},
	{6,	2111.3154	, 2098.2959	, 10.8203	, 208.2435	,	"As venturas"},	// LAS VENTURAS
	{7,	-2245.4099	, 245.1576	, 35.3203	, 111.4694	,	"San fierro"},		// SAN FIERRO
	{8,	1519.2094	, -1676.844	, 13.5469	, 268.6089	,	"Los santos"}		// LOS SANTOS
};
maybe because i have 3 static spawn_point?
murilo2929 is offline   Reply With Quote
Old 16/02/2020, 04:42 PM   #15
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Do you have at least one class in server (using `AddPlayerClass` function)? If not, you should add one in `OnGameModeInit` callback.

Your array has a duplicate, it does not use the first index for an unknown reason and uses an extra item for the index when you already know it.

pawn Code:
enum spawn_point2
{
    Float: x_spawn,
    Float: y_spawn,
    Float: z_spawn,
    Float: angle_spawn,
    name_spawn[21] // change this to the name and size you already have
};

static const point_muerte[][spawn_point2] =
{
/*
     X              Y               Z           R           NAME
*/

    {1182.8849,     -1328.0951,     13.5814,    266.6024,   "H. Market"},   // MARKET
    {2012.3899,     -1434.3098,     13.5558,    151.8842,   "H. Jefferson"} // JEFFERSON
};

is_player_spawn(playerid) // GetClosestSpawnPointForPlayer would be a better name
{
    new Float: distance = GetPlayerDistanceFromPoint(playerid, point_muerte[0][x_spawn], point_muerte[0][y_spawn], point_muerte[0][z_spawn]),
        Float: tmp_distance,
        closest;

    for (new i = 1; i < sizeof (point_muerte); i++)
    {
        tmp_distance = GetPlayerDistanceFromPoint(playerid, point_muerte[i][x_spawn], point_muerte[i][y_spawn], point_muerte[i][z_spawn]);

        if (tmp_distance < distance)
        {
            distance = tmp_distance;
            closest = i;
        }
    }
    return closest;
}

Now it will never return invalid array index and it will return 0 if the player is not connected.
guy thank you so much for your help he stopped freezing
murilo2929 is offline   Reply With Quote
Old 16/02/2020, 05:01 PM   #16
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Do you have at least one class in server (using `AddPlayerClass` function)? If not, you should add one in `OnGameModeInit` callback.

Your array has a duplicate, it does not use the first index for an unknown reason and uses an extra item for the index when you already know it.

pawn Code:
enum spawn_point2
{
    Float: x_spawn,
    Float: y_spawn,
    Float: z_spawn,
    Float: angle_spawn,
    name_spawn[21] // change this to the name and size you already have
};

static const point_muerte[][spawn_point2] =
{
/*
     X              Y               Z           R           NAME
*/

    {1182.8849,     -1328.0951,     13.5814,    266.6024,   "H. Market"},   // MARKET
    {2012.3899,     -1434.3098,     13.5558,    151.8842,   "H. Jefferson"} // JEFFERSON
};

is_player_spawn(playerid) // GetClosestSpawnPointForPlayer would be a better name
{
    new Float: distance = GetPlayerDistanceFromPoint(playerid, point_muerte[0][x_spawn], point_muerte[0][y_spawn], point_muerte[0][z_spawn]),
        Float: tmp_distance,
        closest;

    for (new i = 1; i < sizeof (point_muerte); i++)
    {
        tmp_distance = GetPlayerDistanceFromPoint(playerid, point_muerte[i][x_spawn], point_muerte[i][y_spawn], point_muerte[i][z_spawn]);

        if (tmp_distance < distance)
        {
            distance = tmp_distance;
            closest = i;
        }
    }
    return closest;
}

Now it will never return invalid array index and it will return 0 if the player is not connected.
"Do you have at least one class in server (using `AddPlayerClass` function)? If not, you should add one in `OnGameModeInit` callback."

i don't have a class using "AddPlayerClass" how can i add?
murilo2929 is offline   Reply With Quote
Old 16/02/2020, 06:56 PM   #17
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,085
Reputation: 174
Default Re: Error when die

Quote:
Originally Posted by murilo2929 View Post
i don't have a class using "AddPlayerClass" how can i add?
Not using any class and calling `SpawnPlayer` or exiting from spectating mode which automatically re-spawns the player may give the boundaries error and loading bug.

https://wiki.sa-mp.com/wiki/AddPlayerClass
__________________
Calisthenics is offline   Reply With Quote
Old 17/02/2020, 02:14 AM   #18
murilo2929
Huge Clucker
 
Join Date: Oct 2018
Posts: 216
Reputation: 2
Default Re: Error when die

Quote:
Originally Posted by Calisthenics View Post
Not using any class and calling `SpawnPlayer` or exiting from spectating mode which automatically re-spawns the player may give the boundaries error and loading bug.

https://wiki.sa-mp.com/wiki/AddPlayerClass
It's really necessary do that?
murilo2929 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 017: undefined symbol,fatal error 107: too many error messages on one line Slicebook Scripting Help 11 04/05/2014 08:30 PM
An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds.... rati555 Scripting Help 1 14/09/2012 07:45 PM
Registered plate stock error 'error 076: syntax error in the expression, or invalid function call' Deal-or-die Scripting Help 2 25/06/2012 03:12 PM
Error message: : error 030: compound statement not closed at the end of file (started at line 170) the_zohan Scripting Help 5 04/06/2012 08:38 AM
I get tagmismatch error, But i cant find any error error Swiftz Help Archive 1 16/04/2011 04:31 AM


All times are GMT. The time now is 07:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.