ZCMD command.
#1

Hi, when i type this command it returns the SERVER : /alockbiz [id] but when i put in the id it says unknown command.
If anyone does fix this could you also tell me where i went wrong so i can learn for next time.
Code:
CMD:alockbiz(playerid, params[]) {
if(playerVariables[playerid][pAdminLevel] >= 4) {
	new
	 businessID;
	 if(sscanf(params, "d", businessID))	return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/alockbiz [ID]");

  			switch(businessVariables[businessID][bLocked]) {
			case 0: {
				format(result, sizeof(result), "%s\n(Business %d - owned by %s)\n\n(locked)", businessVariables[ businessID][bName],businessVariables[ businessID][bOwner]);

				businessVariables[ businessID][bLocked] = 1;
				SendClientMessage(playerid, COLOR_WHITE, "Business locked.");
			}
			case 1: {
				format(result, sizeof(result), "%s\n(Business %d - owned by %s)\n\nPress ~k~~PED_DUCK~ to enter", businessVariables[ businessID][bName], businessVariables[ businessID][bOwner]);

			    businessVariables[ businessID][bLocked] = 0;
			    SendClientMessage(playerid, COLOR_WHITE, "Business unlocked.");
			}
		}
		UpdateDynamic3DTextLabelText(businessVariables[businessID][bLabelID], COLOR_YELLOW, result);
	}
return 1;
}
Reply
#2

pawn Code:
CMD:alockbiz(playerid, params[])
{
    new businessID, result[128];
    if(playerVariables[playerid][pAdminLevel] >= 4)
    {
        if(!sscanf(params, "d", businessID))
        {
            switch(businessVariables[businessID][bLocked]) {
                case 0:
                {
                    format(result, sizeof(result), "%s\n(Business %d - owned by %s)\n\n(locked)", businessVariables[businessID][bName], businessVariables[businessID][bOwner]);
                    businessVariables[businessID][bLocked] = 1;
                    SendClientMessage(playerid, COLOR_WHITE, "Business locked.");
                }
                case 1:
                {
                   format(result, sizeof(result), "%s\n(Business %d - owned by %s)\n\nPress ~k~~PED_DUCK~ to enter", businessVariables[businessID][bName], businessVariables[businessID][bOwner]);
                   businessVariables[businessID][bLocked] = 0;
                   SendClientMessage(playerid, COLOR_WHITE, "Business unlocked.");
                }
            }
            UpdateDynamic3DTextLabelText(businessVariables[businessID][bLabelID], COLOR_YELLOW, result);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "/alockbiz [ID]");
        }
    }
    return 1;
}
Hi, you have a few errors that I spotted;
  • You didn't setup the local variable "result" (maybe you had this declared already? not familiar with your gamemode so not sure)
  • Not exactly an error, but your formatting wasn't very good, probably get a few loose indentation warnings
  • SYNTAX_MESSAGE"/alockbiz [ID]"); <-- there is no need for SYNTAX_MESSAGE here
  • You missed the else after the sscanf code (I believe it's needed) - not relevant if you used my code though
I've only been scripting a few days myself, but I think what I pointed out above is valid, if not I apologise for any inconvenience caused!

I think the code I posted is valid though!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)