Help!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#1

Hi Guys i need Help to add oban CMD Please Help me


Код:
COMMAND:oban(playerid, params[])
{
	if(playerData[playerid][playerLoggedIn])
	{
		if(playerData[playerid][Admin] >= 3)
		{
			new otherID, playersIP[24], playerName[24], adminName[24], message[248], reason[300];

			if(sscanf(params, "us[300]", otherID, reason))
			{
				SendClientMessage(playerid, COLOR_ORANGE, "Usage: \"oban <playername/id> <reason>\"");
			}
			else
			{
				if(IsPlayerConnected(otherID))
				{
					if(playerData[otherID][playerLoggedIn])
					{
						if(playerData[playerid][Admin] >= playerData[otherID][Admin])
						{
							// Send message to game
							GetPlayerName(otherID, playerName, sizeof(playerName));
							GetPlayerName(playerid, adminName, sizeof(adminName));
							GetPlayerIp(otherID, playersIP, sizeof(playersIP));
							
							format(message, sizeof(message), "{A9C4E4}%s(%i) has been banned from the server {FF0000}[REASON: %s]{FFFFFF}", playerName, otherID, reason);
							SendClientMessageToAll(COLOR_WHITE, message);
							
							new aMsg[300];
							for (new i=0; i<MAX_PLAYERS; i++)
							{
								if (playerData[i][Admin] >= 0)
								{
									format(aMsg, sizeof(aMsg), "{FF006F}[ADMIN] {FF006F}%s(%i) has banned %s(%i) {FF006F}[REASON: %s]{FFFFFF}", playerData[playerid][playerNamee], playerid, playerData[otherID][playerNamee], otherID, reason);
									SendClientMessage(i, COLOR_WHITE, aMsg);
								}
							}		
							
							new log[250];
							format(log, sizeof(log), "%s(%i) has banned %s(%i)", playerData[playerid][tempAdminName], playerid, playerName, otherID);
							SendAdminText(playerid, log);
							
							new banreason[350];
							format(banreason, sizeof(banreason), "INSERT INTO `playerbans` (`banned_by`, `banned_for`, `player_banned`, `player_ip`) VALUES ('%s', '%s', '%s', '%s')", adminName, reason, playerName, playersIP);
							mysql_query(banreason, MYSQL_ADD_BAN, playerid, connection);
							
							KickWithMessage(otherID, "[BANNED] You have been banned. You may appeal on |SA-MP.com");
						}
						else
						{
							SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot use this command on that player.");
						}
					}
					else
					{
						SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is not logged in!");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is not online!");
				}
			}
		}
		else
		{
			return 0;
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
	}
		
	return 1;
}
Reply
#2

Please use the pawn tags for codes, this way it just looks shit and nearly impossible to read
Reply
#3

Help with what? You're not even stating what your problem is. And like thegamer said, use code tags.

This kind of command structure, while not wrong per se, is also super annoying to dissect. I wouldn't nest compound blocks more than three levels deep. For example, the check to see if the player is logged in takes place at line 3. Yet related code for when the player is not logged in only appears at line 72. And this gets worse the more additional checks are added. I personally like to read code top-to-bottom, not zigzag. Get all the preliminary conditions out of the way first by inverting each statement and immediately returning if the condition is not fulfilled, e.g.:
PHP код:
if(!playerData[playerid][playerLoggedIn])
    return 
SendClientMessage(playeridCOLOR_WHITE"{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands."); 
Reply
#4

Can you put your codes into the pawn tag
like
pawn Код:
msg
Reply
#5

DonE Bros i need To add oban CMD Help me
Reply
#6

What's the issue with your code?

You still never said what the issue is.

Or do you want us to convert the code from /ban to /oban?
Reply
#7

i want to Make it oban CMD
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)