anyway ?
#1

anyway to 'get small' this?

enum TeamCars
{
//// yakuza cars
Y1,
Y2,
Y3,
Y4,
Y5,
Y6,
Y7,
Y8,
Y9,
Y10,
Y11,
Y12,
Y13,
//////// la cosa nostra cars
N1,
N2,
N3,
N4,
N5,
N6,
N7,
N8,
N9,
N10,
N11,
N12,
N13,
N14,
N15,
N16,
N17,
N18,
N19,
N20,
///////// cop cars
M1,
M2,
M3,
M4,
M5,
M6,
M7,
M8,
M9,
M10,
M11,
M12,
M13,
M14,
M15,
M16,
M17,
/////////// triad cars
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11
}
Reply
#2

You can put arrays in the enum instead of lots of single variables:

pawn Код:
enum TeamCars {
    Y[13],
    N[20],
    M[17],
    T[11]
}
To use them, call them like this:
variable[Y][2];
Reply
#3

else if(CarCheck == Cars[Y1] || CarCheck == Cars[Y2] || CarCheck == Cars[Y3] || CarCheck == Cars[Y4] || CarCheck == Cars[Y5] || CarCheck == Cars[Y6] || CarCheck == Cars[Y7] || CarCheck == Cars[Y8] || CarCheck == Cars[Y9] || CarCheck == Cars[Y10] || CarCheck == Cars[Y11])
{
if(ZaidejoKomanda[playerid] != 1)
{
RemovePlayerFromVehicle(playerid);
SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Yakuza", "Рis automobilis priklauso Yakuza.", "Gerai", "Uюdaryti");
return 1;
}
}
so, how can i should use there?
Reply
#4

pawn Код:
for(new i=0; i<sizeof(Y); i++)
{
    if(CarCheck == Cars[[Y[i]])
    {
        if(ZaidejoKomanda[playerid] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Yakuza", "Рis automobilis priklauso Yakuza.", "Gerai", "Uюdaryti");
            return 1;
         }
    }
}
Reply
#5

thx.. but how to 'convert' all callback? (im tryied it, but im getting errors. )
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
/// another shit
// CARS
	   if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        else if(CarCheck == NostraMasinos[1] >= NostraMasinos[16])
        {
            if(ZaidejoKomanda[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"La Cosa Nostra", "Рis automobilis priklauso La Cosa Nostra.", "Gerai", "Uюdaryti");
                return 1;
            }
        }
        else if(CarCheck == PolicijosMasinos[1] >= PolicijosMasinos[17])
        {
            if(ZaidejoKomanda[playerid] != 3)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Policijos Departamentas", "Рis automobilis priklauso Policijos Departamentui", "Gerai", "Uюdaryti");
                return 1;
            }
        }
        else if(CarCheck == YakuzaMasinos[1] >= YakuzaMasinos[11])
        {
            if(ZaidejoKomanda[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Yakuza", "Рis automobilis priklauso Yakuza.", "Gerai", "Uюdaryti");
                return 1;
            }
        }
          else if(CarCheck == TriadsMasinos[1] >= TriadsMasinos[9])
        {
            if(ZaidejoKomanda[playerid] != 4)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Triads", "Рis automobilis priklauso Triads.", "Gerai", "Uюdaryti");
                return 1;
            }
        }
        else if(CarCheck == YakuzaMasinos[12] || CarCheck == YakuzaMasinos[13])
        {
        if(GetPlayerScore(playerid) < 5000 && ZaidejoInformacija[playerid][Licenzija] > 0 || ZaidejoInformacija[playerid][Administratorius] < 1 || ZaidejoInformacija[playerid][VIP] < 1)
        {
        SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Yakuza", "Jыs neturite pakankamai,\nPatirties taрkш valdyti рб tankа. (XP < 5000)", "Gerai", "Uюdaryti");
        RemovePlayerFromVehicle(playerid);
        return 1;
        }
            if(ZaidejoKomanda[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Yakuza", "Рis naikintuvas priklauso Yakuza.", "Gerai", "Uюdaryti");
                return 1;
            }
        }
        else if(CarCheck == NostraMasinos[17] || NostraMasinos[18] || NostraMasinos[19] || NostraMasinos[20])
        {
        if(GetPlayerScore(playerid) < 3500 && ZaidejoInformacija[playerid][Licenzija] > 0 || ZaidejoInformacija[playerid][Administratorius] < 1 || ZaidejoInformacija[playerid][VIP] < 1)
        {
        SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"La Cosa Nostra", "Jыs neturite pakankamai,\nPatirties taрkш valdyti рб tankа.\n(XP < 3500)", "Gerai", "Uюdaryti");
        RemovePlayerFromVehicle(playerid);
        return 1;
        }
            if(ZaidejoKomanda[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"La Cosa Nostra", "Рis naikintuvas/tankas priklauso La Cosa Nostra.", "Gerai", "Uюdaryti");
                return 1;
            }
            }
        else if(CarCheck == TriadsMasinos[10] || CarCheck == TriadsMasinos[10])
        {
        if(GetPlayerScore(playerid) < 5000 && ZaidejoInformacija[playerid][Licenzija] > 0 || ZaidejoInformacija[playerid][Administratorius] < 1 || ZaidejoInformacija[playerid][VIP] < 1)
        {
        SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Triads", "Jыs neturite pakankamai,\nPatirties taрkш valdyti рб tankа. (XP < 5000)", "Gerai", "Uюdaryti");
        RemovePlayerFromVehicle(playerid);
        return 1;
        }
            if(ZaidejoKomanda[playerid] != 4)
            {
                RemovePlayerFromVehicle(playerid);
                SukurtiDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"Triads", "Рis lлktuvas/tankas priklauso Triads.", "Gerai", "Uюdaryti");
                return 1;
            }
            }
            }
	return 1;
}
Reply
#6

