Random Spawn Problem
#1

My Onplayerspawn Script....

Quote:

public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid,0);
TogglePlayerClock(playerid,0);

new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);

new Float:RandomSpawns[][] =
{
{1495.8939,-2435.2817,13.5547}; // Randomspawn
{1426.5933,-2465.2419,13.5547}; // Randomspawn
{1428.1489,-2436.5586,13.5547}; // Randomspawn
{1419.6462,-2449.0503,19.3470}; // Randomspawn
{1392.2720,-2444.8025,19.3470};// Randomspawn
{1433.3538,-2413.0479,13.5547}; // Randomspawn
{1464.5680,-2406.5442,13.5547}; // Randomspawn
{1468.0763,-2465.2300,13.5547}; // Randomspawn
{1442.5254,-2462.9463,13.6563}; // Randomspawn
{1458.5173,-2438.4583,13.6563}; // Randomspawn
};
return 1;
}

Errors i get....

Quote:

C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(39) : error 017: undefined symbol "RandomSpawns"
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(39) : error 029: invalid expression, assumed zero
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(39) : warning 215: expression has no effect
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(40) : error 017: undefined symbol "RandomSpawns"
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(40) : warning 215: expression has no effect
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(40) : error 001: expected token: ";", but found "]"
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(40) : error 029: invalid expression, assumed zero
C:\Users\Fie\Desktop\New Folder\gamemodes\bare.pwn(40) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.

Please help me !!
Reply
#2

You are creating the randomspawns after you are calling them, make it a global array.
Reply
#3

Try This:
pawn Код:
new Float:RandomSpawns[][] =
{
{1495.8939,-2435.2817,13.5547}, // Randomspawn
{1426.5933,-2465.2419,13.5547}, // Randomspawn
{1428.1489,-2436.5586,13.5547}, // Randomspawn
{1419.6462,-2449.0503,19.3470}, // Randomspawn
{1392.2720,-2444.8025,19.3470},// Randomspawn
{1433.3538,-2413.0479,13.5547}, // Randomspawn
{1464.5680,-2406.5442,13.5547}, // Randomspawn
{1468.0763,-2465.2300,13.5547}, // Randomspawn
{1442.5254,-2462.9463,13.6563}, // Randomspawn
{1458.5173,-2438.4583,13.6563} // Randomspawn
};
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
    TogglePlayerClock(playerid,0);
   
    new Random = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    return 1;
}
Reply
#4

Put this under #include <a_samp> or somewhere near it in the beginning like below:

pawn Код:
#include <a_samp>

new Float:RandomSpawns[][] =
{
{1495.8939,-2435.2817,13.5547}, // Randomspawn
{1426.5933,-2465.2419,13.5547}, // Randomspawn
{1428.1489,-2436.5586,13.5547}, // Randomspawn
{1419.6462,-2449.0503,19.3470}, // Randomspawn
{1392.2720,-2444.8025,19.3470},// Randomspawn
{1433.3538,-2413.0479,13.5547}, // Randomspawn
{1464.5680,-2406.5442,13.5547}, // Randomspawn
{1468.0763,-2465.2300,13.5547}, // Randomspawn
{1442.5254,-2462.9463,13.6563}, // Randomspawn
{1458.5173,-2438.4583,13.6563} // Randomspawn
};
then replace your current OnPlayerSpawn with this:

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
    TogglePlayerClock(playerid,0);
    new Random = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    SetCameraBehindPlayer(playerid);
    return 1;
}
Damn just a few seconds too late :P
Reply
#5

Thankyou!!! you helped alot!
Reply
#6

No problem, that is a very easy thing to do once you get used to it, it becomes naturally
Reply
#7

You could also make an include, just like gl_common, or gl_spawns
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)