Call all arrays in one
#1

Yes, whether my title is expressing or not let me tell you my problem..
I have arranged arrays like this
PHP код:
new veh[2] =
        {    
400401 }; 
And now how can I call this 2 variable in one arrary for example
PHP код:
if(GetVehicleModel(vmodel) == veh[2])  //the veh[2] will call only the number 401 
Now tell how to call the 2 variable in one.
Reply
#2

PHP код:
new veh[2] = 
        {    
400401 };  
for(new 
isizeof(veh); i++)
{
    if(
GetVehicleModel(vmodel) == veh[i])

Try this.

EDIT ; Yes, i forgot the i.
Reply
#3

Similar but not the same

Quote:

new veh[2] =
{ 400, 401 };

for(new i; i < sizeof(veh); i++)
{
if(GetVehicleModel(vmodel) == veh[i]) //You should index an i inside.
}

Reply
#4

PHP код:
new veh[2] =  
        {    
400401 }; 
There is too ways, depending on the size of the arrays you have to decide, but if the arrays size often changes, i recommend way 1

PHP код:
for(new isizeof(veh); i++) 

    if(
GetVehicleModel(vmodel) == veh[i])
    {
        new 
modelText[30];
        
format(modelText30"The Vehicle model is: %d"veh[i]);
        
printf("%s"modelText);
        return 
1;
    }

or

PHP код:
if(GetVehicleModel(vmodel) == veh[0] || GetVehicleModel(vmodel) == veh[1])
{
    return 
1;

and also

Quote:
PHP код:
if(GetVehicleModel(vmodel) == veh[2])  //the veh[2] will call only the number 401 
this would give you an out of bounds error, because max index is "1".
Reply
#5

You said: or

if(GetVehicleModel(vmodel) == veh[0] || GetVehicleModel(vmodel) == veh[1])
{
return 1;
}

But it is a timy work.
And can this also work
Quote:

if(GetVehicleModel(vmodel) == veh[0 || 1])
{
return 1;
}

Reply
#6

Quote:

You said: or

if(GetVehicleModel(vmodel) == veh[0] || GetVehicleModel(vmodel) == veh[1])
{
return 1;
}

But it is a timy work.
And can this also work
PHP код:
if(GetVehicleModel(vmodel) == veh[|| 1])

return 
1

1. what does "timy work" mean (Edit: ah, you meant tiny)
2. no, that "veh[0 || 1]" is not valid syntax
Reply
#7

Having no or very little amount of knowledge about SA-MP scripting and you are arguing or representing invalid/ non-existent methods/ syntax...

You better put some time into SA-MP scripting Wiki before posting something like that, programming/ scripting is based on LOGIC.
Reply
#8

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
Having no or very little amount of knowledge about SA-MP scripting and you are arguing or representing invalid/ non-existent methods/ syntax...
Explain

Sorry if i was wrong, i was sure it doesn't work

Forgive me
Reply
#9

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Explain
Not you, talking about the other guy.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)