bump. 8chars+
Reply
#7

bump. 8charz
Reply
#8

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You can put arrays in the enum instead of lots of single variables:

pawn Код:
enum TeamCars {
    Y[13],
    N[20],
    M[17],
    T[11]
}
To use them, call them like this:
variable[Y][2];
I feel like a newbie. (lol) I should probably make this into an array, right?

pawn Код:
pWeapon1,
    pAmmo1,
    pWeapon2,
    pAmmo2,
    pWeapon3,
    pAmmo3,
    pWeapon4,
    pAmmo4,
    pWeapon5,
    pAmmo5,
    pWeapon6,
    pAmmo6,
    pWeapon7,
    pAmmo7,
    pWeapon8,
    pAmmo8,
    pWeapon9,
    pAmmo9,
    pWeapon10,
    pAmmo10,
    pWeapon11,
    pAmmo11,
    pWeapon12,
    pAmmo12,
Reply
#9

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
I feel like a newbie. (lol) I should probably make this into an array, right?

pawn Код:
pWeapon1,
    pAmmo1,
    pWeapon2,
    pAmmo2,
    pWeapon3,
    pAmmo3,
    pWeapon4,
    pAmmo4,
    pWeapon5,
    pAmmo5,
    pWeapon6,
    pAmmo6,
    pWeapon7,
    pAmmo7,
    pWeapon8,
    pAmmo8,
    pWeapon9,
    pAmmo9,
    pWeapon10,
    pAmmo10,
    pWeapon11,
    pAmmo11,
    pWeapon12,
    pAmmo12,
Yep, you can make it one or two arrays: pWeapon[12]/pAmmo[12] or pWeaponData[12][2]. It is also very useful when storing the data. Instead of doing it line by line, you can use GetPlayerWeaponData in a loop (i=array index=weapon slot)
Reply
#10

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Yep, you can make it one or two arrays: pWeapon[12]/pAmmo[12] or pWeaponData[12][2]. It is also very useful when storing the data. Instead of doing it line by line, you can use GetPlayerWeaponData in a loop (i=array index=weapon slot)
I'll have to give that a shot. I'm using MySQL on my script and I do it line by line. Sometimes, I don't think it saves. Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)