Array of pickup coordinates. -
Crayder - 15.11.2013
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);
}
}
Re: Array of pickup coordinates. -
Loot - 15.11.2013
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);
}
}
Re: Array of pickup coordinates. -
Crayder - 15.11.2013
Quote:
Originally Posted by Loot
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...
Re: Array of pickup coordinates. -
Crayder - 15.11.2013
Quote:
Originally Posted by Loot
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!)
Re: Array of pickup coordinates. -
Loot - 15.11.2013
I know that's the exact thing... But does it works? I was hoping to fix your code, not to teach you new stuff.
Re: Array of pickup coordinates. -
Threshold - 15.11.2013
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.
Re: Array of pickup coordinates. -
Crayder - 15.11.2013
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...)
Re: Array of pickup coordinates. -
Pottus - 15.11.2013
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];
Re: Array of pickup coordinates. -
Jefff - 15.11.2013
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
}
Re: Array of pickup coordinates. -
Threshold - 16.11.2013
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 -_-