Array of pickup coordinates.
#1

Well, I am making buy-able spawns for my RP server... I have an array of their coordinates...
Just for example this is what it looks like.

pawn Code:
enum SpawnInfo {X, Y, Z, R}
new Float:BoughtSpawns[][SpawnInfo] =
{
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781)
};
new BS[(sizeof(BoughtSpawns)];
On OnGamemodeInit(), I have...

pawn Code:
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
    BS[i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][X], BoughtSpawns[i][Y], BoughtSpawns[i][Z]);
}
This doesn't create these pickups... So what can I do...?









Also! How would I show this message when a player picks up any of these pickups...
Would this work?

pawn Code:
for(new o = -1; o < sizeof(BS); o++)
    {
        if(pickupid == o && IsValidDynamicPickup(o))
        {
            GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
        }
    }
Reply
#2

Why are you using both enum and floats when you can do all at once?
P.S I haven't tested that, so there might be an error.
pawn Code:
static Float:BoughtSpawns[11][3] =
{
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781)
};

public OnGameModeInit()
{
     for(new i = 0; i < sizeof(BoughtSpawns); i++)
     {
         BS[i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][0], BoughtSpawns[i][1], BoughtSpawns[i][2]);
     }
     return 1;
}

//pickups public
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
     if(IsValidDynamicPickup(i))
     {
          GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
     }
}
Reply
#3

Quote:
Originally Posted by Loot
View Post
Why are you using both enum and floats when you can do all at once?
P.S I haven't tested that, so there might be an error.
pawn Code:
static Float:BoughtSpawns[11][3] =
{
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781)
};

public OnGameModeInit()
{
     for(new i = 0; i < sizeof(BoughtSpawns); i++)
     {
         BS[i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][0], BoughtSpawns[i][1], BoughtSpawns[i][2]);
     }
     return 1;
}

//pickups public
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
     if(IsValidDynamicPickup(i))
     {
          GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
     }
}
Thats basically the same EXACT thing... Thanks anyway but, the enum is for replacing the number, well not replace but just take place as the numbers... So X = 0, Y = 1, and Z = 2... R is for my random spawns... They just make it easier for a noob scripter to understand, I am eventually releasing this, so im making it for beginners...
Reply
#4

Quote:
Originally Posted by Loot
View Post
Why are you using both enum and floats when you can do all at once?
P.S I haven't tested that, so there might be an error.
pawn Code:
static Float:BoughtSpawns[11][3] =
{
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781)
};

public OnGameModeInit()
{
     for(new i = 0; i < sizeof(BoughtSpawns); i++)
     {
         BS[i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][0], BoughtSpawns[i][1], BoughtSpawns[i][2]);
     }
     return 1;
}

//pickups public
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
     if(IsValidDynamicPickup(i))
     {
          GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
     }
}
Thats basically the same EXACT thing... Thanks anyway but, the enum is for replacing the number, well not replace but just take place as the numbers... So X = 0, Y = 1, and Z = 2... R is for my random spawns... They just make it easier for a noob scripter to understand, I am eventually releasing this, so im making it for beginners...

ALSO, you used an exact amount (the 11)... (Float:BoughtSpawns[11][3])
By using sizeof(), it automatically counts the array.

(I dont know why it double posted... I clicked EDIT POST!)
Reply
#5

I know that's the exact thing... But does it works? I was hoping to fix your code, not to teach you new stuff.
Reply
#6

pawn Code:
new Float:BoughtSpawns[][3] =
{
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781),
    (132.0000,  -67.2844,   3.5781)
};
new BS[sizeof(BoughtSpawns)];
pawn Code:
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
    BS[i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][0], BoughtSpawns[i][1], BoughtSpawns[i][2]);
}
Also:

pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 0; i < sizeof(BoughtSpawns); i++)
    {
        if(pickupid == BS[i])
        {
            GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
        }
    }
    return 1;
}
--

I haven't worked with these in a while, but give it a shot and see if it works.
Reply
#7

Niether of these work... They are all the same, therefore work the same way, in which that way is a non-working way... Thanks guys, but does someone else wanna give a shot at this, please...? (Yes, I've tested both of yours... , and thanks Loot, I'll Rep you for the commitment...)
Reply
#8

Of course this will not work...

pawn Code:
new BS[sizeof(BoughtSpawns)];
Want to know how I would do it....

pawn Code:
enum BSINFO
{
   bool:SpawnBought,
   SpawnPickupID,
   SpawnOwner[MAX_PLAYER_NAME],
   Float:SpawnX,
   Float:SpawnY,
   Float:SpawnZ,
}

static BoughtSpawns[][BSINFO];
Reply
#9

pawn Code:
enum SpawnInfo {
    Float:X,
    Float:Y,
    Float:Z
};
new BoughtSpawns[][SpawnInfo] =
{
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781},
    {132.0000,  -67.2844,   3.5781}
};
new BS[2];

pawn Code:
for(new i = 0; i < sizeof(BoughtSpawns); i++)
{
    BS[!!i] = CreateDynamicPickup(1313, 1, BoughtSpawns[i][X], BoughtSpawns[i][Y], BoughtSpawns[i][Z]);
}
pawn Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(BS[0] <= pickupid <= BS[1])
    {
        GameTextForPlayer(playerid, "~l~~h~DO ~g~/buyspawn ~l~~h~TO BUY THIS SPAWN!", 2000, 5);
        return 1;
    }
    return 0
}
Reply
#10

Urgh, forgot to remove that and edit it... the first code I gave was just with a removed bracket, other than that I forgot to actually edit it -_-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)