variable problem
#1

hello everyone, i have a little problem with a variable i put it as this:

pawn Код:
new iSpawn = {SPAWN1,...};
and i get this errors:

Код:
C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 029: invalid expression, assumed zero
C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 008: must be a constant expression; assumed zero
then i put it like this:

pawn Код:
new iSpawn = {SPAWN1,SPAWN2,SPAWN3,SPAWN4};
and i get this error:

Код:
C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 008: must be a constant expression; assumed zero
can anyone help me solving this errors? plz
Reply
#2

can u give me more script lines?
Reply
#3

ok, here it is:

pawn Код:
//defines
#define SPAWN1 0
#define SPAWN2 1
#define SPAWN3 2
#define SPAWN4 3
//the variable
new iSpawn = {SPAWN1,SPAWN2,SPAWN3,SPAWN4};//also i tried puting it in the other way its over

new Float:rSpawn1[10][3] = {
{1246.8333,276.8709,19.5469},
{1293.4458,236.2684,19.5547},
{1359.1572,253.4975,19.5669},
{1334.0454,322.1825,19.7152},
{1306.8153,363.6139,19.5547},
{1276.7098,361.7626,19.5547},
{1266.9955,294.8011,19.5547},
{1324.8519,287.3672,20.0452},
{1340.9645,397.9261,19.5547},
{1389.8987,365.7182,19.6820}
};

new Float:rSpawn2[10][3] = {
{241.9689,-221.4050,1.5781},
{208.8816,-160.0220,1.5781},
{183.2664,-104.8151,2.0234},
{121.7181,-174.8322,1.5781},
{146.8865,-218.5352,1.5781},
{211.8726,-228.9014,1.7786},
{205.9564,-267.5266,1.5843},
{241.9689,-221.4050,1.5781},
{261.8944,-270.4467,1.5781},
{341.8138,-142.8231,1.4268}
};

new Float:rSpawn3[10][3] = {
{-2182.8086,-2423.7449,30.6250},
{-2137.1643,-2455.0193,30.6250},
{-2114.6904,-2426.0012,30.6250},
{-2179.5215,-2415.7537,38.0891},
{-2171.7415,-2495.0276,30.6250},
{-2129.7642,-2523.7480,30.6250},
{-2089.5654,-2517.9167,30.6250},
{-2089.2437,-2439.5278,30.6250},
{-2084.7861,-2423.8340,30.6250},
{-2095.6426,-2421.0159,34.9219}
};

new Float:rSpawn4[10][3] = {
{-2192.3918,2407.6030,4.9643},
{-2272.4980,2351.1023,4.8202},
{-2370.5737,2344.8816,4.8359},
{-2438.2827,2324.9331,4.9844},
{-2496.5095,2371.8245,14.1182},
{-2542.7676,2330.8284,4.8281},
{-2564.4302,2291.6602,4.9908},
{-2572.8518,2237.1780,4.9822},
{-2487.8596,2218.7754,4.9844},
{-2446.8203,2243.6064,4.7742}
};

//in OnPlayerSpawn
    new
        rand;
    switch(iSpawn)
    {
        case SPAWN1: {
            rand = random(sizeof rSpawn1);
            SetPlayerPos(playerid, rSpawn1[rand][0], rSpawn1[rand][1], rSpawn1[rand][2]);
        }
        case SPAWN2: {
            rand = random(sizeof rSpawn2);
            SetPlayerPos(playerid, rSpawn2[rand][0], rSpawn2[rand][1], rSpawn2[rand][2]);
        }
        case SPAWN3: {
            rand = random(sizeof rSpawn3);
            SetPlayerPos(playerid, rSpawn3[rand][0], rSpawn3[rand][1], rSpawn3[rand][2]);
        }
        case SPAWN4: {
            rand = random(sizeof rSpawn4);
            SetPlayerPos(playerid, rSpawn4[rand][0], rSpawn4[rand][1], rSpawn4[rand][2]);
        }
    }

//in OnGameModeInit

SetTimer("SpawnInfo", 600000, true);//cada diez minutos cambia la informaciуn del spawn
//and a callback

forward SpawnInfo();
public SpawnInfo()
{
  if(iSpawn==SPAWN1) iSpawn++;
  else if(Spawn==SPAWN2) iSpawn++;
  else if(Spawn==SPAWN3) iSpawn++;
  else if(Spawn==SPAWN4) iSpawn=CIUDAD_LS;

}
basicly it is all in what it is involved that variable plz help me
Reply
#4

It has to be constant

new iSpawn {0, 1, 2} // like this
Reply
#5

Quote:
Originally Posted by hoodline
Посмотреть сообщение
It has to be constant

new iSpawn {0, 1, 2} // like this
u say with out the "="??

cuz if u say it is like that i have this problem:

C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 001: expected token: ";", but found "{"
Reply
#6

Quote:
Originally Posted by sasuga
Посмотреть сообщение
u say with out the "="??

cuz if u say it is like that i have this problem:

C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 001: expected token: ";", but found "{"
I'm sorry i not had much sleep it should be

new iSpawn[4] = {0, 1, 2, 3};
Reply
#7

same shitty error :l

C:\Users\Javier.FamiliaGomez-PC\Desktop\spawns.pwn(13) : error 008: must be a constant expression; assumed zero
Reply
#8

Because you are trying to store multiple pieces of data in the variable (or an "array" of data if you will!), you must declare the variable as an array:
pawn Код:
new iSpawn[4] = {SPAWN1,SPAWN2,SPAWN3,SPAWN4};
If you would like an example of random spawn locations, checkout the example at the bottom of this Wiki page: https://sampwiki.blast.hk/wiki/Random

Good luck!
Reply
#9

Could I just add; that from what I can see you do not use iSpawn anywhere. What is it supposed to be?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)