Define custom weapon names
#7

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:
Код:
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;
}
Do I need to make a loop? Or how does this work?
Reply


Messages In This Thread
Define custom weapon names - by SiraBots - 01.06.2015, 18:59
Re: Define custom weapon names - by Konstantinos - 01.06.2015, 19:10
Re: Define custom weapon names - by SiraBots - 01.06.2015, 19:12
Re: Define custom weapon names - by Konstantinos - 01.06.2015, 19:16
Re: Define custom weapon names - by SiraBots - 01.06.2015, 19:18
Re: Define custom weapon names - by Konstantinos - 01.06.2015, 19:27
Re: Define custom weapon names - by SiraBots - 01.06.2015, 19:55
Re: Define custom weapon names - by Konstantinos - 01.06.2015, 20:02
Re: Define custom weapon names - by SiraBots - 01.06.2015, 20:14
Re: Define custom weapon names - by Konstantinos - 01.06.2015, 20:26

Forum Jump:


Users browsing this thread: 1 Guest(s)