Closed x-MV closed 5 years ago
static String: itemDB_Desc[MAX_ITEMS]; String:GetItemData_Desc(ITEM: itemid) return itemDB_Desc[itemid]; ITEM: NewItem(const name[MAX_ITEM_NAME], const SQLname[MAX_ITEM_NAME], const desc[] = "No information", const Float: preview[4], model) { //some working code itemDB_Desc[newitem] = str_new(desc); return newitem; } // creating item NewItem("Mobile phone", "phone", "Mobile phone description", Float:{0.0, 0.0, 0.0, 1.0}, 18866); // and code native ShowPlayerDialogAMXStr(playerid, dialogid, style, caption[], AmxString:info, button1[], button2[]) = ShowPlayerDialog; // showing dialog ShowPlayerDialogAMXStr(playerid, dialog_none, DIALOG_STYLE_MSGBOX, "Item information", GetItemData_Desc(PlayerInventory[playerid][i][INV_ITEMID]), "Okay", ""); // PlayerInventory[playerid][i][INV_ITEMID] gives right value // also tried new buffer[128]; str_get(GetItemData_Desc(PlayerInventory[playerid][i][INV_ITEMID]), buffer); print(buffer); //prints (null)```
If you store a string in a permanent location, you must call str_acquire on it when you add it and str_release when you remove it. Otherwise, the garbage collector will delete it early.
str_acquire
str_release