SA-MP Forums Archive
[HELP]Server : Unknown Command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Server : Unknown Command (/showthread.php?tid=232528)



[HELP]Server : Unknown Command - Vibrate17 - 27.02.2011

Hy everyone. I have o problem with command /buyprods. When I type this command, it says Unknown command. Why?

Code:
if(strcmp(cmd, "/buyprods", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
			new tmpcar = GetPlayerVehicleID(playerid);
			new compcost = 50;
			if(PlayerToPoint(60.0, playerid, 2787.8,-2436.3,13.7))
			{
				if(IsATruck(tmpcar))
				{
					if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])
					{
					    new amount;
					    tmp = strtok(cmdtext, idx);
						if(!strlen(tmp))
						{
							SendClientMessage(playerid, COLOR_GRAD1, "Use: /buyprods [amount]");
							return 1;
						}
						amount = strval(tmp);
						if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_GREY, "   Can't buy less then 1 Product or more then 500 !"); return 1; }
						new check= PlayerHaul[tmpcar][pLoad] + amount;
						if(check > PlayerHaul[tmpcar][pCapasity])
						{
						    format(string, sizeof(string), "   You went over the Truck Products Carry Limit of %d, you currently carry %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);
						    SendClientMessage(playerid, COLOR_GREY, string);
						    return 1;
						}
						new cost = amount*compcost;
						if(GetPlayerCash(playerid) >= cost)
						{
							PlayerHaul[tmpcar][pLoad] += amount;
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							GivePlayerCash(playerid,-cost);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
						else
						{
							format(string, sizeof(string), "You cant afford %d Products at $%d !", amount,cost);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							return 1;
						}
					}
					else
					{
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							return 1;
					}
				}
				else
				{
					SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not deliver Products.");
					return 1;
				}
			}
		}
		return 1;
	}



Re: [HELP]Server : Unknown Command - maramizo - 27.02.2011

Use ZCMD and replace your script with ZCMD and SSCANF2.
https://sampforum.blast.hk/showthread.php?tid=231496


Re: [HELP]Server : Unknown Command - Vibrate17 - 28.02.2011

Thanks, but I have much more commands:O.


Re: [HELP]Server : Unknown Command - Stheam - 01.03.2011

f I were you, just rewrite this whole command.
And with a better looking thing.
cause your brackets are all over the place and it's hard to see where it goed wrong this way if there was a fault.


Re: [HELP]Server : Unknown Command - Mike Garber - 01.03.2011

Quote:
Originally Posted by Stheam
View Post
f I were you, just rewrite this whole command.
And with a better looking thing.
cause your brackets are all over the place and it's hard to see where it goed wrong this way if there was a fault.
First time you see a correct usage of brackets?
But It is alot, indeed, and I wonder if it could not be shortened a little.