i had this command in my gamemode, when i type this in game,it tells server unknow command?
#1

Code:
		if(strcmp(cmd, "/bag", true) == 0)
	{
		if (IsPlayerConnected(playerid))
		{
	    	if(IsPlayerConnected(playerid))
	    	{
	    	    for(new i = 0; i < 31; i++)
				{
				    if(baoguo[playerid][i][bItem] != 0)
				    {
				        new string[328];
				        new ps[128];
				        new gunname[128];
				        GetWeaponName(baoguo[playerid][i][bID],gunname,128);
				        format(string,328,"|{FF6699}x|    |name		| Amount |\n");
				        format(ps,128,"|{FFFF66}%d|    |%s		| %d |\n",baoguo[playerid][i][bItem],gunname,baoguo[playerid][i][bAmount]);
						strcat(string, ps);
						ShowPlayerDialog(playerid, 3163, DIALOG_STYLE_LIST,"Bag",string);
					}
				}
			}
		}
	}
i had my enum too

Code:
enum pbaoguo
{
	sID,
	bItem,
	bID,
	bAmount,
};
new baoguo[MAX_PLAYERS][30][pbaoguo];
when i type /bag in game, it shows me Server Unknow Command? help plz
Reply
#2

Code:
CMD:bag
		if(strcmp(cmd, "/bag", true) == 0)
	{
		if (IsPlayerConnected(playerid))
		{
	    	if(IsPlayerConnected(playerid))
	    	{
	    	    for(new i = 0; i < 31; i++)
				{
				    if(baoguo[playerid][i][bItem] != 0)
				    {
				        new string[328];
				        new ps[128];
				        new gunname[128];
				        GetWeaponName(baoguo[playerid][i][bID],gunname,128);
				        format(string,328,"|{FF6699}x|    |name		| Amount |\n");
				        format(ps,128,"|{FFFF66}%d|    |%s		| %d |\n",baoguo[playerid][i][bItem],gunname,baoguo[playerid][i][bAmount]);
						strcat(string, ps);
						ShowPlayerDialog(playerid, 3163, DIALOG_STYLE_LIST,"Bag",string);
					}
				}
			}
		}
try now
Reply
#3

try this
Code:
if(strcmp(cmd, "/bag", true) == 0)
		{
	    	if(IsPlayerConnected(playerid))
	    	{
	    	    for(new i = 0; i < 31; i++)
				{
				    if(baoguo[playerid][i][bItem] != 0)
				    {
				        new string[328];
				        new ps[128];
				        new gunname[128];
				        GetWeaponName(baoguo[playerid][i][bID],gunname,128);
				        format(string,328,"|{FF6699}x|    |name		| Amount |\n");
				        format(ps,128,"|{FFFF66}%d|    |%s		| %d |\n",baoguo[playerid][i][bItem],gunname,baoguo[playerid][i][bAmount]);
						strcat(string, ps);
						ShowPlayerDialog(playerid, 3163, DIALOG_STYLE_LIST,"Bag",string, "Close");
					}
				}
			}
		}
Reply
#4

Quote:
Originally Posted by Chrisli520
View Post
when i type /bag in game, it shows me Server Unknow Command? help plz
Because you get run time error "Index out of bounds".

Take a look at the 2nd index of baoguo. It's 30, that's means it can get 0-29 values (in total 30).

What you do is:
pawn Code:
for(new i = 0; i < 31; i++)
Which will be called 31 times and when it will pass the invalid index (30) to the baoguo array, it will display the unknown command.

Change to:
pawn Code:
for(new i = 0; i < 30; i++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)