Cant compiler
#1

My script stills good but when I add this
Код:
new rand = random(sizeof(RandomSpawn));
on the top of the script (behind define and include) That error appears.
http://imgur.com/QyHpE50
Help!
Reply
#2

Show us

"RandomSpawn"
Assuming this is your "RandomSpawn"

PHP код:
new rand random(sizeof(RandomSpawn)); 
new 
Float:RandomSpawn[][7] = 

//Positions,(X,Y,ZandFacingAngle) 
{-873.1492,-1929.0703,24.6819,351.9071}, 
{-
879.4926,-1911.9144,38.0141,42.6676}, 
{-
862.8982,-1901.0688,38.3521,357.5472}, 
{-
881.0944,-1989.5999,25.9896,184.5856}, 
{-
737.8086,-1837.0662,22.1271,85.9572}, 
{-
690.7778,-1913.4591,7.2225,346.3163
}; 
SetPlayerCheckpoint(playerid,RandomSpawn[rand][0],RandomSpawn[rand][1],RandomSpawn[rand][2],5); 
Try it like this:

PHP код:
new Float:RandomSpawn[][4]= 

{-
873.1492,-1929.0703,24.6819,351.9071}, 
{-
879.4926,-1911.9144,38.0141,42.6676}, 
{-
862.8982,-1901.0688,38.3521,357.5472}, 
{-
881.0944,-1989.5999,25.9896,184.5856}, 
{-
737.8086,-1837.0662,22.1271,85.9572}, 
{-
690.7778,-1913.4591,7.2225,346.3163
}; 
new 
rand random(sizeof(RandomSpawn)); 
SetPlayerCheckpoint(playeridRandomSpawn[rand][0],RandomSpawn[rand][1],RandomSpawn[rand][2], 5); 
Reply
#3

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Show us

"RandomSpawn"
Assuming this is your "RandomSpawn"

PHP код:
new rand random(sizeof(RandomSpawn)); 
new 
Float:RandomSpawn[][7] = 

//Positions,(X,Y,ZandFacingAngle) 
{-873.1492,-1929.0703,24.6819,351.9071}, 
{-
879.4926,-1911.9144,38.0141,42.6676}, 
{-
862.8982,-1901.0688,38.3521,357.5472}, 
{-
881.0944,-1989.5999,25.9896,184.5856}, 
{-
737.8086,-1837.0662,22.1271,85.9572}, 
{-
690.7778,-1913.4591,7.2225,346.3163
}; 
SetPlayerCheckpoint(playerid,RandomSpawn[rand][0],RandomSpawn[rand][1],RandomSpawn[rand][2],5); 
Try it like this:

PHP код:
new Float:RandomSpawn[][4]= 

{-
873.1492,-1929.0703,24.6819,351.9071}, 
{-
879.4926,-1911.9144,38.0141,42.6676}, 
{-
862.8982,-1901.0688,38.3521,357.5472}, 
{-
881.0944,-1989.5999,25.9896,184.5856}, 
{-
737.8086,-1837.0662,22.1271,85.9572}, 
{-
690.7778,-1913.4591,7.2225,346.3163
}; 
new 
rand random(sizeof(RandomSpawn)); 
SetPlayerCheckpoint(playeridRandomSpawn[rand][0],RandomSpawn[rand][1],RandomSpawn[rand][2], 5); 
Still bug
Reply
#4

Код:
 
new Float:RandomSpawn[][4]=
{
{-873.1492,-1929.0703,24.6819,351.9071},
{-879.4926,-1911.9144,38.0141,42.6676},
{-862.8982,-1901.0688,38.3521,357.5472},
{-881.0944,-1989.5999,25.9896,184.5856},
{-737.8086,-1837.0662,22.1271,85.9572},
{-690.7778,-1913.4591,7.2225,346.3163}
};

new rand = sizeof(RandomSpawn);
well i tested those but didnt give me any error or crashing at all
Reply
#5

You cannot call functions globally.
Reply
#6

Quote:
Originally Posted by ThatFag
Посмотреть сообщение
Код:
 
new Float:RandomSpawn[][4]=
{
{-873.1492,-1929.0703,24.6819,351.9071},
{-879.4926,-1911.9144,38.0141,42.6676},
{-862.8982,-1901.0688,38.3521,357.5472},
{-881.0944,-1989.5999,25.9896,184.5856},
{-737.8086,-1837.0662,22.1271,85.9572},
{-690.7778,-1913.4591,7.2225,346.3163}
};

new rand = sizeof(RandomSpawn);
well i tested those but didnt give me any error or crashing at all
Maybe It isn't about this line. I dont know !!
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You cannot call functions globally.
Why...Help me
Reply
#7

You cannot make a function return a value at compile time and calling one outside of any function/callback makes the compiler not responding.

You must place:
pawn Код:
new rand = random(sizeof(RandomSpawn));
to the place you do your stuff with that random position, be it OnPlayerSpawn or anything else. Read example: https://sampwiki.blast.hk/wiki/Random
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)