sscanf warning!
#1

when i use this command
Код:
CMD:editevent(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][pHelper] >= 3 || PlayerInfo[playerid][pDonateRank] >= 4)
	{
		if(EventKernel[EventCreator] == playerid || PlayerInfo[playerid][pAdmin] >= 4)
		{
			new choice[32], opstring[64];
			if(EventKernel[EventType] == 1)
			{
			    if(sscanf(params, "s[32]S[64]", choice, opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent [name]");
					SendClientMessageEx(playerid, COLOR_GREY, "Available names: Jointext, Limit, Health, Armor, Gun1, Gun2, Gun3, Gun4, Gun5");
					return 1;
				}
			}
			else if(EventKernel[EventType] == 2)
			{
			    if(sscanf(params, "s[32]S[64]", choice, opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent [name]");
					SendClientMessageEx(playerid, COLOR_GREY, "Available names: Jointext, Limit, Team1Skin, Team2Skin, Team1Color, Team2Color");
					SendClientMessageEx(playerid, COLOR_GREY, "Team1Spawn, Team2Spawn, Health, Armor, Gun1, Gun2, Gun3, Gun4, Gun5");
					return 1;
				}
			}
			else if(EventKernel[EventType] == 3)
			{
			    if(sscanf(params, "s[32]S("")[64]", choice, opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent [name]");
					SendClientMessageEx(playerid, COLOR_GREY, "Available names: Jointext, Limit, Health, Hours, CheckPoints, RaceType(Future Development), OnFoot(0/1)");
					return 1;
				}
			}
			else if(EventKernel[EventType] == 4)
			{
			    if(sscanf(params, "s[32]S[64]", choice, opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent [name]");
					SendClientMessageEx(playerid, COLOR_GREY, "Available names: Jointext, Limit, Health, Armor, Gun1, Gun2, Gun3, Gun4, Gun5");
					return 1;
				}
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_GREY, "You need to set the event type first!");
				return 1;
			}

			if(strcmp(choice, "jointext",true) == 0)
			{
				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent jointext [text]");
					return 1;
				}
				strmid(EventKernel[EventInfo], opstring, 0, strlen(opstring), 64);
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event join text.");
			}
			else if(strcmp(choice, "health", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 3 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent health [health]");
					return 1;
				}
				new Float: health;
				health = floatstr(opstring);
				EventKernel[EventHealth] = health;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event health.");
			}
			else if(strcmp(choice, "armor", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_WHITE, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent armor [armor]");
					return 1;
				}

				new Float: armor;
				armor = floatstr(opstring);
				EventKernel[EventArmor] = armor;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event armor.");
			}
			else if(strcmp(choice, "team1skin", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_WHITE, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent team1skin [skinid]");
					return 1;
				}

				new skin;
				skin = strval(opstring);
				EventKernel[EventTeamSkin][0] = skin;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event team 1 skin.");
			}
			else if(strcmp(choice, "team2skin", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent team2skin [skinid]");
					return 1;
				}

				new skin;
				skin = strval(opstring);
				EventKernel[EventTeamSkin][1] = skin;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event team 2 skin.");
			}
			else if(strcmp(choice, "team1color", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!strlen(opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent team1color [color]");
					SendClientMessageEx(playerid, COLOR_GREY, "black | white | blue | red | green | purple | yellow | lightblue |");
					SendClientMessageEx(playerid, COLOR_GREY, "darkgreen | darkblue | darkgrey | brown | darkbrown | darkred | pink ");
					return 1;
				}
				EventKernel[EventTeamColor][0] = GetColorCode(opstring);
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event team 1 color.");
			}
			else if(strcmp(choice, "team2color", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!strlen(opstring))
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent team2color [color]");
					SendClientMessageEx(playerid, COLOR_GREY, "black | white | blue | red | green | purple | yellow | lightblue |");
					SendClientMessageEx(playerid, COLOR_GREY, "darkgreen | darkblue | darkgrey | brown | darkbrown | darkred | pink ");
					return 1;
				}
				EventKernel[EventTeamColor][1] = GetColorCode(opstring);
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event team 2 color.");
			}
			else if(strcmp(choice, "team1spawn", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}
				GetPlayerPos(playerid, EventKernel[ EventTeamPosX1 ], EventKernel[ EventTeamPosY1 ], EventKernel[ EventTeamPosZ1 ] );
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted team 1's spawn position.");
			}
			else if(strcmp(choice, "team2spawn", true) == 0)
			{
				if(EventKernel[EventType] != 2)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This feature is not available for this event type.");
					return 1;
				}
				GetPlayerPos(playerid, EventKernel[ EventTeamPosX2 ], EventKernel[ EventTeamPosY2 ], EventKernel[ EventTeamPosZ2 ]);
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted team 2's spawn position.");
			}
			else if(strcmp(choice, "limit", true) == 0)
			{
			    if(EventKernel[EventTime] != 0)
			        return SendClientMessageEx(playerid, COLOR_GRAD2, "This feature is not available for this event, everyone is free to join. If you want to enable this please set the hours to 0.");
				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent limit [limit 0-60]");
					return 1;
				}

				new limit;
				limit = strval(opstring);
				if(limit < 0 || limit > 120) return SendClientMessageEx(playerid, COLOR_RED, "You cannot adjust the event limit higher than 120 or below 0");
				EventKernel[EventLimit] = limit;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the players in event limit.");
			}
			else if(strcmp(choice, "hours", true) == 0)
			{
			    if(EventKernel[EventType] != 3)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This feature is not available for this event type.");
					return 1;
				}
				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent hours [hours 0-5]");
					return 1;
				}

				new hours, seconds;
				hours = strval(opstring);
				if(hours < 0 || hours > 5) return SendClientMessageEx(playerid, COLOR_RED, "You cannot adjust the event hours higher than 5 or below 0");
				seconds = hours*3600;
				EventKernel[EventTime] = seconds;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event hours that the event will be active for, timer will start once you fully start the event.");
                SendClientMessageEx(playerid, COLOR_GREY, "NOTE: If you set the event hours to 0 the event will finish once the last racer goes into the last checkpoint.");
				if(hours != 0)
					SendClientMessageEx(playerid, COLOR_YELLOW, "The feature players in event limit(/editevent limit) is now disabled since you changed the hours more than 0.");
			}
   			else if(strcmp(choice, "checkpoints", true) == 0)
			{
				if(EventKernel[EventType] != 3)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This feature is not available for this event type.");
					return 1;
				}
				ConfigEventCPs[playerid][0] = 1;
				ConfigEventCPs[playerid][1] = 0;
				ConfigEventCPs[playerid][2] = 0;
				ConfigEventCPId[playerid] = 0;
				new string[279];
				format(string,sizeof(string),"Welcome to the race checkpoint configuration system!\nThis is a quick guide on the steps you need to follow to successfully get the race checkpoints done.\nFirst and most important you need to remember to make the checkpoints in order, from the start line to the end line.");
				ShowPlayerDialog(playerid,RCPINTRO,DIALOG_STYLE_MSGBOX,"Race Checkpoints Introduction",string,"Next","Skip");
			}
			else if(strcmp(choice, "onfoot", true) == 0)
			{
				if(EventKernel[EventFootRace])
				{
				    EventKernel[EventFootRace] = 0;
					SendClientMessageEx(playerid, COLOR_GRAD2, "You have toggled off the onfoot feature, people can use vehicles(Future development, please don't use not working proprely)");
				}
				else {
				    EventKernel[EventFootRace] = 1;
					SendClientMessageEx(playerid, COLOR_GRAD2, "You have toggled on the onfoot feature, people cannot use vehicles.");
				}
			}
			else if(strcmp(choice, "gun1", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent gun1 [weaponid]");
					return 1;
				}

				new weapon;
				weapon = strval(opstring);
				if(weapon == 16 || weapon == 18 || weapon == 35 || weapon == 37 || weapon == 38 || weapon == 39) return SendClientMessageEx(playerid, COLOR_WHITE, "This weapon cannot be set as an event weapon!");
				EventKernel[EventWeapons][0] = weapon;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event gun 1.");
			}
			else if(strcmp(choice, "gun2", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent gun1 [weaponid]");
					return 1;
				}

				new weapon;
				weapon = strval(opstring);
				if(weapon == 16 || weapon == 18 || weapon == 35 || weapon == 37 || weapon == 38 || weapon == 39) return SendClientMessageEx(playerid, COLOR_WHITE, "This weapon cannot be set as an event weapon!");
				EventKernel[EventWeapons][1] = weapon;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event gun 2.");
			}
			else if(strcmp(choice, "gun3", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent gun1 [weaponid]");
					return 1;
				}

				new weapon;
				weapon = strval(opstring);
				if(weapon == 16 || weapon == 18 || weapon == 35 || weapon == 37 || weapon == 38 || weapon == 39) return SendClientMessageEx(playerid, COLOR_WHITE, "This weapon cannot be set as an event weapon!");
				EventKernel[EventWeapons][2] = weapon;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event gun 3.");
			}
			else if(strcmp(choice, "gun4", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent gun1 [weaponid]");
					return 1;
				}

				new weapon;
				weapon = strval(opstring);
				if(weapon == 35 || weapon == 37 || weapon == 38) return SendClientMessageEx(playerid, COLOR_WHITE, "This weapon cannot be set as an event weapon!");
				EventKernel[EventWeapons][3] = weapon;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event gun 4.");
			}
			else if(strcmp(choice, "gun5", true) == 0)
			{
				if(EventKernel[EventType] != 1 && EventKernel[EventType] != 2 && EventKernel[EventType] != 4)
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "This name is not available for this event type.");
					return 1;
				}

				if(!opstring[0])
				{
					SendClientMessageEx(playerid, COLOR_GREY, "SUDUNG: /editevent gun1 [weaponid]");
					return 1;
				}

				new weapon;
				weapon = strval(opstring);
				if(weapon == 35 || weapon == 37 || weapon == 38) return SendClientMessageEx(playerid, COLOR_WHITE, "This weapon cannot be set as an event weapon!");
				EventKernel[EventWeapons][4] = weapon;
				SendClientMessageEx(playerid, COLOR_WHITE, "You have sucessfully adjusted the event gun 5.");
			}
		}
	}
	return 1;
}
The text show up in server_log
Код:
[19:39:16] sscanf warning: No default value found.
[19:39:16] sscanf warning: Unknown format specifier '[', skipping.
[19:39:16] sscanf warning: Unknown format specifier '6', skipping.
[19:39:16] sscanf warning: Unknown format specifier '4', skipping.
[19:39:16] sscanf warning: Unknown format specifier ']', skipping.
[19:39:16] sscanf warning: Format specifier does not match parameter count.
Reply
#2

S[64] should be with small letter - s[64]

Wrong

if(sscanf(params, "s[32]S[64]", choice, opstring))

Correct

if(sscanf(params, "s[32]s[64]", choice, opstring))
Reply
#3

Thanks, it work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)