Hello, I have a question, I need to place many names, which would be faster/efficient, declare the names in the same function, or create a variable with the list of names and then call them, here are differents ways
First Way:
PHP Code:
stock SetNameType( __int_Entity, Type )
{
switch(Type)
{
case 1:
{
entity_set_string(__int_Entity,EV_SZ_classname,"Rogue");
}
case 2:
{
entity_set_string(__int_Entity,EV_SZ_classname,"Warrior");
}
case 3:
{
entity_set_string(__int_Entity,EV_SZ_classname,"Wizzard");
} // And a few more
}
}
Second Way:
PHP Code:
new const Names[][] = // Global
{
"Warrior",
"Rogue",
"Wizzard"
}
stock SetNameType( __int_Entity, Type )
{
switch(Type)
{
case 1:
{
entity_set_string(__int_Entity,EV_SZ_classname,Names[0]);
}
case 2:
{
entity_set_string(__int_Entity,EV_SZ_classname,Names[1]);
}
case 3:
{
entity_set_string(__int_Entity,EV_SZ_classname,Names[2]);
} // And a few more
}
}
i can set it directly like this:
PHP Code:
new Names[][] = // Global
{
"Warrior",
"Rogue",
"Wizzard"
}
stock SetNameType( __int_Entity, Type )
{
entity_set_string(__int_Entity,EV_SZ_classname,Names[Type]);
}
But i need to use other switch for other purpose, but, what is better, set the string directly, or with a global variable( Way 1 or 2 );