20.10.2012, 18:43
I know how sscanf optional parameters work - you have to provide a 'default' value or whatever, but how can I tell if a player passed that parameter or not? They could pass the default value..
CMD:carcol(playerid,params[]){ new Col1,option[16],Col2,string[64]; if (sscanf(params,"dS[16]",Col1,option)) { SendClientMessage(playerid,MSGCMDS_COLOR, "Usage: \"/CarCol <Col1> [Col2] [Col3 (=Trailer)]\""); return 1; } else { //here a strlen, isnull, or whatever check? if (sscanf(option,"d",Col2)) { SendClientMessage(playerid,MSGINFO_COLOR, "Color1 will be the same as Color2."); Col2=Col1; } new VehicleID=GetPlayerVehicleID(playerid); ChangeVehicleColor(VehicleID,Col1,Col2); SetGVarInt("VehCol1",Col1,VehicleID); SetGVarInt("VehCol2",Col2,VehicleID); format(string,sizeof(string),"Colors changed to %d - %d.",Col1,Col2); SendClientMessage(playerid,MSGSUCC_COLOR,string); new TrailerID; TrailerID=GetVehicleTrailer(VehicleID); if(TrailerID>0) { ChangeVehicleColor(TrailerID,Col1,Col2); SetGVarInt("VehCol1",Col1,TrailerID); SetGVarInt("VehCol2",Col2,TrailerID); format(string,sizeof(string),"Trailer colors changed aswell."); SendClientMessage(playerid,MSGSUCC_COLOR,string); } } return 1; }
You can't really, the point of the defaults is to pick something they can't type, of course that isn't always possible. Sorry, just assume that if they typed a stupid value they're being stupid, and try make the message generic like "please enter a value between 0 and 27" - then it doesn't matter if what they typed was wrong or if they typed nothing.
|