Kodisanje ORG sistema i Gate sistema

Započeo Andreus, Avgust 08, 2023, 11:28:18 PRE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

Pozz, ja sam jedan od pocetnih skriptera koji radi svoju skriptu i planira poceti svoj mali server ali imam probleme. Posto sam odnegde morao nauciti po nesto o skriptanju pratio sam tutorijal od youtubera TazGee i primetio sam od toga sto mi vecina koda uspeva neki videi znaju biti uspesni ali da nemam nikakog effecta radnje.
Kao sto je i naslov od njega sam napravio i prepisao njegov dinamicni kod za pravljenje organizacije ali loigcno iz nekog razloga kada unesem sve kako je i on napravio njemu se napravi i spawna dok u mene dode prvi dialog da napravim ime org i onda pri klikom na bilo koje dugme (Enter, Potvrdi, Odustani i sl.) dialog ce se samo prekinuti, tj. nece prikazati druge dialoge i samo ce se spawnati moj odabrani pickup i celi server ce tu stajati sve dok ne restartujem server. cak i nece nista sacuvati u scriptfiles.
Takode i za Dinamicni Gate sistem sto je pravio u mene isto vecina radi imaju oni points (X, Y, Z) Ali kada kliknem da sacuvam gate se zapravo sacuve po ID-jem i svacim ali na mapi i bilo gde gate ne postoji, cak i kada klikcem dugme C/H nema nikakve poruke.
Ukoliko znate bolji kod ili fix javite se!

Evo poslacu kod gde sam celi org sistem zapisao
[pawn]enum orgInfo
{
   orgIme[128],
   orgLeader[128],
   orgMember1[128],
   orgMember2[128],
   orgMember3[128],
   orgMember4[128],
   orgMember5[128],
   orgMember6[128],
   orgMember7[128],
   orgMember8[128],
   orgMember9[128],
   orgMember10[128],
   orgMember11[128],
   orgMember12[128],
   orgMember13[128],
   orgMember14[128],
   orgMember15[128],
   orgMember16[128],
   orgMember17[128],
   orgMember18[128],
   orgMember19[128],
   orgMember20[128],
   orgSefPare,
   orgSefMats,
   orgSefDroga,
   orgDrzavna,
   orgRank1[128],
   orgRank2[128],
   orgRank3[128],
   orgRank4[128],
   orgRank5[128],
   orgRank6[128],
   orgRank7[128],
   Float:orgX,
   Float:orgY,
   Float:orgZ
};
new OrgInfo[MAX_ORGS][orgInfo];
new brojorg;[/pawn]

[pawn]stock NewOrg(const len)
{
   new orgid = -1;
   for(new loop = (0), org_check = (-1), Data_[64] = "\0"; loop != len; ++ loop)
   {
       org_check = (loop+1);
      format(Data_, sizeof(Data_), ORGPATH, org_check);
      if(!fexist(Data_))
      {
          orgid = (org_check);
          break;
      }
   }
   return orgid;
}

stock SaveOrg(id)
{
   new org_file[64];
   format(org_file, sizeof(org_file), ORGPATH, id);
   new INI:File = INI_Open(org_file);
   INI_WriteString(File, "Ime", OrgInfo[id][orgIme]);
   INI_WriteString(File, "Leader", OrgInfo[id][orgLeader]);
   INI_WriteString(File, "Member1", OrgInfo[id][orgMember1]);
   INI_WriteString(File, "Member2", OrgInfo[id][orgMember2]);
   INI_WriteString(File, "Member3", OrgInfo[id][orgMember3]);
   INI_WriteString(File, "Member4", OrgInfo[id][orgMember4]);
   INI_WriteString(File, "Member5", OrgInfo[id][orgMember5]);
   INI_WriteString(File, "Member6", OrgInfo[id][orgMember6]);
   INI_WriteString(File, "Member7", OrgInfo[id][orgMember7]);
   INI_WriteString(File, "Member8", OrgInfo[id][orgMember8]);
   INI_WriteString(File, "Member9", OrgInfo[id][orgMember9]);
   INI_WriteString(File, "Member10", OrgInfo[id][orgMember10]);
   INI_WriteString(File, "Member11", OrgInfo[id][orgMember11]);
   INI_WriteString(File, "Member12", OrgInfo[id][orgMember12]);
   INI_WriteString(File, "Member13", OrgInfo[id][orgMember13]);
   INI_WriteString(File, "Member14", OrgInfo[id][orgMember14]);
   INI_WriteString(File, "Member15", OrgInfo[id][orgMember15]);
   INI_WriteString(File, "Member16", OrgInfo[id][orgMember16]);
   INI_WriteString(File, "Member17", OrgInfo[id][orgMember17]);
   INI_WriteString(File, "Member18", OrgInfo[id][orgMember18]);
   INI_WriteString(File, "Member19", OrgInfo[id][orgMember19]);
   INI_WriteString(File, "Member20", OrgInfo[id][orgMember20]);
   INI_WriteInt(File, "SefPare", OrgInfo[id][orgSefPare]);
   INI_WriteInt(File, "SefMats", OrgInfo[id][orgSefMats]);
   INI_WriteInt(File, "SefDroga", OrgInfo[id][orgSefDroga]);
   INI_WriteInt(File, "Drzavna", OrgInfo[id][orgDrzavna]);
   INI_WriteString(File, "Rank1", OrgInfo[id][orgRank1]);
   INI_WriteString(File, "Rank2", OrgInfo[id][orgRank2]);
   INI_WriteString(File, "Rank3", OrgInfo[id][orgRank3]);
   INI_WriteString(File, "Rank4", OrgInfo[id][orgRank4]);
   INI_WriteString(File, "Rank5", OrgInfo[id][orgRank5]);
   INI_WriteString(File, "Rank6", OrgInfo[id][orgRank6]);
   INI_WriteString(File, "Rank7", OrgInfo[id][orgRank7]);
   INI_WriteFloat(File, "X", OrgInfo[id][orgX]);
   INI_WriteFloat(File, "Y", OrgInfo[id][orgY]);
   INI_WriteFloat(File, "Z", OrgInfo[id][orgZ]);
   INI_Close(File);

}[/pawn]

