Array help.
#1

Hello, I need help getting some array values to make my code smaller. Here's what I mean:

This is my code
Код:
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        SetPlayerHealth(playerid, 0.0);
 }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 25 && bodypart == 9)
    {
  SetPlayerHealth(playerid, 0.0);
 }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 27 && bodypart == 9)
    {
  SetPlayerHealth(playerid, 0.0);
 }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 26 && bodypart == 9)
    {
  SetPlayerHealth(playerid, 0.0);
 }
 if(issuerid != INVALID_PLAYER_ID && weaponid == 30 && bodypart == 9)
    {
   SetPlayerHealth(playerid, 0.0);
    }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 31 && bodypart == 9)
    {
   SetPlayerHealth(playerid, 0.0);
 }
  if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 9)
    {
     SetPlayerHealth(playerid, 0.0);
 }
I want to use something like
Код:
new array[x] = {24,25,34,etc,etc...}
if(issuerid != INVALID_PLAYER_ID && weaponid == arrayvalues && bodypart == 9)
{
}
I've already tried
Код:
 new array[7];
 array = {24, 25, 26, 27, 30, 31, 34};
 new i;

 for (i=0; i<7; i++)
 {
 }

 if(issuerid != INVALID_PLAYER_ID && weaponid == array[i] && bodypart == 9)
    {
        SetPlayerHealth(playerid, 0.0);
 }
But it won't work because the values can only be used inside the for function and I need to use them in the if function.

And I've also tried
Код:
 if(issuerid != INVALID_PLAYER_ID && weaponid == 31 || 30 || 24 || 34 && bodypart == 9)
    {
     SetPlayerHealth(playerid, 0);
 }
But it doesn't work.
Any help? Thanks in advance.
Reply


Messages In This Thread
Array help. - by Cepillado - 28.07.2014, 03:36
Re: Array help. - by Stanford - 28.07.2014, 03:59
Respuesta: Array help. - by FullCircle - 28.07.2014, 03:59
Respuesta: Re: Array help. - by Cepillado - 28.07.2014, 05:10
Re: Array help. - by Smileys - 28.07.2014, 07:34
Re: Array help. - by Threshold - 28.07.2014, 08:16
Re: Array help. - by MBilal - 28.07.2014, 09:42

Forum Jump:


Users browsing this thread: 1 Guest(s)