Help with name
#1

Hi. I have code, that is shows for me from mysql tables furniture model ID. How to do, that it will be written not ID, but name? For example, I know, that ID 1429 is TV, but how to write in server not ID, but ,,TV'' ?

Код:
 format(msg,sizeof(msg),"     %i. %i",i+1,oInf[playerDB[playerid][house]][modelid][i+1]);
  strcat(MSG,msg);
Reply
#2

Make a function or a constant array that links each ID to a name..

Like
PHP код:
GetFurnitureName(id)
{
     new 
name[128];
     switch(
id)
     {
           case 
1429format(namesizeof(name), "TV");
     }
     return 
name;

or
PHP код:
enum furnitureenum
{
     
fID,
     
fName
}
new const 
Furnitures[MAX_FURNITURES][fEnum] = 
{
      {
1429,   "TV"}
}; 
And on loading...

PHP код:
Furniture[furnitureid][fName]; 
But make sure that the "furnitureid" in here is the order of the enum.. Not the model itself.
Reply
#3

Thanks man. Really helped me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)