SA-MP Forums Archive
Switch help - 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: Switch help (/showthread.php?tid=355068)



Switch help - PaulDinam - 28.06.2012

I want to make this command to use Cases.
the main command is /improve and sub is paintjob
Is he does /improve paintjob 1 so i will do something in case one till 2 and 3


here is the code
Код:
else if(!strcmp(x_imp,"paintjob",true))
			{
			    tmp = strtok(cmdtext, idx);
	  			if(!strlen(tmp))
	  			{
	  			    SendClientMessage(playerid, COLOR_GREY, ">> Please choose paintjob 0-2 ,3 to remove!");
					return 1;
	    		}
	    		new paint = strval(tmp);
	    		if(paint < 0 && paint > 3)
	    		{
	    		    SendClientMessage(playerid, COLOR_GREY, ">> Please choose paintjob 1-2 ,0 to remove!");
					return 1;
	    		}
				ChangeVehiclePaintjob(vehicleid,paint);
				VehicleInfo[vehicleid][vPaintJob] = paint;
	    		format(string, sizeof(string), "* %s sprays the vehicle.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				return 1;
			}



Re: Switch help - sleepysnowflake - 28.06.2012

You could do something like:

pawn Код:
switch(paint)
{

case 1: { SOMETHING HERE }
case 2: { SOMETHING HERE }
case 3: { SOMETHING HERE }
}