[pawn]//ORG SISTEM
   for(new i = 0; i < MAX_ORGS; i++)
   {
       new orgfile[64];
       format(orgfile, sizeof(orgfile), ORGPATH, i);
        if(fexist(orgfile))
         {
             INI_ParseFile(orgfile, "LoadOrgs", .bExtra = true, .extra = i);
            new string[128];
             format(string, sizeof(string), "{DAA520}[{FFFFFF}%s{DAA520}]\n{FFFFFF}Leader: {DAA520}%s", OrgInfo[orgIme], OrgInfo[orgLeader]);
              orgLabel = Create3DTextLabel(string, COLOR_BLACK, OrgInfo[orgX], OrgInfo[orgY], OrgInfo[orgZ], 20.0, 0, 0);
            orgPickup = CreatePickup(19132, 1, OrgInfo[orgX], OrgInfo[orgY], OrgInfo[orgZ]);
            brojorg++;
         }
   }[/pawn]

[pawn]public OnGameModeExit()
{
    for(new id = 0; id < MAX_HOUSES; id ++)
   {
      SaveHouse(id);
   }
   for(new id = 0; id < MAX_ORGS; id++)
   {
       SaveOrg(id);
   }
   return 1;
}[/pawn]


Komande
[pawn]CMD:skinilidera(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Niste ovlasceni za upotrebu ove komande!");
    new id, orgfile[128], pid, pfile[128], niko[128], poruka[128], adm[128];
    if(sscanf(params, "i", id)) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}/skinilidera [id]");
    format(orgfile, sizeof(orgfile), ORGPATH, id);
    format(niko, sizeof(niko), "Niko");
    if(!fexist(orgfile)) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Ova organizacija se ne uklapa sa nasom bazom podataka!");
    pid = GetPlayerID(OrgInfo[id][orgLeader]);
    if(pid == -1)
    {
        new ime[128];
        format(ime, sizeof(ime), PATH, OrgInfo[id][orgLeader]);
        format(pfile, sizeof(pfile), PATH, ime);
        INI_ParseFile(pfile, "LoadIser_%s", .bExtra = true, .extra = SKIDANJEID);
        PlayerInfo[SKIDANJEID][pLeader] = 0;
        OrgInfo[id][orgLeader] = niko;
        RefreshEntity(id, 2);
        Sacuvaj(SKIDANJEID, ime);
        SaveOrg(id);
    }
    else
    {
        PlayerInfo[pid][pLeader] = 0;
        OrgInfo[id][orgLeader] = niko;
        GetPlayerName(playerid, adm, sizeof(adm));
        format(poruka, sizeof(poruka), "{DAA520}LEADER: {FFFFFF}Skinut vam je lider rank organizacije {DAA520}%s {FFFFFF}od strane admina {DAA520}%s!", OrgInfo[id][orgIme], adm);
        RefreshEntity(id, 2);
        SavePlayer(pid);
        SaveOrg(id);
    }
    format(poruka, sizeof(poruka), "{DAA520}SERVER: {FFFFFF}Uspesno ste skinuli lidera organizacije {DAA520}%s sa vlasti!", OrgInfo[id][orgIme]);
    SCM(playerid, -1, poruka);
   return 1;
}


