Jump to content

Comanda script (/ban ) !


adiqua

Recommended Posts

10 hours ago, adiqua said:

Salut , As vrea si eu o comanda /ban sa poti da ban pe zile si permanent multumesc!

Poftim: 

CMD:ban(playerid, params[]) {
	if(playerVariables[playerid][pAdminLevel] >= 1) {
	    new
	        playerBanID,
	        days,
	        string[256],
	        playerBanReason[60];

	    if(sscanf(params, "uis[60]", playerBanID,days, playerBanReason))
	    	return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/ban [playerid] [days: 0 - permanently / max 999 days] [reason]");

	    if(IsPlayerConnected(playerBanID))
	    {
		    if(playerVariables[playerBanID][pAdminLevel] >= 1)
				return SendClientMessage(playerid, COLOR_GREY, "You can't ban an administrator.");


			new aString[384];

			if(days == 0)
			{
				playerVariables[playerBanID][pBanned] = 1;

		       	format(aString, sizeof(aString), "Ban: %s has been permanent banned by %s, reason: %s", playerVariables[playerBanID][pNormalName], playerVariables[playerid][pNormalName], playerBanReason);
		       	SendClientMessageToAll(COLOR_LIGHTRED, aString);
		       	mysql_real_escape_string(aString, aString);
		       	adminLog(aString);
				format(szMessage, sizeof(szMessage), "INSERT INTO lastpunish (text, playerID) VALUES ('%s', '%d')", aString,playerVariables[playerBanID][pInternalID]);
				mysql_tquery(handle,szMessage);
		       	format(aString, sizeof(aString), "INSERT INTO bans (playerNameBanned, playerBannedBy, playerBanReason) VALUES('%s', '%s', '%s')", playerVariables[playerBanID][pNormalName], playerVariables[playerid][pNormalName], playerBanReason);
				mysql_tquery(handle,aString);
				SetTimerEx("kick2", 1000, 0, "d", playerBanID);
			}
			else if((days >= 1) && (days <= 999))
			{

				new File:tempban = fopen("TempBans.ban", io_append);
		        if(tempban)
		        {
		                new year,month,day;
		                getdate(year, month, day);
		                day += days;
		                if (IsMonth31(month))
		                {
		                    if (day > 31)
		                    {
		                        month += 1;
		                        if (month > 12)
		                        {
		                            year += 1;
		                            while(day > 31) day -= 31;
		                        }
		                        else while(day > 31) day -= 31;
		                    }
		                }
		                else if (!IsMonth31(month))
		                {
		                    if (day > 30)
		                    {
		                        month += 1;
		                        if (month > 12)
		                        {
		                            year += 1;
		                            while(day > 30) day -= 30;
		                        }
		                        else while(day > 30) day -= 30;
		                    }
		                }
		                else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
		                {
		                    if (day > 29)
		                    {
		                        month += 1;
		                        if (month > 12)
		                        {
		                            year += 1;
		                            while(day > 29) day -= 29;
		                        }
		                        else while(day > 29) day -= 29;
		                    }
		                }
		                else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
		                {
		                    if (day > 28)
		                    {
		                        month += 1;
		                        if (month > 12)
		                        {
		                            year += 1;
		                            while(day > 28) day -= 28;
		                        }
		                        else while(day > 28) day -= 28;
		                    }
		                }
		        }
				format(string, sizeof(string), "Ban: %s has been banned by %s for %d days, reason: %s",playerVariables[playerBanID][pNormalName], playerVariables[playerid][pNormalName], days, playerBanReason);
				SendClientMessageToAll(COLOR_LIGHTRED, string);
				adminLog(string);

				new str[128];
				format(str,128,"UPDATE `playeraccounts` SET `playerBanDays`='%d' WHERE `playerName`='%s'",days*24,playerVariables[playerBanID][pNormalName]);
				mysql_tquery(handle, str);

				format(szMessage, sizeof(szMessage), "INSERT INTO lastpunish (text, playerID) VALUES ('%s', '%d')", string,playerVariables[playerBanID][pInternalID]);
				mysql_tquery(handle,szMessage);
				SCM(playerBanID,-1,"Ai fost banat temporar de catre un admin!");
		        SetTimerEx("kick2", 1000, 0, "d", playerBanID);
			}
			else
			{
				SCM(playerid,-1,"Invalid amount of days");
			}
	    }
	}
	else return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
	return 1;
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.