Floats and Random Spawns -
Codac - 11.04.2015
I was following a tutorial on creating a random spawning system, and I was getting errors with the code I wasn't sure about how to fix. I would post on the tutorial, but I'm not going to bump a post from mid-way 2014, so I figured I'd post here.
Код:
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(73) : error 017: undefined symbol "RandomSpawns"
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(73) : error 029: invalid expression, assumed zero
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(73) : warning 215: expression has no effect
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(74) : error 017: undefined symbol "RandomSpawns"
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(74) : warning 215: expression has no effect
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(74) : error 001: expected token: ";", but found "]"
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(74) : error 029: invalid expression, assumed zero
C:\Users\Windows7\Desktop\SAMP My Script\gamemodes\Gamemode.pwn(74) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
6 Errors.
And this is the code for spawning
Код:
public OnPlayerSpawn(playerid)
{
new Random = random(sizeof(RandomSpawns)); // 73
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]); // 74
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]); //
return 1;
}
The float
Код:
new Float:RandomSpawns[][] =
{
{1299.6201, 303.8129, 27.5555, 334.1266}, // Randomspawn
{1300.2102, 224.2214, 23.7565, 171.3810}, // Randomspawn
{1327.3563, 217.3694, 23.9410, 254.5809}, // Randomspawn
{1351.4109, 181.9179, 19.6343, 241.7132} // Randomspawn
};
I can't find what I did wrong, been trying to figure it out for the past hour almost, anyone able to help?
Re: Floats and Random Spawns -
Konstantinos - 11.04.2015
You declared RandomSpawns after OnPlayerSpawn callback. It needs to be declared before:
pawn Код:
new Float:RandomSpawns[][] =
{
{1299.6201, 303.8129, 27.5555, 334.1266}, // Randomspawn
{1300.2102, 224.2214, 23.7565, 171.3810}, // Randomspawn
{1327.3563, 217.3694, 23.9410, 254.5809}, // Randomspawn
{1351.4109, 181.9179, 19.6343, 241.7132} // Randomspawn
};
// callbacks below..
public OnPlayerSpawn(playerid)
{
new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
return 1;
}
Re: Floats and Random Spawns -
Codac - 11.04.2015
I posted them in a weird order, my fault. The Float:RandomSpawns was at the top of the script and the OnPlayerSpawn was below it.
EDIT: Oh my god I'm so smart. I never removed the #IF DEFINED FILTERSCRIPT (or whatever it was), after removing that and the #END IF (something), it worked.
Problem solved myself! (I'm so noob, excuse me while I go cry.)