CMD:organizacije(playerid, params[])
{
   new lista[1024], text[128];
   if(brojorg < 1) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Organizacije nisu jos napravljene!");
   for(new i = 1; i <= brojorg; i++)
   {
       format(text, sizeof(text), "{DAA520}[{FFFFFF}%d{DAA520}] - {FFFFFF}%s\n", i, OrgInfo[orgIme]);
       strcat(lista, text);
   }
   ShowPlayerDialog(playerid, DIALOG_ORGLIST, DIALOG_STYLE_MSGBOX, "{DAA520}Lista Organizacija", lista, "{DAA520}Napusti", "");
   return 1;
}


CMD:lideri(playerid, params[])
{
   new lista[2048], text[128];
   if(brojorg < 1) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Organizacije nisu jos napravljene!");
   for(new i = 0; i <= brojorg; i++)
   {
       format(text, sizeof(text), "{DAA520}[{FFFFFF}%d{DAA520}] - {DAA520}Ime:%s - {DAA520}Leader: {FFFFFF}%s\n", i, OrgInfo[orgIme], OrgInfo[orgLeader]);
       strcat(lista, text);
   }
   ShowPlayerDialog(playerid, DIALOG_ORGLIST, DIALOG_STYLE_MSGBOX, "{DAA520}Lista Lidera", lista, "{DAA520}Napusti", "");
   return 1;
}
CMD:makeleader(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Niste ovlasceni za upotrebu ove komande!");
   if(brojorg < 1) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Organizacije nisu jos napravljene!");
   new id, orgid, ime[128], string[128];
   if(sscanf(params, "ui", id, orgid)) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}/makeleader [id] [orgid]");
   if(PlayerInfo[id][pLeader] != 0) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Igrac je vec lider neke druge organizacije!");
   if(orgid < 0 || orgid > brojorg) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Netacan ID organizacije je unjet!");
   GetPlayerName(id, ime, sizeof(ime));
   PlayerInfo[id][pLeader] = orgid;
   OrgInfo[orgid][orgLeader] = ime;
   SavePlayer(id);
   SaveOrg(orgid);
   format(string, sizeof(string), "{DAA520}ORGANIZACIJA: {FFFFFF}Uspesno ste postavili lidera organizacije {DAA520}%s{FFFFFF} igracu {DAA520}%s!", OrgInfo[orgid][orgIme], ime);
   SCM(playerid, -1, string);
   Delete3DTextLabel(orgLabel[orgid]);
   format(string, sizeof(string), "{DAA520}[{FFFFFF}%s{DAA520}]\n{FFFFFF}Leader: {DAA520}%s", OrgInfo[orgid][orgIme], OrgInfo[orgid][orgLeader]);
   orgLabel[orgid] = Create3DTextLabel(string, COLOR_BLACK, OrgInfo[orgid][orgX], OrgInfo[orgid][orgY], OrgInfo[orgid][orgZ], 20.0, 0, 0);
   return 1;
}
[/pawn]

Najbitnije

[pawn]CMD:napraviorg(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Niste ovlasceni za upotrebu ove komande!");
   if(editaorg[playerid] != -1) return SCM(playerid, COLOR_RED, "SERVER: {FFFFFF}Vec pravite/uredujete neku org!");
   new Float:X, Float:Y, Float:Z, i = NewOrg(MAX_ORGS), nikostring[128];
   format(nikostring, sizeof(nikostring), "Niko");
   OrgInfo[orgLeader] = nikostring;
   OrgInfo[orgMember1] = nikostring;
   OrgInfo[orgMember2] = nikostring;
   OrgInfo[orgMember3] = nikostring;
   OrgInfo[orgMember4] = nikostring;
   OrgInfo[orgMember5] = nikostring;
   OrgInfo[orgMember6] = nikostring;
   OrgInfo[orgMember7] = nikostring;
   OrgInfo[orgMember8] = nikostring;
   OrgInfo[orgMember9] = nikostring;
   OrgInfo[orgMember10] = nikostring;
   OrgInfo[orgMember11] = nikostring;
   OrgInfo[orgMember12] = nikostring;
   OrgInfo[orgMember13] = nikostring;
   OrgInfo[orgMember14] = nikostring;
   OrgInfo[orgMember15] = nikostring;
   OrgInfo[orgMember16] = nikostring;
   OrgInfo[orgMember17] = nikostring;
   OrgInfo[orgMember18] = nikostring;
   OrgInfo[orgMember19] = nikostring;
   OrgInfo[orgMember20] = nikostring;
   OrgInfo[orgSefPare] = 0;
   OrgInfo[orgSefMats] = 0;
   OrgInfo[orgSefDroga] = 0;
   GetPlayerPos(playerid, X, Y, Z);
   OrgInfo[orgX] = X;
   OrgInfo[orgY] = Y;
   OrgInfo[orgZ] = Z;
   orgPickup = CreatePickup(19132, 1, X, Y, Z);
   SCM(playerid, COLOR_ORANGE, "ORGANIZACIJA: {FFFFFF}Uspesno ste poceli sa pravljenjem organizacije!");
   ShowPlayerDialog(playerid, DIALOG_ORGIME, DIALOG_STYLE_INPUT, "{DAA520}Ime Organizacije", "{FFFFFF}Unestie vase zeljno ime organizacije!", "Potvrdi", "Odustani");
   brojorg++;
   return 1;
}[/pawn]

