27.07.2015, 03:57
How can I make comenile to use sscanf to shorten and more of them?
You can replace the mysql terms from r5 with r39?
cuisine +1
Код:
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;
}
cuisine +1


