Hi. I made this faction system command, and it returns fine, however when I put a value for some of the sub-options, it doesnt do anything.
Код:
CMD:setfaction(playerid, params[])
{
new string[128], facid;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "is[32]", facid, params))
{
if(facid > MAX_FACTIONS || facid < 0) return SCM(playerid, ADMIN, "Factions 1-20 only.");
SendClientMessage(playerid, COLOR_GREY, "USAGE: /setfaction [option] [ID]");
SendClientMessage(playerid, ADMIN, "OPTIONS: spawn | type | name | rankname");
return 1;
}
if(!strcmp(params, "spawn", true))
{
GetPlayerPos(playerid, FacInfo[facid][fX], FacInfo[facid][fY], FacInfo[facid][fZ]);
FacInfo[facid][fInt] = GetPlayerInterior(playerid);
FacInfo[facid][fVW] = GetPlayerVirtualWorld(playerid);
format(string, sizeof(string), "[AdmCmd] {FFFFFF}%s set faction %d's spawn in %s. {006600}[INT:%d, VW:%d]", RPN(playerid), facid, GZ(playerid), GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
SendAdminMessage(COLOR_GREEN, 1, string);
Log("logs/factions.log", string);
}
else if(!strcmp(params, "type", true))
{
new type, typenam[32];
if(sscanf(params, "is[32]i", facid, params, type)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setfaction [fac id] [type(1-3)]");
{
if(type < 0 || type > 3) return SCM(playerid, GREY, "Types: 1) Law Enforcement | 2) Transportation | 3) Criminal/Gang");
if(type == 1) { typenam = "Law Enforcement"; }
if(type == 2) { typenam = "Transportation/Public Service"; }
if(type == 3) { typenam = "Criminal/Gang"; }
FacInfo[facid][factype] = type;
}
format(string, sizeof(string), "[AdmCmd] {FFFFFF}%s set faction %d's type to %d. (%s)", RPN(playerid), facid, type, typenam);
SendAdminMessage(COLOR_GREEN, 1, string);
Log("logs/factions.log", string);
}
else if(!strcmp(params, "name", true))
{
new FName[64];
if(sscanf(params, "is[32]s[64]", facid, params, FName)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setfaction [facid] name [name(64 characters)]");
{
format(string, sizeof(string), "[AdmCmd] {FFFFFF}%s set faction %d's name to: [ %s ]", RPN(playerid), facid, FName);
format(FacInfo[facid][facName], sizeof(FName), FName);
SendAdminMessage(COLOR_GREEN, 1, string);
Log("logs/factions.log", string);
}
}
else if(!strcmp(params, "rankname", true))
{
new name[32], rank;
if(sscanf(params, "is[32]is[32]", facid, params, rank, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setfaction [facid] rankname [rank ID(0-9)] [Name]");
{
if(rank < 0 || rank > 9) return SCM(playerid, ADMIN, "Ranks 0-9 only");
switch(rank)
{
case 0:
{
format(FacInfo[facid][fRank0], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 1:
{
format(FacInfo[facid][fRank1], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 2:
{
format(FacInfo[facid][fRank2], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 3:
{
format(FacInfo[facid][fRank3], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 4:
{
format(FacInfo[facid][fRank4], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 5:
{
format(FacInfo[facid][fRank5], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 6:
{
format(FacInfo[facid][fRank6], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 7:
{
format(FacInfo[facid][fRank7], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 8:
{
format(FacInfo[facid][fRank8], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
case 9:
{
format(FacInfo[facid][fRank9], 32, "%s", name);
format(string, sizeof(string), "[FacInfo] {FFFFFF}Faction %d's rank %d set to %s.", facid, rank, name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
}
}
format(string, sizeof(string), "[SERVER] %s set faction %d's rank %d to %s", RPN(playerid), facid, rank, name);
Log("logs/faction.log", string);
}
SaveFactions();
return 1;
}