SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/11/2013, 12:46 AM   #1
Chrisli520
Big Clucker
 
Join Date: May 2013
Posts: 53
Reputation: 0
Default i had this command in my gamemode, when i type this in game,it tells server unknow command?

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
Chrisli520 is offline   Reply With Quote
Old 24/11/2013, 02:46 AM   #2
JamesJohnson
Little Clucker
 
Join Date: Nov 2013
Posts: 39
Reputation: 0
Default Re: i had this command in my gamemode, when i type this in game,it tells server unknow command?

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
__________________
Hiring Admins, Faction Leaders, and more players to the community

JamesJohnson is offline   Reply With Quote
Old 24/11/2013, 03:12 AM   #3
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 401
Reputation: 27
Default Re: i had this command in my gamemode, when i type this in game,it tells server unknow command?

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");
					}
				}
			}
		}
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~

AiRaLoKa is offline   Reply With Quote
Old 24/11/2013, 11:02 AM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,846
Reputation: 1399
Default Re: i had this command in my gamemode, when i type this in game,it tells server unknow command?

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++)
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Server: UNKNOW COMMAND SonicFreeStyle Português/Portuguese 13 08/11/2013 10:49 PM
server unknow command?? Chrisli520 Scripting Help 2 18/10/2013 02:41 AM
when i type in the command, it saids server unknow command Chrisli520 Scripting Help 3 18/07/2013 02:29 AM
Server: Unknow Command Schock Help Archive 1 25/02/2009 07:50 PM


All times are GMT. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.