sscanf +msysql 39-3
#1

How can I make comenile to use sscanf to shorten and more of them?

Код:
CMD:makeleaderoff(playerid,params[])
	{
		new idx, string[128];
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] > 5)
	        {
	         	new length = strlen(params);
				while ((idx < length) && (params[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[128];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = params[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_GRAD2, "{00FF00}Folosire:{FFFFFF} /makeleaderoff [NUMELE-EXACT]");
					return 1;
				}
			   	format(string, sizeof(string), "SELECT `username` FROM `players` WHERE username = '%s' AND Leader > 0 LIMIT 1", (result));
				mysql_query(string);
				mysql_store_result();
				if(!mysql_num_rows())
				{
			    	format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu factiune!", (result));
					mysql_free_result();
					return SendClientMessage(playerid, 0xEF5C5CFF, string);
				}
				else if(mysql_num_rows() != 0)
				{
				    format(string, sizeof(string), "UPDATE `players` SET `Leader` = 0 WHERE username = '%s'", (result));
					mysql_query(string);
					mysql_store_result();
					format(string, sizeof(string), "{0066FF}[Info:] {FFFFFF}%s nu mai este lider!", (result));
					ABroadCast(0xa9c4e4FF, string, 1);
					mysql_free_result();
				}
			}
	    }
   		return 1;
	}
//========================================[CMD /MAKEHELPEROFF]===============================================//
CMD:makehelperoff(playerid,params[])
{
	new idx, string[128];
	if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] > 5)
	        {
	         	new length = strlen(params);
				while ((idx < length) && (params[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[128];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = params[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_GRAD2, "{00FF00}Folosire:{FFFFFF} /makehelperoff [NUMELE-EXACT]");
					return 1;
				}
			   	format(string, sizeof(string), "SELECT `username` FROM `players` WHERE username = '%s' AND Trial > 0 LIMIT 1", (result));
				mysql_query(string);
				mysql_store_result();
				if(!mysql_num_rows())
				{
			    	format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu asistent!", (result));
					mysql_free_result();
					return SendClientMessage(playerid, 0xEF5C5CFF, string);
				}
				else if(mysql_num_rows() != 0)
				{
				    format(string, sizeof(string), "UPDATE `players` SET `Trial` = 0 WHERE username = '%s'", (result));
					mysql_query(string);
					mysql_store_result();
					format(string, sizeof(string), "{0066FF}[Info:] {FFFFFF}%s nu mai este asistent!", (result));
					ABroadCast(0xa9c4e4FF, string, 1);
					mysql_free_result();
				}
			}
	    }
  	    return 1;
   }
//========================================[CMD /MAKEADMINOFF]================================================//
CMD:makeadminoff(playerid,params[])
{
	new idx, string[128];
	if(IsPlayerConnected(playerid))
	{
		if(PlayerInfo[playerid][pAdmin] > 5)
		{
			new length = strlen(params);
			while ((idx < length) && (params[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = params[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "{00FF00}Folosire:{FFFFFF} /makeadminoff [NUMELE-EXACT]");
				return 1;
			}
			format(string, sizeof(string), "SELECT `username` FROM `players` WHERE username = '%s' AND AdminLevel > 0 LIMIT 1", (result));
			mysql_query(string);
			mysql_store_result();
			if(!mysql_num_rows())
			{
				format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu admin!", (result));
				mysql_free_result();
				return SendClientMessage(playerid, 0xEF5C5CFF, string);
			}
			else if(mysql_num_rows() != 0)
			{
				format(string, sizeof(string), "UPDATE `players` SET `AdminLevel` = 0 WHERE username = '%s'", (result));
				mysql_query(string);
				mysql_store_result();
				format(string, sizeof(string), "{0066FF}[Info:] {FFFFFF}%s nu mai este admin!", (result));
				ABroadCast(0xa9c4e4FF, string, 1);
				mysql_free_result();
			}
		}
	}
	return 1;
}
You can replace the mysql terms from r5 with r39?

cuisine +1
Reply
#2

upppp
Reply
#3

Try more English. Like what does comenile mean? Need more information to be able to help you
Reply
#4

commandes* sorry
Reply
#5

uppp?
Reply
#6

missing bracket hear:
Код:
forward OnPlayerMysql(playerid, response, str[]);
public OnPlayerMysql(playerid, response, str[])
{
    switch(response)
    {
        case 1: // command makeleaderoff
        {
            if (cache_num_rows())
            {
                new query[78];
                mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Leader` = 0 WHERE username = '%e'", str);
                mysql_query(mysql, query, false);
            }
            else{
                new string[75];
                format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu factiune!", str);
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        case 2: // command makehelperoff.
        {
            if (cache_num_rows())
            {
                new query[77];
                mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Trial` = 0 WHERE username = '%s'", str);
                mysql_query(mysql, query, false);
			}
			else{
                new string[75];
                format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu factiune!", str);
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        case 3: // command makeadminoff.
        {
            if (cache_num_rows())
            {
                new query[82];
                mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `AdminLevel` = 0 WHERE username = '%e'", str);
                mysql_query(mysql, query, false);
            }
            else{
                new string[75];
                format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu factiune!", str);
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
    }
    return true;
}
Reply
#7

up[pppp
Reply
#8

Hello!

Where are your problem? If you know that there is missing a bracket why you don't fix this problem?

How we can help you know?
Reply
#9

IM missing none but still gives me the error from braces
Reply
#10

Can you send us the error and the current code of this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)