What is wrong ?
#1

Код:
//Player Spawns
new Float:PlayerRandomSpawn[][5] =
{
	{365.07, 2538.79, 18.98}, //Spawn Abandoned Airport
    {1389.27, -2430.39, 16.028}, //Spawn Los Santos Airport
    {1608.89, 1173.59, 14.22}, //Spawn Las Venturas Airport
    {-1243.30, 176.50, 16.63} //Spawn San Fierro Airport
};


public OnPlayerSpawn(playerid)
{
	new Random = random(sizeof(PlayerRandomSpawn));
    SetPlayerPos(playerid, PlayerRandomSpawn[Random][0], PlayerRandomSpawn[Random][1], PlayerRandomSpawn[Random][2], PlayerRandomSpawn[Random][3], PlayerRandomSpawn[Random][4]);
	return 1;
}
It Shows me a Warning but i dont know why
warning 202: number of arguments does not match definition

Reply
#2

I'm rather surprised it doesn't complain about array out of bounds. This is completely wrong.
SetPlayerPos takes only 4 parameters, you have 6. Then you go out of the bounds of your array by accessing indices 3 and 4 even though you can only access 0, 1 and 2.
Reply
#3

Ok Thanks
Reply
#4

Код:
SetPlayerPos(playerid, PlayerRandomSpawn[Random][0], PlayerRandomSpawn[Random][1], PlayerRandomSpawn[Random][2], PlayerRandomSpawn[Random][3], PlayerRandomSpawn[Random][4]);
Replace with
Код:
SetPlayerPos(playerid, PlayerRandomSpawn[Random][0], PlayerRandomSpawn[Random][1], PlayerRandomSpawn[Random][2]);
EDIT: Didn't see Vince's post, sorry
Reply
#5

Quote:

Then you go out of the bounds of your array by accessing indices 3 and 4 even though you can only access 0, 1 and 2.

Can I ask, how can he not access indices 3 & 4?

This isn't a dig or anything, I genuinely want to understand what you mean? or what it means, rather.

@Vince.
Reply
#6

EDIT: Yay, 2000th post

pawn Код:
new Float:PlayerRandomSpawn[][5] =
{

//   (Level 0) - {365.07, 2538.79, 18.98}, //Spawn Abandoned Airport
//   (Index)   -    0       ,   1      ,     2

//   (Level 1) - {1389.27, -2430.39, 16.028}, //Spawn Los Santos Airport
//   (Index)   -    0       ,   1      ,     2
   
};
Level corresponds to the 1D index and then 0, 1 and 2 per level.

There are 0, 1, 2, 3 levels, but there's no 3 & 4 index inside the level.


So,

This is valid -
pawn Код:
PlayerRandomSpawn[3][0]
but this is invalid -
pawn Код:
PlayerRandomSpawn[3][3]
Read this guide for more information! - https://sampforum.blast.hk/showthread.php?tid=318212
Reply
#7

I truly appreciate that, reading through now!

Thanks! <3
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)