Spaces in ZCMD and Car commands
#3

the problem with putting spaces "in zcmd":
you cannot put spaces in strcmp-designed commands either. no command processor does that.
a space is the delimeter to split parameters - but combined with that (parsing parameters), it is possible, tricky maybe, but look here:
Код:
CMD:car(playerid,params[]){
	new Action[16];
	if(!sscanf(params,"S(help)[16]",Action))
	{
		if(!sscanf(Action,"s(16)","help"))
		{
			SendClientMessage(playerid, COLOR_GREEN, "/Car Bonnet/Trunk/Lights");
			return 1;
		}
		if(!sscanf(Action,"s(16)","bonnet"))
		{
			SendClientMessage(playerid, COLOR_GREEN, "Vehicle bonnet opened");
			return 1;
		}
		if(!sscanf(Action,"s(16)","trunk"))
		{
			SendClientMessage(playerid, COLOR_GREEN, "Vehicle trunk opened");
			return 1;
		}
		if(!sscanf(Action,"s(16)","lights"))
		{
			SendClientMessage(playerid, COLOR_GREEN, "Vehicle lights enabled");
			return 1;
		}
	}
	return 1;
}
if you understand the SetVehicleParamsEx functin mentioned above, then you can copy-n-paste the Get/Set parameter lines, and insert them into my spaghetti-code. after changing the desired variable (opening/closing bonnet/trunk etc), the commands can be improved further:
by setting a (player)variable for the vehicles' parts status (0=closed/switched off, 1=opened/switched on bonnet/trunk/door(s)/light(s))... < i know, that looks horrible ^^
...then you can additionally add one more string to the parameters. if they are given as optional (uppercase "S" strings, you might want to add a default switch for lazy players, like "switch" for changing the variable from 0 to 1, and 1 to 0.
switching a binary, is simply done by doing bit=1-bit;

ok, i edited some more, and added the option (can be left out ingame, so it defaults to "switch"):
Код:
CMD:car(playerid,params[]){
	new Part[16],Action[16];
	if(!sscanf(params,"S(help)[16]S(switch)[16]",Part,Action))
	{
		if(!sscanf(Part,"s(16)","help"))
		{
			SendClientMessage(playerid, COLOR_GREEN, "/car <bonnet/trunk/lights> <switch / on/open / off/close>");
			return 1;
		}
		if(!sscanf(Part,"s(16)","bonnet"))
		{
			if(!sscanf(Action,"s(16)","switch"))
			{
				VehicleBonnet[vehicleid]=1-VehicleBonnet[vehicleid];
			}
			else if(!sscanf(Action,"s(16)","open"))
			{
				VehicleBonnet[vehicleid]=1;
			}
			else if(!sscanf(Action,"s(16)","close"))
			{
				VehicleBonnet[vehicleid]=0;
			}
			switch(VehicleBonnet[vehicleid])
			{
				case 0:
				{
					SendClientMessage(playerid, COLOR_GREEN, "Vehicle bonnet closed");
				}
				case 1:
				{
					SendClientMessage(playerid, COLOR_GREEN, "Vehicle bonnet opened");
				}
			}
			//SetVehicleParamsEx();// thats your job ^^
		}
thats only for the bonnet - try that first (not tested!), it it works, good. if not, good: fixing bugs=learning.
Reply


Messages In This Thread
Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 13:55
Re: Spaces in ZCMD and Car commands - by Mr.Anonymous - 04.01.2013, 14:20
Re: Spaces in ZCMD and Car commands - by Babul - 04.01.2013, 15:04
Re: Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 15:14
Re: Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 15:17
Re: Spaces in ZCMD and Car commands - by Babul - 04.01.2013, 15:26
Re: Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 15:41
Re: Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 15:45
Re: Spaces in ZCMD and Car commands - by Astrais - 04.01.2013, 15:48
Re: Spaces in ZCMD and Car commands - by Babul - 04.01.2013, 15:51

Forum Jump:


Users browsing this thread: 1 Guest(s)