19.06.2015, 15:16
Hello, I have been working on a command that consists of multi parameters my concern is if I can store an integer inside a string or use something else, I am kind of confused about it so i'd appreciate if you could tell me if I use strcmp or something else to check if a player wrote that integer.
Here is my code
Here is my code
pawn Код:
CMD:fedit(playerid,params[]) //This is the family edit command
{
new ranks[10], motd[50], option[10];
if(pInfo[playerid][USER_FACTION] < 1 && pInfo[playerid][USER_FACTIONRANK] < 10)
{
SendClientMessage(playerid, -1, "You have no permission to use this command.");
return 1;
}
if(pInfo[playerid][USER_FACTION] > 0 && pInfo[playerid][USER_FACTIONRANK] == 10)
{
if(sscanf(params, "s[10]", option))
{
SendClientMessage(playerid, -1, "[USAGE]: /fedit (facname | rank (1-10) | motd)");
return 1;
}
if(!strcmp(option, "facname", true))
{
new Query[256], string[256], factionname[50];
format(factionname, 50, "%s", params);
if(strlen(factionname) <= 50)
{
fInfo[pInfo[playerid][USER_FACTION]][FNAME] = factionname;
format(Query, sizeof(Query), "UPDATE factioninfo SET fname = '%s' WHERE fid = %d", fInfo[pInfo[playerid][USER_FACTION]][FNAME], fInfo[pInfo[playerid][USER_FACTION]][FID]);
db_query(FDatabase, Query);
format(string, sizeof(string), "You have changed the faction name to %s.", fInfo[pInfo[playerid][USER_FACTION]][FNAME]);
SendClientMessage(playerid, -1, string);
return 1;
}
}
if(!strcmp(option, "rank", true))
{
new Query[256], string[256], rankname[10], rank;
if(sscanf(params, "ds[50]", rank, rankname))
{
SendClientMessage(playerid, -1, "[USAGE]: /fedit rank (rank number) (rank name)."
return 1;
}
format(rankname, 10, "%s", params);
if(!strcmp(rank, "1", true)) // this is the line I am confused on.
{
}
return 1;
}