Random with Names
#1

Okay Im taking this code as an example of what I want to do. I want to create an array with that have "Location" in it also. So for example I could use

PHP код:
new Float:SomethingRandom[][4] =
{
    {-
2796.98541224.818020.5429192.0335"Spawn 1"},
    {-
2454.2170503.875930.0790267.2932,"Spawn 2"},
    {-
2669.7322, -6.08746.132889.8853,"Spawn 3"}
}; 
Now how do I use this?
I know how to use coordinates from it, but not the name
Reply
#2

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 representation, 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 to how many spawns available: 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.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)