Better way to do this?
#3

You could put the code you currently have inside a stock or a callback, it doesn't really matter, as long it does get called. (Not sure if this is what you meant, but for me, to indent a code, I place it inside a callback or a stock to make it looks clean.

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerTeamPos(playerid);
    return true;
}

stock SetPlayerTeamPos(playerid)
{
    switch(pTeam[playerid])
    {
        case TEAM_COP:
        {
            switch(curCity)
            {
                case CITY_LS:
                {
                    new
                        r = random( sizeof(CopSpawnsLS) );

                    SetPlayerPos(playerid, CopSpawnsLS[r][0], CopSpawnsLS[r][1], CopSpawnsLS[r][2]);
                    SetPlayerFacingAngle(playerid, CopSpawnsLS[r][3]);
                }
                case CITY_SF:
                {
                    new
                        r = random( sizeof(CopSpawnsSF) );
                       
                    SetPlayerPos(playerid, CopSpawnsSF[r][0], CopSpawnsSF[r][1], CopSpawnsSF[r][2]);
                    SetPlayerFacingAngle(playerid, CopSpawnsSF[r][3]);
                }
                case CITY_LV:
                {
                    new
                        r = random( sizeof(CopSpawnsLV) );

                    SetPlayerPos(playerid, CopSpawnsLV[r][0], CopSpawnsLV[r][1], CopSpawnsLV[r][2]);
                    SetPlayerFacingAngle(playerid, CopSpawnsLV[r][3]);
                }
            }
           
            #if defined USE_ANTI_TEAMKILL
                SetPlayerTeam(playerid, TEAM_COP);
            #endif
        }
        case TEAM_BUM:
        {
            switch(curCity)
            {
                case CITY_LS:
                {
                    new
                        r = random( sizeof(BumSpawnsLS) );

                    SetPlayerPos(playerid, BumSpawnsLS[r][0], BumSpawnsLS[r][1], BumSpawnsLS[r][2]);
                    SetPlayerFacingAngle(playerid, BumSpawnsLS[r][3]);
                }
            }
            #if defined USE_ANTI_TEAMKILL
                SetPlayerTeam(playerid, TEAM_BUM);
            #endif
        }
    }
    return true;
}
Reply


Messages In This Thread
Better way to do this? - by 2KY - 24.12.2013, 17:55
Re: Better way to do this? - by 2KY - 24.12.2013, 18:02
Re: Better way to do this? - by Patrick - 24.12.2013, 18:03
Re: Better way to do this? - by 2KY - 24.12.2013, 18:06
Re: Better way to do this? - by CutX - 24.12.2013, 18:12
Re: Better way to do this? - by 2KY - 24.12.2013, 18:14

Forum Jump:


Users browsing this thread: 2 Guest(s)