What is wrong ? - 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)
+--- Thread: What is wrong ? (
/showthread.php?tid=504639)
What is wrong ? -
Useryy - 05.04.2014
Код:
//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
Re: What is wrong ? -
Vince - 05.04.2014
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.
Re: What is wrong ? -
Useryy - 05.04.2014
Ok Thanks
Re: What is wrong ? -
CroM256 - 05.04.2014
Код:
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
Re: What is wrong ? -
Dokins - 05.04.2014
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.
Re: What is wrong ? -
RajatPawar - 05.04.2014
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 -
but this is invalid -
Read this guide for more information! -
https://sampforum.blast.hk/showthread.php?tid=318212
Re: What is wrong ? -
Dokins - 05.04.2014
I truly appreciate that, reading through now!
Thanks! <3