Sada Dialozi

[pawn]case DIALOG_ORGIME:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new ime[128];
              format(ime, sizeof(ime), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgIme] = ime;
              ShowPlayerDialog(playerid, DIALOG_ORGDRZAVNA, DIALOG_STYLE_MSGBOX, "{DAA520}Vrsta organizacije", "{FFFFFF}Izaberite vasu vrstu organizacije!", "Drzavna", "Nelegalna");
          }
      }
      case DIALOG_ORGDRZAVNA:
      {
          if(!response)
          {
              OrgInfo[editaorg[playerid]][orgDrzavna] = 0;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK1, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 1", "Potvrdi", "Odustani");
          }
          if(response)
          {
              OrgInfo[editaorg[playerid]][orgDrzavna] = 1;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK1, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 1", "Potvrdi", "Odustani");
          }
      }
      case DIALOG_ORGRANK1:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank1] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK2, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 2", "Potvrdi", "Odustani");
          }
      }
      case DIALOG_ORGRANK2:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank2] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK3, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 3", "Potvrdi", "Odustani");
          }
      }
      case DIALOG_ORGRANK3:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank3] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK4, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 4", "Potvrdi", "Odustani");
          }
      }
      case DIALOG_ORGRANK4:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank4] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK5, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 5", "Potvrdi", "Odustani");
          }
      }
      case DIALOG_ORGRANK5:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank5] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK6, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 6", "Potvrdi", "Odsutani");
          }
      }
      case DIALOG_ORGRANK6:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128];
              format(string, sizeof(string), "%s", inputtext);
              OrgInfo[editaorg[playerid]][orgRank6] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGRANK7, DIALOG_STYLE_INPUT, "{DAA520}Imena Rankova", "{FFFFFF}Unesite ime za Rank 7", "Potvrid", "Odustani");
          }
      }
      case DIALOG_ORGRANK7:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new string[128], infostring[512], drz[128], i = editaorg[playerid];
              if(OrgInfo[orgDrzavna] == 0)
              {
                  format(drz, sizeof(drz), "Nelegalna");
              }
              else
              {
                  format(drz, sizeof(drz), "Drzavna");
              }
              format(string, sizeof(string), "%s", inputtext);
              format(infostring, sizeof(infostring), "{DAA520}Da li ste sigurni da zelite da napravite organizaciju?\n{FFFFFF}Ime: {DAA520}%s\n{FFFFFF}Vrsta: {DAA520}%s", OrgInfo[orgIme], drz);
              OrgInfo[editaorg[playerid]][orgRank7] = string;
              ShowPlayerDialog(playerid, DIALOG_ORGDRZAVNA, DIALOG_STYLE_MSGBOX, "{DAA520}Potvrda", infostring, "Potvrid", "Odustani");
          }
      }
      case DIALOG_ORGINFO:
      {
          if(!response)
          {
              DestroyPickup(orgPickup[editaorg[playerid]]);
              SCM(playerid, COLOR_RED, "{DAA520}SERVER: {FFFFFF}Prekinuli ste pravljenje organizacije!");
              editaorg[playerid] = -1;
          }
          if(response)
          {
              new i = editaorg[playerid], string[128];
              SCM(playerid, COLOR_ORANGE, "{DAA520}ORGANIZACIJA: {FFFFFF}Uspesno ste napravili organizaciju!");
              SaveOrg(i);
                format(string, sizeof(string), "{DAA520}[{FFFFFF}%s{DAA520}]\n{FFFFFF}Leader: {DAA520}%s", OrgInfo[orgIme], OrgInfo[orgLeader]);
                 orgLabel = Create3DTextLabel(string, COLOR_BLACK, OrgInfo[orgX], OrgInfo[orgY], OrgInfo[orgZ], 20.0, 0, 0);
                 editaorg[playerid] = -1;
          }
      }[/pawn]

Ukoliko neko zna sta sam zabrljao ili u cemu je bug neka posalje odgovor!