Random with Names
#3

Quote:
Originally Posted by RoboN1X
Посмотреть сообщение
You have to declare more size as String is an array (you are making an array inside an array that get an array).

I mean,
Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335, "Spawn 1"},
this do like (just example, not to be used):
Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335, 'S', 'p', 'a', 'w', 'n', ' ', '1'},
so the size is not 4, but 11.

Use enumerator
Код:
enum E_SPAWNS
{
	Float:SpawnX,
	Float:SpawnY,
	Float:SpawnZ,
	Float:SpawnA,
	SpawnName[16], // Change 16 to the maximum number of Spawn Name length
}

new Spawn[][E_SPAWNS] =
{
    {-2796.9854, 1224.8180, 20.5429, 192.0335, "Spawn 1"},
    {-2454.2170, 503.8759, 30.0790, 267.2932,"Spawn 2"},
    {-2669.7322, -6.0874, 6.1328, 89.8853,"Spawn 3"}
};
Then how will you use is this (for example random):
Код:
new rdm = random(sizeof(Spawn)); // you better have set the size new Spawn[3][E_SPAWNS] ^
// rdm will get the random array index (so it can be spawn 1, 2, or 3)
SetPlayerPos(playerid, Spawn[rdm][SpawnX], Spawn[rdm][SpawnY], Spawn[rdm][SpawnZ]); // set pos on x y z
SetPlayerFacingAngle(playerid, Spawn[rdm][SpawnA]); // set facing angle on a
GameTextForPlayer(playerid, Spawn[rdm][SpawnName], 5000, 3); // game text the spawn name
Hope you understands.
Ahhhhhhhhhh thank you!
Reply


Messages In This Thread
Random with Names - by Squirrel - 20.01.2016, 16:30
Re: Random with Names - by RoboN1X - 20.01.2016, 17:12
Re: Random with Names - by Squirrel - 20.01.2016, 17:14

Forum Jump:


Users browsing this thread: 1 Guest(s)