Array with a string, an integer and a float
#1

Hello there. Is there any way to do something like this?
Код:
new array[][][] = 
{
 { "string", 0, 1.0 }
};
When I try to get it, the compiler tells 'tag mismatch':
Код:
get_data(index, a[], &b, Float:&c)
{
 strins(a, array[index][0], 32);
 b = array[index][1];
 c = array[index][2];
}
Reply
#2

https://sampwiki.blast.hk/wiki/Keywords:Initialisers#enum

PHP код:
enum e_array
{
    
e_string[32], // change the value to "fit" the whole text
    
e_integer,
    
Floate_float
};
new array[][
e_array] = 
{
    {
"string"01.0}
};
get_data(indexa[], &b, &Floatc
{
    if (!(
<= index sizeof array)) return; // invalid index, prevent from run time error 4
  
    
strcat((a[0] = EOSa), array[index][e_string], 32); // reset and copy
    
= array[index][e_integer];
    
= array[index][e_float];

Even though I don't understand why would you want to call a function when you can use "array" directly.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#enum

PHP код:
enum e_array
{
    
e_string[32], // change the value to "fit" the whole text
    
e_integer,
    
Floate_float
};
new array[][
e_array] = 
{
    {
"string"01.0}
};
get_data(indexa[], &b, &Floatc
{
    if (!(
<= index sizeof array)) return; // invalid index, prevent from run time error 4
  
    
strcat((a[0] = EOSa), array[index][e_string], 32); // reset and copy
    
= array[index][e_integer];
    
= array[index][e_float];

Even though I don't understand why would you want to call a function when you can use "array" directly.
Oops, thank you. It was just an example.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)