how to make random spawn for class
#1

hello guys,
i have a question.
i want to make a random spawn for my classes.
i have this defines and all shit:
Код:
#define STREETRACERS 1
#define POLICE 2
#define DRIFTERS 3
#define MAFIA 4
#define BIKERS 5
#define STUNTERS 6
#define STREETRACERS_COLOUR 0x33AA33AA  //colour green
#define POLICE_COLOUR 0xFFFF00AA//colour blue
#define DRIFTERS_COLOUR 0xAA3333AA//colour red
#define MAFIA_COLOUR 0xFF00FFAA//colour purple
#define BIKERS_COLOUR 0x0000FFFF//colour yellow
#define STUNTERS_COLOUR 0xFF9000FF //colour orange
Код:
enum TeamCars
{
Streetracers,
Police,
Drifters,
Mafia,
Bikers,
Stunters
}
Код:
new Cars[TeamCars];

new gTeam[MAX_PLAYERS];
now i have this classes at the moment:
Код:
	// streetracers class
	AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Streetracers member (1)
	AddPlayerClass(106,2497.2693,-1676.9578,13.3398,23.6501,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,1332.6597,1362.7931,10.8766,263.7629,0,0,0,0,0,0); // stunters (3)
and this:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	switch(classid)
    {
        case 0 .. 4: { GameTextForPlayer(playerid, "~g~StreetRacers", 3000, 6); }
		case 5 .. 7: { GameTextForPlayer(playerid, "~b~Police", 3000, 6); }
		case 8 .. 10: { GameTextForPlayer(playerid, "~r~Drifters", 3000, 6); }
		case 11 .. 14: { GameTextForPlayer(playerid, "~p~Mafia", 3000, 6); }
		case 15 .. 17: { GameTextForPlayer(playerid, "~y~Bikers", 3000, 6); }
		case 18 .. 20: { GameTextForPlayer(playerid, "~w~Stunters", 3000, 6); }
}

  	SetPlayerInterior(playerid,14);
  	SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  	SetPlayerFacingAngle(playerid, 270.0);
  	SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  	SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
	SetPlayerTeamFromClass(playerid, classid);
	return 1;
}
and this:
Код:
public OnPlayerSpawn(playerid)
{
  SetPlayerInterior(playerid, 0);
  SetPlayerToTeamColour(playerid);
  return 1;
}
and this:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Streetracers] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Drifters] )
        {
            if(gTeam[playerid] != 3)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Mafia] )
        {
            if(gTeam[playerid] != 4)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Bikers] )
        {
            if(gTeam[playerid] != 5)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Stunters] )
        {
            if(gTeam[playerid] != 6)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = STREETRACERS;
    }
    if(classid == 1)
    {
        gTeam[playerid] = POLICE;
    }
    if(classid == 2)
    {
        gTeam[playerid] = DRIFTERS;
    }
    if(classid == 3)
    {
        gTeam[playerid] = MAFIA;
    }
    if(classid == 4)
    {
        gTeam[playerid] = BIKERS;
    }
    if(classid == 5)
    {
        gTeam[playerid] = STUNTERS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == STREETRACERS)
    {
        SetPlayerColor(playerid,STREETRACERS_COLOUR); //Green
    }
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOUR); // Blue
    }
    if(gTeam[playerid] == DRIFTERS)
    {
        SetPlayerColor(playerid,DRIFTERS_COLOUR); // red
    }
    if(gTeam[playerid] == MAFIA)
    {
        SetPlayerColor(playerid,MAFIA_COLOUR); // grey
    }
    if(gTeam[playerid] == BIKERS)
    {
        SetPlayerColor(playerid,BIKERS_COLOUR); // yellow
    }
    if(gTeam[playerid] == STUNTERS)
    {
        SetPlayerColor(playerid,STUNTERS_COLOUR); // orange
    }
}
and now i want to know how to make a random spawn for each class so that each class spawns somewhere else: example: when u choose the streetracers class that spawn at grove street and then when u die or when u reclass that u spawn at bayside or somewhere else.. and i want that for each class... but how to make this?

niels
Reply
#2

ah come on someone has to know it? i hope
Reply
#3

wtf noone?
Reply
#4

why noone replies man wtf...
Reply
#5

In the meanwhile you had to use the wiki:
https://sampwiki.blast.hk/wiki/Random
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)