Little help with random spawns
#1

Hey this is a very little question about random spawns.
I want 2 or more random spawns sections I mean this:

PHP код:
public OnPlayerSpawn(playerid)
{
    switch(
GetPlayerSkin(playerid))
    {
        case 
105,106,107,269,270,271:
            {
                 new 
rand random(sizeof(gRandomSpawns));
                 
SetPlayerPos(playeridgRandomSpawns[rand][0], gRandomSpawns[rand][1], gRandomSpawns[rand][2]);
                 
SetPlayerColor(playerid0x499C67FF);
         }
    }
    switch(
GetPlayerSkin(playerid))
    {
        case 
102,103,104:
            {
                 new 
rand random(sizeof(bRandomSpawns));
                 
SetPlayerPos(playeridbRandomSpawns[rand][0], bRandomSpawns[rand][1], bRandomSpawns[rand][2]);
         }
    }
    return 
1;

I think its wrong and it is!
I got one error namely:

PHP код:
C:\Users\Edward\Desktop\SA-MP Server Gangwars\pawno\GangWarsULv.03.pwn(348) : error 018initialization data exceeds declared size
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

Ty,
Reply
#2

Hmm anyone? I am really really bored about this, I work 3 days on this random spawns! because I didnt realy know how to make it, now i need only know how to fix this..
Reply
#3

The size of the array 2D is bigger than the value you've placed.
Reply
#4

I didnt see why it is bigger than the value ?
Reply
#5

show the code where you define the array called gRandomSpawns
Reply
#6

I didnt #define gRandomSpawns
Reply
#7

Not litterally #define, i ment the code where you create the array, like new Float: gRandomSpawns[?][?];
Reply
#8

Ohw here:

PHP код:
new Float:gRandomSpawns[4][3] =
{
    {
2509.3162,-1654.4011,13.6194},
    {
2511.2471,-1688.7179,13.5511},
    {
2471.9990,-1686.6086,13.5078},
    {
2509.3162,-1654.4011,13.6194}
};
new 
Float:bRandomSpawns[3][3] = //Ballas
{
    {
2140.7705,-1700.4626,15.0784},
    {
2146.6111,-1665.4973,15.0859},
    {
2144.3179,-1685.4233,15.0859},
}; 
Reply
#9

Remove the last comma in bRandomSpawns:

new Float:bRandomSpawns[3][3] = //Ballas
{
{2140.7705,-1700.4626,15.0784},
{2146.6111,-1665.4973,15.0859},
{2144.3179,-1685.4233,15.0859}, <- REMOVE
};

so you get:

new Float:bRandomSpawns[3][3] = //Ballas
{
{2140.7705,-1700.4626,15.0784},
{2146.6111,-1665.4973,15.0859},
{2144.3179,-1685.4233,15.0859}
};
Reply
#10

Cool it works!, thanks for your help +rep for you.
But one question, why did i need removed the last comma? I dont know why if I know it than I know it for the next time.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)