MySQL BlueG CMD unwarn
#6

The message pops up that the player has no warnings and the player has 3 warnings in the MySQL database.
Code:
CMD:unwarn(playerid, params[])
{
	if(pInfo[playerid][pAdmin] == 3)
	{
		new string[256], name[MAX_PLAYER_NAME], query[150], rows;
			
		if(sscanf(params, "s[24]", name))
		{
			SendClientMessage(playerid, -1, "Usage: /unwarn [name]");
			return 1;
		}

		mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 0, 1", name);
		new Cache:result = mysql_query(g_SQL, query);
		cache_get_row_count(rows);

		if(!rows)
		{
		    SendClientMessage(playerid, -1, "This name does not exist or there is no prohibition under this name.");
		}

		mysql_format(g_SQL, query, sizeof(query), "SELECT `warns` FROM `players` WHERE `username` = '%e' LIMIT 1", name);
		mysql_tquery(g_SQL, query);

	 	for(new i = 0; i < rows; i ++)
		{
			if(pInfo[i][pWarn] == 0) return SendClientMessage(playerid, -1, "The player has no warnings!");
			mysql_format(g_SQL, query, sizeof(query), "UPDATE `players` SET `warns` = `warns`-1 WHERE `id` = %d LIMIT 1", PlayerInfo[i][ID]);
			mysql_tquery(g_SQL, query);

	     	for(new x; x < MAX_PLAYERS; x++)
	     	{
		        if(pInfo[x][pAdmin] == 1)
		        {
					format(string, sizeof(string), "AdminWarn: %s(%d) unwarned %s", PlayerName(playerid), playerid, name);
					SendClientMessage(x, -1, string);
		        }
		    }
		}
		cache_delete(result);
	}
	else
	{
		SendClientMessage(playerid, -1, "You do not have access to the command!!");
	}
	return 1;
}
Reply


Messages In This Thread
MySQL BlueG CMD unwarn - by KamilPolska - 22.12.2018, 22:43
Re: MySQL BlueG CMD unwarn - by zerruv - 22.12.2018, 23:36
Re: MySQL BlueG CMD unwarn - by KamilPolska - 23.12.2018, 10:38
Re: MySQL BlueG CMD unwarn - by KamilPolska - 23.12.2018, 20:00
Re: MySQL BlueG CMD unwarn - by Tenka - 24.12.2018, 07:47
Re: MySQL BlueG CMD unwarn - by KamilPolska - 24.12.2018, 17:44

Forum Jump:


Users browsing this thread: 1 Guest(s)