SA-MP Forums Archive
stock error - 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: stock error (/showthread.php?tid=648546)



stock error - Zeus666 - 24.01.2018

Код HTML:
stock ShowTargetInventory(targetid)
{
	new str[180];
    if(!IsPlayerNPC(targetid))
    {
		gItemList="";
		for(new item;item<MAX_ITEMS;item++)
		{
			if(!strlen(_GetItemNamePVar(targetid,item))||!_GetItemAmountPVar(targetid,item))continue;
			format(gItemList,sizeof(gItemList),"%s\n%d\t\t%s",gItemList,_GetItemAmountPVar(targetid,item),_GetItemNamePVar(targetid,item));
		}
		format(gItemList,sizeof(gItemList),"%s",gItemList);

		format(str,sizeof(str),""COL_WHITE"%s "COL_GREEN"%i |"COL_WHITE" %i",GetBackpackName(targetid),pInfo[targetid][BackpackSlotsUsed],pInfo[targetid][BackpackSlots]);
		ShowPlayerDialog(targetid,INV_DIALOG_ID,DIALOG_STYLE_LIST,str,gItemList,"Select","Close");
	}
	return 1;
}
Код HTML:
CMD:targetinv(playerid,params[])
{
	new targetid;
    if(pInfo[playerid][pAdminLevel] >= 2)
    {
	  ShowTargetInventory(targetid);
	 }
	else {
		SendClientMessage(playerid,-1,"*"COL_RED" You ain't admin biatch!");
	}
	return 1;
}
but it doesn't target id's inventory.


Re: stock error - alanhutch - 24.01.2018

You don't set any value to targetid variable.

What do you want to do with this command?
Something like /targetinv [ID of a player] ?


Re: stock error - Marricio - 24.01.2018

Код:
CMD:targetinv(playerid,params[])
{
	new targetid = strval(params);
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,"Wrong player ID");
    if(pInfo[playerid][pAdminLevel] >= 2)
    {
	  ShowTargetInventory(targetid);
	 }
	else {
		SendClientMessage(playerid,-1,"*"COL_RED" You ain't admin biatch!");
	}
	return 1;
}
Also, before you go in-depth item and inventory system, I highly recommend you to use iterators (from YSI/y_iterate or foreach).


Re: stock error - Zeus666 - 24.01.2018

It shows not target inventory, but who type the command.

It shows mine, not target's.


Re: stock error - rfr - 24.01.2018

for the stock do this

ShowTargetInventory(targetid)
{

//code here

}


Re: stock error - Zeus666 - 24.01.2018

Quote:
Originally Posted by rfr
Посмотреть сообщение
for the stock do this

ShowTargetInventory(targetid)
{

//code here

}
i dont understand


Re: stock error - Marricio - 25.01.2018

Код:
stock ShowTargetInventory(playerid, targetid)
{
	new str[180];
    if(!IsPlayerNPC(targetid))
    {
		gItemList="";
		for(new item;item<MAX_ITEMS;item++)
		{
			if(!strlen(_GetItemNamePVar(targetid,item))||!_GetItemAmountPVar(targetid,item))continue;
			format(gItemList,sizeof(gItemList),"%s\n%d\t\t%s",gItemList,_GetItemAmountPVar(targetid,item),_GetItemNamePVar(targetid,item));
		}
		format(gItemList,sizeof(gItemList),"%s",gItemList);

		format(str,sizeof(str),""COL_WHITE"%s "COL_GREEN"%i |"COL_WHITE" %i",GetBackpackName(targetid),pInfo[targetid][BackpackSlotsUsed],pInfo[targetid][BackpackSlots]);
		ShowPlayerDialog(playerid,INV_DIALOG_ID,DIALOG_STYLE_LIST,str,gItemList,"Select","Close");
	}
	return 1;
}

CMD:targetinv(playerid,params[])
{
	new targetid = strval(params);
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,"Wrong player ID");
    if(pInfo[playerid][pAdminLevel] >= 2)
    {
	  ShowTargetInventory(playerid, targetid);
	 }
	else {
		SendClientMessage(playerid,-1,"*"COL_RED" You ain't admin biatch!");
	}
	return 1;
}