So, i'm working on dynamic system. I finished commands like "/afaction spawn" etc. but it looks like it doesn't save anything properly! Can you please look at my code and tell me what's wrong?
Код:
COMMAND:afrakcja(playerid, params[])
{
new string[128], otherstring[128];
new id, cmd[128], str[128];
if(IsPlayerAdmin(playerid))
{
if(sscanf(params, "sd", cmd, id) != 0)
{
return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id> <nazwa | komendy | rangi | skiny | spawn>");
}
if(strcmp("nazwa", cmd, true, 5) == 0)
{
new nazwa[64];
if(!sscanf(params, "sds", cmd, id, nazwa))
{
format(string, sizeof(string),"Faction_%d",id);
{
format(otherstring, sizeof(otherstring),"Faction_%d/FactionName", id); djSet(FACTIONS_FILE, otherstring, nazwa, true);
format(string,sizeof(string),"Zmieniłeś nazwe frakcji %d na %s.", id, nazwa);
SendClientMessage(playerid, COLOR_WHITE, str);
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id> <nazwa>");
}
else if(strcmp("komendy", cmd, true, 7) == 0)
{
new idkomend;
if(!sscanf(params, "sdd", cmd, id, idkomend))
{
format(string, sizeof(string),"Faction_%d",id);
{
format(otherstring, sizeof(otherstring),"Faction_%d/CommandType",id); djSetInt(FACTIONS_FILE, otherstring, idkomend, true);
format(string,sizeof(string),"Zmieniłeś ID komend frakcji %d na %d.", id, idkomend);
SendClientMessage(playerid, COLOR_WHITE, str);
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id> <id komend>");
}
else if(strcmp("rangi", cmd, true, 5) == 0)
{
new idrangi, nazwarangi[64];
if(!sscanf(params, "sdds", cmd, id, idrangi, nazwarangi))
{
if(idrangi >= 1 && idrangi <= 6)
{
format(string, sizeof(string),"Faction_%d",id);
{
format(otherstring, sizeof(otherstring),"Faction_%d/RankName%d",id, idrangi); djSet(FACTIONS_FILE, otherstring, nazwarangi, true);
format(string,sizeof(string),"Zmieniłeś nazwe rangi %d frakcji %d na %s.", idrangi, id, nazwarangi);
SendClientMessage(playerid, COLOR_WHITE, str);
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "W każdej frakcji jest tylko po 6 rang!");
}
else return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id> <id rangi> <nazwa rangi>");
}
else if(strcmp("skiny", cmd, true, 5) == 0)
{
new idskinu, idslotu;
if(!sscanf(params, "sddd", cmd, id, idslotu, idskinu))
{
if(idskinu >=0 && idskinu <=299)
{
if(idslotu >=1 && idslotu <=6)
{
format(string, sizeof(string),"Faction_%d",id);
{
format(otherstring, sizeof(otherstring),"Faction_%d/Skin%d", id, idslotu); djSetInt(FACTIONS_FILE, otherstring, idskinu, true);
format(string,sizeof(string),"Nastawiłeś skin %d na slocie %d.", idskinu, idslotu);
SendClientMessage(playerid, COLOR_WHITE, str);
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "Wybierz slot pomiędzy 1, a 6!");
}
else return SendClientMessage(playerid, COLOR_WHITE, "To nie jest prawidłowy skin!");
}
else return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id> <id slotu> <id skinu>");
}
else if(strcmp("spawn", cmd, true, 5) == 0)
{
new Float:x, Float:y, Float:z;
if(!sscanf(params, "sd", cmd, id))
{
format(string, sizeof(string),"Faction_%d",id);
{
GetPlayerPos(playerid, x, y, z);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/X",id); djSetFloat(FACTIONS_FILE, otherstring, x, true);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/Y",id); djSetFloat(FACTIONS_FILE, otherstring, y, true);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/Z",id); djSetFloat(FACTIONS_FILE, otherstring, z, true);
format(otherstring, sizeof(otherstring),"Faction_%d/Interior",id); djSetInt(FACTIONS_FILE, otherstring, GetPlayerInterior(playerid), true);
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "UŻYJ: /afrakcja <id>");
}
}
return 1;
}
Those are my commands for factions. (name, commands type, ranks, skins, spawn)
Код:
public LoadFactions()
{
new string[128], otherstring[128];
for(new i = 0; i < MAX_GROUPS; i++)
{
format(string, sizeof(string),"Faction_%d",i);
if(djIsSet(FACTIONS_FILE, string))
{
format(otherstring, sizeof(otherstring),"Faction_%d/FactionName",i); FactionInfo[i][fName] = dj(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/CommandType",i); FactionInfo[i][fCommandsType] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName1",i); FactionInfo[i][fRankName1] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName2",i); FactionInfo[i][fRankName2] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName3",i); FactionInfo[i][fRankName3] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName4",i); FactionInfo[i][fRankName4] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName5",i); FactionInfo[i][fRankName5] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/RankName6",i); FactionInfo[i][fRankName6] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin1",i); FactionInfo[i][fSkin1] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin2",i); FactionInfo[i][fSkin2] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin3",i); FactionInfo[i][fSkin3] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin4",i); FactionInfo[i][fSkin4] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin5",i); FactionInfo[i][fSkin5] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Skin6",i); FactionInfo[i][fSkin6] = djInt(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/X",i); FactionInfo[i][fXPos] = djFloat(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/Y",i); FactionInfo[i][fYPos] = djFloat(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Pos/Z",i); FactionInfo[i][fZPos] = djFloat(FACTIONS_FILE, otherstring);
format(otherstring, sizeof(otherstring),"Faction_%d/Interior",i); FactionInfo[i][fInterior] = djInt(FACTIONS_FILE, otherstring);
}
}
}
Please give me some tips or something! I'm stuck! This is my first time making smething dynamic!