19.06.2015, 15:51
You used 'd' in sscanf, it will be converted to in integer therefore you only need to do "rank == 1"
Also your code wont work like that because if you do "if(sscanf(params, "s[10]", option))"
It will put the whole string into options, no matter if there is a space behind (last 's' gets the remaining string)
Also your code wont work like that because if you do "if(sscanf(params, "s[10]", option))"
It will put the whole string into options, no matter if there is a space behind (last 's' gets the remaining string)
pawn Код:
MD:fedit(playerid,params[]) {
if(pInfo[playerid][USER_FACTION] < 1 || pInfo[playerid][USER_FACTIONRANK] < 10) {
return SendClientMessage(playerid, -1, "You have no permission to use this command.");
}
new
option[10]
;
if(sscanf(params, "s[10]S[128]", option, params)) {
return SendClientMessage(playerid, -1, "[USAGE]: /fedit (facname | rank (1-10) | motd)");
}
if(!strcmp(option, "facname", true)) {
if(strlen(params) > 50) {
return SendClientMessage(playerid, -1, "Faction name to long");
}
new
string[256],
idx = pInfo[playerid][USER_FACTION]
;
fInfo[idx][FNAME][0] = EOS;
strcat(fInfo[idx][FNAME], params, 50);
format(string, sizeof string, "UPDATE factioninfo SET fname = '%s' WHERE fid = %d", params, fInfo[idx][FID]);
db_query(FDatabase, Query);
format(string, sizeof string, "You have changed the faction name to %s.", params);
return SendClientMessage(playerid, -1, string);
}
if(!strcmp(option, "rank", true)) {
new
rankname[50],
rank
;
if(sscanf(params, "ds[50]", rank, rankname)) {
return SendClientMessage(playerid, -1, "[USAGE]: /fedit rank (rank number) (rank name)."
}
switch(rank) {
case 1: {
// ...
}
}
// ...
}
return true;
}