SA-MP Forums Archive
"SERVER: Unknown Command!" with /sellprods - 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: "SERVER: Unknown Command!" with /sellprods (/showthread.php?tid=416084)



"SERVER: Unknown Command!" with /sellprods - Fizz - 15.02.2013

Hello. So, I have a /sellprods command which only works when you are far away from a business or out of prods (for trucker job), and when you are at a business and you try to do /sellprods it says "SERVER: Unknown Command".

I was thinking it may be because i misplaced or missed a return or something like that.

Here is my "/sellprods" command:

Код:
	if(strcmp(cmd, "/sellprods", true) == 0)
	{
	    new cashmade;
		new tmpcar;
		if(IsPlayerConnected(playerid))
		{
			tmpcar = GetPlayerVehicleID(playerid);
			if(!IsATruck(tmpcar))
			{
				GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
				return 1;
			}
			if(PlayerInfo[playerid][pTruckLoad] == 0)
			{
				GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
				SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
				return 1;
			}
			for(new i = 0; i < sizeof(BizzInfo); i++)
			{
				if (IsPlayerInRangeOfPoint(playerid, 10,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
				{
					//printf("Found House :%d",i);
					for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
					{
						if(BizzInfo[i][bProducts] == BizzInfo[i][bMaxProducts])
						{
							GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
						if(BizzInfo[i][bPriceProd] > BizzInfo[i][bTill])
						{
							GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
						PlayerInfo[playerid][pTruckLoad]--;
						BizzInfo[i][bProducts]++;
						cashmade = cashmade+BizzInfo[i][bPriceProd];
						//ConsumingMoney[playerid] = 1;
						SafeGivePlayerMoney(playerid,BizzInfo[i][bPriceProd]);
						BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
						if(PlayerInfo[playerid][pTruckLoad] == 0)
						{
							GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
					}
					OnPropUpdate(3,i);
					return 1;
				}
			}
		}
		for(new i = 0; i < sizeof(SBizzInfo); i++)
		{
			if (IsPlayerInRangeOfPoint(playerid, 10,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
			{
				//printf("Found House :%d",i);
				for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
				{
					if(SBizzInfo[i][sbProducts] == SBizzInfo[i][sbMaxProducts])
					{
						GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
					if(SBizzInfo[i][sbPriceProd] > SBizzInfo[i][sbTill])
					{
						GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
					PlayerHaul[tmpcar][pLoad]--;
					SBizzInfo[i][sbProducts]++;
					cashmade = cashmade+SBizzInfo[i][sbPriceProd];
					//ConsumingMoney[playerid] = 1;
					SafeGivePlayerMoney(playerid,SBizzInfo[i][sbPriceProd]);
					SBizzInfo[i][sbTill] -= SBizzInfo[i][sbPriceProd];
					if(PlayerHaul[tmpcar][pLoad] == 0)
					{
						GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
				}
				OnPropUpdate(3,i);
				return 1;
			}
		}
		GameTextForPlayer(playerid, "~r~To Far From A Business", 5000, 1);
		return 1;
	}