Help Needed
#1

Hey guys,
I created a off-ban cmd for my server, which is working, but instead of banning the name it bans name "я"
Here is the code:=
Код:
COMMAND:oban(playerid, params[])
{
	if(playerData[playerid][playerLoggedIn])
	{
		if(playerData[playerid][playerLevel] >= 4)
		{
			new playerName[24], playersIP[24], message[248], reason[300];

			if(sscanf(params, "us[300]", playerName, reason))
			{
				SendClientMessage(playerid, COLOR_ORANGE, "Usage: \"oban <playerName> <reason>\"");
			}
			else
			{
				new banreason[200];

				// Query
				format(banreason, sizeof(banreason), "INSERT INTO `playerbans` (`banned_by`, `banned_for`, `player_banned`, `player_ip`) VALUES ('%s', '%s', '%s', '%s')", playerData[playerid][tempAdminName], reason, playerName, playersIP);
				mysql_query(banreason, MYSQL_ADD_BAN, playerid, connection);

                                format(message, sizeof(message), "%s Has Been Offine Banned from the server![Reason:-%s]", playerName, reason);
                                SendClientMessageToAll(COLOR_RED, message);
			}
		}
		else
		{
			return 0;
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
	}

	return 1;
}
It have a lot of mistakes, but just need help in the name, +rep if solved!!!
Reply
#2

I Have fixed, but it giving warning stings without a length are deprecated, please add a destination size!

New Code:-
Код:
COMMAND:oban(playerid, params[])
{
	if(playerData[playerid][playerLoggedIn])
	{
		if(playerData[playerid][playerLevel] >= 4)
		{
			new playerName[24], playersIP[24], message[248], reason[300];

			if(sscanf(params, "us[300]", playerName, reason))
			{
				SendClientMessage(playerid, COLOR_ORANGE, "Usage: \"oban <playerName> <reason>\"");
			}
			else
			{
				new banreason[200];

				// Query
				format(banreason, sizeof(banreason), "INSERT INTO `playerbans` (`banned_by`, `banned_for`, `player_banned`, `player_ip`) VALUES ('%s', '%s', '%s', '%s')", playerData[playerid][tempAdminName], reason, playerName, playersIP);
				mysql_query(banreason, MYSQL_ADD_BAN, playerid, connection);

                                format(message, sizeof(message), "%s Has Been Offine Banned from the server![Reason:-%s]", playerName, reason);
                                SendClientMessageToAll(COLOR_RED, message);
			}
		}
		else
		{
			return 0;
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
	}

	return 1;
}
Reply
#3

PHP код:
if(sscanf(params"us[300]"playerNamereason)) 
Here at this line, since playerName's size is declared as 24 you also need to mention it here and playername is a string when you have declared its size so rename it as a string
Here is the fixed line
PHP код:
if(sscanf(params"s[24]s[300]"playerNamereason)) 
Reply
#4

Quote:
Originally Posted by Debjit
Посмотреть сообщение
PHP код:
if(sscanf(params"us[300]"playerNamereason)) 
Here at this line, since playerName's size is declared as 24 you also need to mention it here and playername is a string when you have declared its size so rename it as a string
Here is the fixed line
PHP код:
if(sscanf(params"s[24]s[300]"playerNamereason)) 
Thanks buddy fixed, +reped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)