01.06.2015, 19:55
All right. That works just fine, thanks a lot for your assistance.
But I'll take it a bit further. Let's say I load the inventory items from the database. How would that be?
Here is my "samp_inventory" table:
And here is my code:
Do I need to make a loop? Or how does this work?
But I'll take it a bit further. Let's say I load the inventory items from the database. How would that be?
Here is my "samp_inventory" table:
And here is my code:
Код:
enum InventoryItems { ObjectName[32], ObjectModel }; static const Inventory[][InventoryItems] = { // Desert Eagle (24) {"Beretta 92", 1000}, {"SIG P226", 1001}, {"Walther P5", 1002}, // M4 (31) {"M4A1", 1003}, {"Barrett REC7", 1004}, // MP5 (29) {"AMP-69", 1005}, {"MAS-38", 1006} }; stock DefineGuns(playerid) { new string[128]; for(new i; i != sizeof(Inventory); ++i) { if(Player[playerid][pTest] == Inventory[i][ObjectModel]) { format(string, sizeof(string), "%s", Inventory[i][ObjectName]); break; // Do I need this? } } return string; } CMD:gunname(playerid) { new string[50]; format(string, sizeof(string), "Your weapon is: %s", DefineGuns(playerid)); SendClientMessage(playerid, -1, string); return 1; }