SA-MP Forums Archive
Help with name - 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: Help with name (/showthread.php?tid=656854)



Help with name - ,TomY' - 25.07.2018

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



Re: Help with name - JasonRiggs - 25.07.2018

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.


Re: Help with name - ,TomY' - 25.07.2018

Thanks man. Really helped me.