Optimize code
#1

Tips on shortening the amount of lines/code?

Spawns:
pawn Код:
new Float:RandomSpawns[][] =
{
    {-78.5105,1089.5498,19.3229,358.0109}, // Randomspawn
    {-74.0025,1224.0546,19.2905,178.9746}, // Randomspawn
    {20.0504,1188.5989,18.7510,357.6666}, // Randomspawn
    {-311.2364,1310.5121,53.7565,70.0428}, // Randomspawn
    {-194.0204,1209.9554,19.3063,178.3723} // Randomspawn
};

new Float:JailSpawns[][] =
{
    {318.8602,317.0610,999.1484,272.1662},
    {319.9413,317.3439,999.1484,269.5342},
    {320.1702,310.9289,999.1484,272.6048},
    {318.4836,313.3496,999.1484,268.9495}
};
//ej klara
new Float:FoodSpawns[][] =
{
    {-78.5105,1089.5498,19.3229,358.0109}, // Randomspawn
    {-74.0025,1224.0546,19.2905,178.9746}, // Randomspawn
    {20.0504,1188.5989,18.7510,357.6666}, // Randomspawn
    {-311.2364,1310.5121,53.7565,70.0428}, // Randomspawn
    {-194.0204,1209.9554,19.3063,178.3723} // Randomspawn
};

new Float:FBISpawns[][] =
{
    {-78.5105,1089.5498,19.3229,358.0109}, // Randomspawn
    {-74.0025,1224.0546,19.2905,178.9746}, // Randomspawn
    {20.0504,1188.5989,18.7510,357.6666}, // Randomspawn
    {-311.2364,1310.5121,53.7565,70.0428}, // Randomspawn
    {-194.0204,1209.9554,19.3063,178.3723} // Randomspawn
};

new Float:PoliceSpawns[][] =
{
    {-78.5105,1089.5498,19.3229,358.0109}, // Randomspawn
    {-74.0025,1224.0546,19.2905,178.9746}, // Randomspawn
    {20.0504,1188.5989,18.7510,357.6666}, // Randomspawn
    {-311.2364,1310.5121,53.7565,70.0428}, // Randomspawn
    {-194.0204,1209.9554,19.3063,178.3723} // Randomspawn
};

new Float:MedicSpawns[][] =
{
    {-78.5105,1089.5498,19.3229,358.0109}, // Randomspawn
    {-74.0025,1224.0546,19.2905,178.9746}, // Randomspawn
    {20.0504,1188.5989,18.7510,357.6666}, // Randomspawn
    {-311.2364,1310.5121,53.7565,70.0428}, // Randomspawn
    {-194.0204,1209.9554,19.3063,178.3723} // Randomspawn
};

new Float:PilotSpawns[][] =
{
    {340.3901,2533.1902,16.7867,173.3253}, // pilotspawn
    {402.3915,2536.6050,16.5454,138.8161} // pilotspawn
};
OnPlayerSpawn:
pawn Код:
if(gTeam[playerid] == POLICE)
    {
        new Random = random(sizeof(PoliceSpawns));
        SetPlayerPos(playerid, PoliceSpawns[Random][0], PoliceSpawns[Random][1], PoliceSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, PoliceSpawns[Random][3]);
        return 1;
    }
    if(gTeam[playerid] == MEDIC)
    {
        new Random = random(sizeof(MedicSpawns));
        SetPlayerPos(playerid, MedicSpawns[Random][0], MedicSpawns[Random][1], MedicSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, MedicSpawns[Random][3]);
        return 1;
    }
    if(gTeam[playerid] == FBI)
    {
        new Random = random(sizeof(FBISpawns));
        SetPlayerPos(playerid, FBISpawns[Random][0], FBISpawns[Random][1], FBISpawns[Random][2]);
        SetPlayerFacingAngle(playerid, FBISpawns[Random][3]);
        return 1;
    }
    if(gTeam[playerid] == PILOT)
    {
        new Random = random(sizeof(PilotSpawns));
        SetPlayerPos(playerid, PilotSpawns[Random][0], PilotSpawns[Random][1], PilotSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, PilotSpawns[Random][3]);
        return 1;
    }
    if(gTeam[playerid] == NOSKILL)
    {
        new Random = random(sizeof(RandomSpawns));
        SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
        return 1;
    }
    if(gTeam[playerid] == FOODDELIVERY)
    {
        new Random = random(sizeof(FoodSpawns));
        SetPlayerPos(playerid, FoodSpawns[Random][0], FoodSpawns[Random][1], FoodSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, FoodSpawns[Random][3]);
        return 1;
    }
Reply


Messages In This Thread
Optimize code - by Elite1337 - 14.01.2015, 11:59
Re: Optimize code - by CodyHawkins - 14.01.2015, 12:07

Forum Jump:


Users browsing this thread: 1 Guest(s)