SA-MP Forums Archive
Call all arrays in one - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Call all arrays in one (/showthread.php?tid=624112)



Call all arrays in one - coool - 11.12.2016

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.


Re: Call all arrays in one - AjaxM - 11.12.2016

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

Try this.

EDIT ; Yes, i forgot the i.


Re: Call all arrays in one - coool - 11.12.2016

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.
}




Re: Call all arrays in one - BiosMarcel - 11.12.2016

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".


Re: Call all arrays in one - coool - 11.12.2016

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;
}




Re: Call all arrays in one - BiosMarcel - 11.12.2016

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


Re: Call all arrays in one - Logic_ - 11.12.2016

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.


Re: Call all arrays in one - BiosMarcel - 11.12.2016

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


Re: Call all arrays in one - Logic_ - 11.12.2016

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