Jump to content

Recommended Posts

Posted
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;
}

 

Posted
10 hours ago, adiqua said:

Este buna dar nu as vrea sa fie mysql sa fie cu if si alea

What? normal ca e pe mysql si acel if nu are treaba cu mysql.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.