SA-MP Forums Archive
need help with randomspawn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: need help with randomspawn (/showthread.php?tid=300466)



need help with randomspawn - niels44 - 30.11.2011

hey guys,
i want to make a random spawn for my classes and now i made this but it isnt working and i get all kind of warnings and errors.
on top of script:
Код:
new Float:RandomSpawnStreetRacers[][4] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
under OnGameModeInit()
Код:
	// streetracers class
	RandomSpawnStreetRacers = AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (1)
	RandomSpawnStreetRacers = AddPlayerClass(106,1048.4546,1928.2059,10.8203,261.0777,0,0,0,0,0,0); //Streetracers member (2)
    RandomSpawnStreetRacers = AddPlayerClass(107,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (3)
   	RandomSpawnStreetRacers = AddPlayerClass(115,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (4)
	RandomSpawnStreetRacers = AddPlayerClass(108,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (5)
but this isnt working... this are the errors:
Код:
F:\program files\my own drifting gamemode\gamemodes\NYD_Drifting1.pwn(73) : error 021: symbol already defined: "RandomSpawnStreetRacers"
F:\program files\my own drifting gamemode\gamemodes\NYD_Drifting1.pwn(2100) : warning 217: loose indentation
F:\program files\my own drifting gamemode\gamemodes\NYD_Drifting1.pwn(91) : warning 204: symbol is assigned a value that is never used: "RandomSpawnStreetRacers"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
help pls.
niels


Re: need help with randomspawn - Kostas' - 30.11.2011

pawn Код:
#include <a_samp>

new Float:RandomSpawnStreetRacers[][] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};

public OnGameModeInit()
{
    // Normal the AddPlayerClass here
    AddPlayerClass(105, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(106, 1048.4546, 1928.2059, 10.8203, 261.0777, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(107, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(115, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(108, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    return 1;
}

// It should be on OnPlayerSpawn
public OnPlayerSpawn(playerid)
{
    new Random = random(sizeof(RandomSpawnStreetRacers));
    SetPlayerPos(playerid, RandomSpawnStreetRacers[Random][0], RandomSpawnStreetRacers[Random][1], RandomSpawnStreetRacers[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnStreetRacers[Random][3]);
    return 1;
}



Re: need help with randomspawn - niels44 - 01.12.2011

yeah but then all the classes spawn randomly right? and i dont want that... here this are the classes i got:
Код:
	// streetracers class
	AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (1)
	AddPlayerClass(106,1048.4546,1928.2059,10.8203,261.0777,0,0,0,0,0,0); //Streetracers member (2)
    AddPlayerClass(107,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (3)
   	AddPlayerClass(115,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (4)
	AddPlayerClass(108,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (5)
	// police class
	AddPlayerClass(280,2264.9895,2457.2261,10.8203,183.2561,0,0,0,0,0,0); //Police Officer (1)
    AddPlayerClass(287,2264.9895,2457.2261,10.8203,183.2561,0,0,0,0,0,0); //Police Officer (2)
    AddPlayerClass(282,2264.9895,2457.2261,10.8203,183.2561,0,0,0,0,0,0); //Police Officer (3)
	// drifters class
	AddPlayerClass(173,-2244.5742,-2303.5190,30.0467,252.3967,0,0,0,0,0,0); //Drifters (1)
	AddPlayerClass(174,-2244.5742,-2303.5190,30.0467,252.3967,0,0,0,0,0,0); //Drifters (2)
    AddPlayerClass(175,-2244.5742,-2303.5190,30.0467,252.3967,0,0,0,0,0,0); //Drifters (3)
	// mafia class
	AddPlayerClass(111,2822.4297,895.8810,10.7500,8.5160,0,0,0,0,0,0); //Mafia (1)
	AddPlayerClass(112,-1010.4442,-699.1964,32.0078,6.3033,0,0,0,0,0,0); //Mafia (2)
	AddPlayerClass(113,-1010.4442,-699.1964,32.0078,6.3033,0,0,0,0,0,0); //Mafia (3)
	AddPlayerClass(124,-2217.8198,2336.1533,7.5469,129.2003,0,0,0,0,0,0); //Mafia (4)
	// bikers class
	AddPlayerClass(247,2317.5906,-1527.5520,25.3438,275.5380,0,0,0,0,0,0); //Bikers (1)
	AddPlayerClass(248,2317.5906,-1527.5520,25.3438,275.5380,0,0,0,0,0,0); //Bikers (2)
	AddPlayerClass(254,2317.5906,-1527.5520,25.3438,275.5380,0,0,0,0,0,0); //Bikers (3)
	// stunters class
	AddPlayerClass(121,-1354.0376,-239.9485,14.1823,325.2208,0,0,0,0,0,0); // stunters (1)
	AddPlayerClass(122,1332.6597,1362.7931,10.8766,263.7629,0,0,0,0,0,0); // stunters (2)
	AddPlayerClass(116,422.4953,2531.2754,16.6155,178.5320,0,0,0,0,0,0); // stunters (3)
and each class spawns somewhere else now but i want it randomly for each one but if u do it ur way then all the classes spawn randomly to that spawns


Re: need help with randomspawn - Kostas' - 01.12.2011

So you want every team to spawn randomly.
Then, something like this
pawn Код:
#include <a_samp>

new Float:RandomSpawnTeam1[][] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};

new Float:RandomSpawnTeam2[][] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-3796.9854, 1224.8180, 20.5429, 192.0335},
    {-3454.2170, 503.8759, 30.0790, 267.2932},
    {-3669.7322, -6.0874, 6.1328, 89.8853}
};

public OnGameModeInit()
{
    // Normal the AddPlayerClass here
    AddPlayerClass(105, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(106, 1048.4546, 1928.2059, 10.8203, 261.0777, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(107, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(115, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(108, 2497.2693, -1676.9578, 13.3398, 23.6501, 0, 0, 0, 0, 0, 0);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    // Your Team1
    if(gTeam[playerid] == Team1) {
        new
            Random = random(sizeof(RandomSpawnTeam1));
        SetPlayerPos(playerid, RandomSpawnTeam1[Random][0], RandomSpawnTeam1[Random][1], RandomSpawnTeam1[Random][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnTeam1[Random][3]);
    }
    // Your Team2
    else if(gTeam[playerid] == Team2) {
        new
            Random = random(sizeof(RandomSpawnTeam2));
        SetPlayerPos(playerid, RandomSpawnTeam2[Random][0], RandomSpawnTeam1[Random][1], RandomSpawnTeam2[Random][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnTeam2[Random][3]);
    }
    return 1;
}



Re: need help with randomspawn - niels44 - 01.12.2011

yeah thnx man XD i hope this works


Re: need help with randomspawn - niels44 - 01.12.2011

hmm it isnt working very good... now every class spawns at 2 places not more... and all teh classes spawn at teh same place... how to fix this?


Re: need help with randomspawn - Kostas' - 01.12.2011

Add as many as places you want. Also, change the coordinates from team1
pawn Код:
new Float:RandomSpawnTeam1[][] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
and team2
pawn Код:
new Float:RandomSpawnTeam2[][] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-3796.9854, 1224.8180, 20.5429, 192.0335},
    {-3454.2170, 503.8759, 30.0790, 267.2932},
    {-3669.7322, -6.0874, 6.1328, 89.8853}
};



Re: need help with randomspawn - niels44 - 01.12.2011

yeah i did but now all the classes spawn at 2 loactions... 1 in Lv and 1 in grove street..... how to fix this? here this is wut i have now...
Код:
new Float:RandomSpawnTeam1[][] = // StreetRacers
{
    // Positions, (X, Y, Z and Facing Angle)
    {1048.4546,1928.2059,10.8203,261.0777},
    {2497.2693,-1676.9578,13.3398,23.6501},
    {2497.2693,-1676.9578,13.3398,23.6501}
};

new Float:RandomSpawnTeam2[][] = // Police
{
    // Positions, (X, Y, Z and Facing Angle)
    {2264.9895,2457.2261,10.8203,183.2561},
    {2264.9895,2457.2261,10.8203,183.2561},
    {2264.9895,2457.2261,10.8203,183.2561}
};
new Float:RandomSpawnTeam3[][] = // Drifters
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2244.5742,-2303.5190,30.0467,252.3967},
    {-2244.5742,-2303.5190,30.0467,252.3967},
    {-2244.5742,-2303.5190,30.0467,252.3967}
};
new Float:RandomSpawnTeam4[][] = // Mafia
{
    // Positions, (X, Y, Z and Facing Angle)
    {2822.4297,895.8810,10.7500,8.5160},
    {-1010.4442,-699.1964,32.0078,6.3033},
    {-2217.8198,2336.1533,7.5469,129.2003}
};
new Float:RandomSpawnTeam5[][] = // Bikers
{
    // Positions, (X, Y, Z and Facing Angle)
    {2317.5906,-1527.5520,25.3438,275.5380},
    {2317.5906,-1527.5520,25.3438,275.5380},
    {2317.5906,-1527.5520,25.3438,275.5380}
};
new Float:RandomSpawnTeam6[][] = // Stunters
{
    // Positions, (X, Y, Z and Facing Angle)
    {-1354.0376,-239.9485,14.1823,325.2208},
    {1332.6597,1362.7931,10.8766,263.7629},
    {422.4953,2531.2754,16.6155,178.5320}
and this:
Код:
public OnGameModeInit()
{
	SetGameModeText("[DC] UnderGround Drift Central");
	// streetracers class
	AddPlayerClass(105,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Streetracers member (1)
	AddPlayerClass(106,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Streetracers member (2)
    AddPlayerClass(107,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Streetracers member (3)
   	AddPlayerClass(115,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Streetracers member (4)
	AddPlayerClass(108,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Streetracers member (5)
	// police class
	AddPlayerClass(280,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Police Officer (1)
    AddPlayerClass(287,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Police Officer (2)
    AddPlayerClass(282,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Police Officer (3)
	// drifters class
	AddPlayerClass(173,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Drifters (1)
	AddPlayerClass(174,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Drifters (2)
    AddPlayerClass(175,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Drifters (3)
	// mafia class
	AddPlayerClass(111,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Mafia (1)
	AddPlayerClass(112,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Mafia (2)
	AddPlayerClass(113,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Mafia (3)
	AddPlayerClass(124,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Mafia (4)
	// bikers class
	AddPlayerClass(247,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Bikers (1)
	AddPlayerClass(248,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Bikers (2)
	AddPlayerClass(254,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); //Bikers (3)
	// stunters class
	AddPlayerClass(121,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // stunters (1)
	AddPlayerClass(122,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // stunters (2)
	AddPlayerClass(116,0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // stunters (3)
and this:
Код:
if(gTeam[playerid] == STREETRACERS) {
    new
    Random = random(sizeof(RandomSpawnTeam1));
    SetPlayerPos(playerid, RandomSpawnTeam1[Random][0], RandomSpawnTeam1[Random][1], RandomSpawnTeam1[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam1[Random][3]);
    }

    else if(gTeam[playerid] == POLICE) {
    new
   	Random = random(sizeof(RandomSpawnTeam2));
    SetPlayerPos(playerid, RandomSpawnTeam2[Random][0], RandomSpawnTeam1[Random][1], RandomSpawnTeam2[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam2[Random][3]);
	}
 	else if(gTeam[playerid] == DRIFTERS) {
    new
   	Random = random(sizeof(RandomSpawnTeam3));
    SetPlayerPos(playerid, RandomSpawnTeam3[Random][0], RandomSpawnTeam3[Random][1], RandomSpawnTeam3[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam3[Random][3]);
	}
	else if(gTeam[playerid] == MAFIA) {
    new
   	Random = random(sizeof(RandomSpawnTeam4));
    SetPlayerPos(playerid, RandomSpawnTeam4[Random][0], RandomSpawnTeam4[Random][1], RandomSpawnTeam4[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam4[Random][3]);
	}
	else if(gTeam[playerid] == BIKERS) {
    new
   	Random = random(sizeof(RandomSpawnTeam5));
    SetPlayerPos(playerid, RandomSpawnTeam5[Random][0], RandomSpawnTeam5[Random][1], RandomSpawnTeam5[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam5[Random][3]);
	}
	else if(gTeam[playerid] == STUNTERS) {
    new
   	Random = random(sizeof(RandomSpawnTeam6));
    SetPlayerPos(playerid, RandomSpawnTeam6[Random][0], RandomSpawnTeam6[Random][1], RandomSpawnTeam6[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawnTeam6[Random][3]);
	}
  	SetPlayerInterior(playerid, 0);
  	SetPlayerToTeamColour(playerid);
	return 1;
}
but it isnt working.. how to fix it?


Re: need help with randomspawn - niels44 - 01.12.2011

come on guys replie i want to finish this XD my whole server is fucked up now


Re: need help with randomspawn - niels44 - 01.12.2011

wtf no one knows how to fix this?