Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: TONY x poslato Avgust 20, 2024, 21:41:43 POSLE PODNE

Naslov: Pomoc
Poruka od: TONY x poslato Avgust 20, 2024, 21:41:43 POSLE PODNE
Problem(error/warning): YSI fajl za korisnika stalno duplira
CitatSati Igre = 0
Banka Novac = 0
Licna Karta = 0
Moto Dozvola = 0
AutoBusKamion Dozvola = 0
Plovilo Dozvola = 0
Gun Dozvola = 0
Posao Ugovor = 0
ORG Ugovor = 0
iz ne znam ni ja kog razloga svaki put kada leftam gejm i mozda kada se pozove saveplayerdata. Korisnicki fajl cu okaciti dole da vidite kako tacno izgleda, u .ysi fajlu u scriptfiles takodje ima 200 duplikata kolko sam puta ulazio na srw.
Deo skripte: public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(Korisnici(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Lozinka",PlayerData[playerid][pLozinka]);
INI_WriteInt(File,"Novac",PlayerData[playerid][pNovac]);
INI_WriteInt(File,"Level",GetPlayerScore(playerid));
INI_WriteString(File,"Email",PlayerData[playerid][pEmail]);
INI_WriteInt(File,"Spawn",PlayerData[playerid][pSpawn]);
INI_WriteInt(File,"Admin",PlayerData[playerid][pAdmin]);
INI_WriteInt(File,"VIP",PlayerData[playerid][pVIP]);
INI_WriteInt(File,"Asistent",PlayerData[playerid][pAsistent]);
INI_WriteInt(File,"Posao",PlayerData[playerid][pPosao]);
INI_WriteInt(File,"Sankcije",PlayerData[playerid][pSankcije]);
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_WriteInt(File,"Pol",PlayerData[playerid][pPol]);
INI_WriteInt(File,"Godine",PlayerData[playerid][pGodine]);
INI_WriteInt(File,"Drzavljanstvo",PlayerData[playerid][pDrzavljanstvo]);
INI_WriteInt(File,"Ubistva",PlayerData[playerid][pUbistva]);
INI_WriteInt(File,"Smrti",PlayerData[playerid][pSmrti]);
INI_WriteInt(File,"Organizacija",PlayerData[playerid][pORG]);
INI_WriteInt(File,"Rank",PlayerData[playerid][pRank]);
INI_WriteInt(File,"Gaol",PlayerData[playerid][pGaol]);
INI_WriteInt(File,"Mutiran",PlayerData[playerid][pMutiran]);
INI_WriteInt(File,"Zaduzenje",PlayerData[playerid][pZaduzenje]);
INI_WriteInt(File,"SpecRank",PlayerData[playerid][pSpecRank]);
INI_WriteInt(File,"Bizz",PlayerData[playerid][pPosedovanjeBizza]);
INI_WriteInt(File,"Kuca",PlayerData[playerid][pPosedovanjeKuce]);
INI_WriteInt(File,"Rent",PlayerData[playerid][pRent]);
INI_WriteInt(File,"WL",PlayerData[playerid][pWL]);
INI_WriteInt(File,"Sati Igre",PlayerData[playerid][pSatiIgre]);
INI_WriteInt(File,"Respekti",PlayerData[playerid][pRespekti]);
INI_WriteInt(File,"Banka Novac",PlayerData[playerid][pBankaNovac]);
INI_WriteInt(File,"Zlato",PlayerData[playerid][pZlato]);
INI_WriteInt(File,"Licna Karta",PlayerData[playerid][pLK]);
INI_WriteInt(File,"Pasos",PlayerData[playerid][pPasos]);
INI_WriteInt(File,"Vozacka",PlayerData[playerid][pVD]);
INI_WriteInt(File,"Moto Dozvola",PlayerData[playerid][pMD]);
INI_WriteInt(File,"AutoBusKamion Dozvola",PlayerData[playerid][pAKD]);
INI_WriteInt(File,"Plovilo Dozvola",PlayerData[playerid][pPLD]);
INI_WriteInt(File,"Gun Dozvola",PlayerData[playerid][pGD]);
INI_WriteInt(File,"Automobil",PlayerData[playerid][pPosedovanjeAutomobila]);
INI_WriteInt(File,"Motor",PlayerData[playerid][pPosedovanjeMotora]);
INI_WriteInt(File,"Bicikla",PlayerData[playerid][pPosedovanjeBicikle]);
INI_WriteInt(File,"Droga",PlayerData[playerid][pDroga]);
INI_WriteInt(File,"Mats",PlayerData[playerid][pMats]);
INI_WriteInt(File,"Disarm",PlayerData[playerid][pDisarm]);
INI_WriteInt(File,"OffGaol",PlayerData[playerid][pOffGaol]);
INI_WriteString(File,"OffGaolAdmin",PlayerData[playerid][pOffGaolAdmin]);
INI_WriteString(File,"OffGaolRazlog",PlayerData[playerid][pOffGaolRazlog]);
INI_WriteInt(File,"Posao Ugovor",PlayerData[playerid][pPU]);
INI_WriteInt(File,"ORG Ugovor",PlayerData[playerid][pORGU]);
new str[24];
  for(new i=0;i<MAX_VEH_SLOTS;i++)
    {
        format(str,sizeof(str),"Vozilo%d",i);
        INI_WriteInt(File,str, PlayerData[playerid][pVozilo][i]);
    }
    INI_WriteInt(File,"APlus",PlayerData[playerid][pAPlus]);
INI_WriteInt(File,"LPlus",PlayerData[playerid][pLPlus]);
INI_WriteInt(File,"ASPlus",PlayerData[playerid][pASPlus]);
INI_WriteInt(File,"AMinus",PlayerData[playerid][pAMinus]);
INI_WriteInt(File,"LMinus",PlayerData[playerid][pLMinus]);
INI_WriteInt(File,"ASMinus",PlayerData[playerid][pASMinus]);
INI_Close(File);

[data]
Novac = 80000
Level = 1
Spawn = 0
Admin = 7
VIP = 0
Asistent = 0
Posao = 0
Sankcije = 0
Skin = 217
Pol = 1
Godine = 23
Drzavljanstvo = 1
Ubistva = 0
Smrti = 0
Organizacija = 0
Rank = -1
Gaol = 0
Mutiran = 0
Zaduzenje = 0
SpecRank = 0
pPosedovanjeBizza = -1
Kuca = -1
Rent = -1
WL = 0
Sati Igre = 0
Respekti = 0
Banka Novac = 0
Zlato = 0
Licna Karta = 0
Pasos = 0
Vozacka = 0
Moto Dozvola = 0
AutoBusKamion Dozvola = 0
Plovilo Dozvola = 0
Gun Dozvola = 0
Automobil = -1
Motor = -1
Bicikla = -1
Droga = 0
Mats = 0
Disarm = 0
OffGaol = 0
Posao Ugovor = 0
ORG Ugovor = 0
Vozilo0 = -1
Vozilo1 = -1
APlus = 0
LPlus = 0
ASPlus = 0
AMinus = 0
LMinus = 0
ASMinus = 0
Email = asdfv.@
Lozinka = 68944173
Bizz = 0
Sati Igre = 0
Banka Novac = 0
Licna Karta = 0
Moto Dozvola = 0
AutoBusKamion Dozvola = 0
Plovilo Dozvola = 0
Gun Dozvola = 0
OffGaolAdmin =
OffGaolRazlog =
Posao Ugovor = 0
ORG Ugovor = 0
Sati Igre = 0
Banka Novac = 0
Licna Karta = 0
Moto Dozvola = 0
AutoBusKamion Dozvola = 0
Plovilo Dozvola = 0
Gun Dozvola = 0
Posao Ugovor = 0
ORG Ugovor = 0
Sati Igre = 0
Banka Novac = 0
Licna Karta = 0
Moto Dozvola = 0
AutoBusKamion Dozvola = 0
Plovilo Dozvola = 0
Gun Dozvola = 0
Posao Ugovor = 0
ORG Ugovor = 0

Naslov: Odg: Pomoc
Poruka od: Đ J Ø ₥ Ⱡ ₳ poslato Avgust 20, 2024, 22:53:17 POSLE PODNE
proveri da li ispravno ucitava i cuva fajl korisnika, sve mora biti po redu.
Naslov: Odg: Pomoc
Poruka od: TONY x poslato Avgust 21, 2024, 18:37:05 POSLE PODNE
ChatGPT kaze da mi je svo po istom redosledu, evo jos nekih delova gde se cuvaju podaci
Dialog register: new INI:File = INI_Open(Korisnici(playerid));
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Novac", 0);
    INI_WriteInt(File, "Level", 0);
    INI_WriteInt(File, "Spawn", 0);
    INI_WriteInt(File, "Admin", 0);
    INI_WriteInt(File, "VIP", 0);
    INI_WriteInt(File, "Asistent", 0);
    INI_WriteInt(File, "Posao", 0);
    INI_WriteInt(File, "Sankcije", 0);
    INI_WriteInt(File, "Skin", 0);
    INI_WriteInt(File, "Pol", 0);
    INI_WriteInt(File, "Godine", 0);
    INI_WriteInt(File, "Drzavljanstvo", 0);
    INI_WriteInt(File, "Ubistva", 0);
    INI_WriteInt(File, "Smrti", 0);
    INI_WriteInt(File, "Organizacija", 0);
    INI_WriteInt(File, "Rank", -1);
    INI_WriteInt(File, "Gaol", 0);
    INI_WriteInt(File, "Mutiran", 0);
    INI_WriteInt(File, "Zaduzenje", 0);
    INI_WriteInt(File, "SpecRank", 0);
    INI_WriteInt(File, "pPosedovanjeBizza", -1);
    INI_WriteInt(File, "Kuca", -1);
    INI_WriteInt(File, "Rent", -1);
    INI_WriteInt(File, "WL", 0);
    INI_WriteInt(File, "Sati Igre", 0);
    INI_WriteInt(File, "Respekti", 0);
    INI_WriteInt(File, "Banka Novac", 0);
    INI_WriteInt(File, "Zlato", 0);
    INI_WriteInt(File, "Licna Karta", 0);
    INI_WriteInt(File, "Pasos", 0);
    INI_WriteInt(File, "Vozacka", 0);
    INI_WriteInt(File, "Moto Dozvola", 0);
    INI_WriteInt(File, "AutoBusKamion Dozvola", 0);
    INI_WriteInt(File, "Plovilo Dozvola", 0);
    INI_WriteInt(File, "Gun Dozvola", 0);
    INI_WriteInt(File, "Automobil", -1);
    INI_WriteInt(File, "Motor", -1);
    INI_WriteInt(File, "Bicikla", -1);
    INI_WriteInt(File, "Droga", 0);
    INI_WriteInt(File, "Mats", 0);
    INI_WriteInt(File, "Disarm", 0);
    INI_WriteInt(File, "Sankcije", 0);
    INI_WriteInt(File, "OffGaol", 0);
    INI_WriteInt(File, "Posao Ugovor", 0);
    INI_WriteInt(File, "ORG Ugovor", 0);

    new str[24];
    for (new i = 0; i < MAX_VEH_SLOTS; i++)
    {
        format(str, sizeof(str), "Vozilo%d", i);
        PlayerData[playerid][pVozilo][i] = -1;
        INI_WriteInt(File, str, PlayerData[playerid][pVozilo][i]);
    }

    INI_WriteInt(File, "APlus", 0);
    INI_WriteInt(File, "LPlus", 0);
    INI_WriteInt(File, "ASPlus", 0);
    INI_WriteInt(File, "AMinus", 0);
    INI_WriteInt(File, "LMinus", 0);
    INI_WriteInt(File, "ASMinus", 0);
INI_Close(File);
stock SavePlayerData(playerid)
{
    new INI:File = INI_Open(Korisnici(playerid));
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Lozinka", PlayerData[playerid][pLozinka]);
    INI_WriteInt(File, "Novac", PlayerData[playerid][pNovac]);
    INI_WriteInt(File, "Level", GetPlayerScore(playerid));
    INI_WriteString(File, "Email", PlayerData[playerid][pEmail]);
    INI_WriteInt(File, "Spawn", PlayerData[playerid][pSpawn]);
    INI_WriteInt(File, "Admin", PlayerData[playerid][pAdmin]);
    INI_WriteInt(File, "VIP", PlayerData[playerid][pVIP]);
    INI_WriteInt(File, "Asistent", PlayerData[playerid][pAsistent]);
    INI_WriteInt(File, "Posao", PlayerData[playerid][pPosao]);
    INI_WriteInt(File, "Sankcije", PlayerData[playerid][pSankcije]);
    INI_WriteInt(File, "Skin", PlayerData[playerid][pSkin]);
    INI_WriteInt(File, "Pol", PlayerData[playerid][pPol]);
    INI_WriteInt(File, "Godine", PlayerData[playerid][pGodine]);
    INI_WriteInt(File, "Drzavljanstvo", PlayerData[playerid][pDrzavljanstvo]);
    INI_WriteInt(File, "Ubistva", PlayerData[playerid][pUbistva]);
    INI_WriteInt(File, "Smrti", PlayerData[playerid][pSmrti]);
    INI_WriteInt(File, "Organizacija", PlayerData[playerid][pORG]);
    INI_WriteInt(File, "Rank", PlayerData[playerid][pRank]);
    INI_WriteInt(File, "Gaol", PlayerData[playerid][pGaol]);
    INI_WriteInt(File, "Mutiran", PlayerData[playerid][pMutiran]);
    INI_WriteInt(File, "Zaduzenje", PlayerData[playerid][pZaduzenje]);
    INI_WriteInt(File, "SpecRank", PlayerData[playerid][pSpecRank]);
    INI_WriteInt(File, "Bizz", PlayerData[playerid][pPosedovanjeBizza]);
    INI_WriteInt(File, "Kuca", PlayerData[playerid][pPosedovanjeKuce]);
    INI_WriteInt(File, "Rent", PlayerData[playerid][pRent]);
    INI_WriteInt(File, "WL", PlayerData[playerid][pWL]);
    INI_WriteInt(File, "Sati Igre", PlayerData[playerid][pSatiIgre]);
    INI_WriteInt(File, "Respekti", PlayerData[playerid][pRespekti]);
    INI_WriteInt(File, "Banka Novac", PlayerData[playerid][pBankaNovac]);
    INI_WriteInt(File, "Zlato", PlayerData[playerid][pZlato]);
    INI_WriteInt(File, "Licna Karta", PlayerData[playerid][pLK]);
    INI_WriteInt(File, "Pasos", PlayerData[playerid][pPasos]);
    INI_WriteInt(File, "Vozacka", PlayerData[playerid][pVD]);
    INI_WriteInt(File, "Moto Dozvola", PlayerData[playerid][pMD]);
    INI_WriteInt(File, "AutoBusKamion Dozvola", PlayerData[playerid][pAKD]);
    INI_WriteInt(File, "Plovilo Dozvola", PlayerData[playerid][pPLD]);
    INI_WriteInt(File, "Gun Dozvola", PlayerData[playerid][pGD]);
    INI_WriteInt(File, "Automobil", PlayerData[playerid][pPosedovanjeAutomobila]);
    INI_WriteInt(File, "Motor", PlayerData[playerid][pPosedovanjeMotora]);
    INI_WriteInt(File, "Bicikla", PlayerData[playerid][pPosedovanjeBicikle]);
    INI_WriteInt(File, "Droga", PlayerData[playerid][pDroga]);
    INI_WriteInt(File, "Mats", PlayerData[playerid][pMats]);
    INI_WriteInt(File, "Disarm", PlayerData[playerid][pDisarm]);
    INI_WriteInt(File, "OffGaol", PlayerData[playerid][pOffGaol]);
    INI_WriteString(File, "OffGaolAdmin", PlayerData[playerid][pOffGaolAdmin]);
    INI_WriteString(File, "OffGaolRazlog", PlayerData[playerid][pOffGaolRazlog]);
    INI_WriteInt(File, "Posao Ugovor", PlayerData[playerid][pPU]);
    INI_WriteInt(File, "ORG Ugovor", PlayerData[playerid][pORGU]);

    new str[24];
    for (new i = 0; i < MAX_VEH_SLOTS; i++)
    {
        format(str, sizeof(str), "Vozilo%d", i);
        INI_WriteInt(File, str, PlayerData[playerid][pVozilo][i]);
    }

    INI_WriteInt(File, "APlus", PlayerData[playerid][pAPlus]);
    INI_WriteInt(File, "LPlus", PlayerData[playerid][pLPlus]);
    INI_WriteInt(File, "ASPlus", PlayerData[playerid][pASPlus]);
    INI_WriteInt(File, "AMinus", PlayerData[playerid][pAMinus]);
    INI_WriteInt(File, "LMinus", PlayerData[playerid][pLMinus]);
    INI_WriteInt(File, "ASMinus", PlayerData[playerid][pASMinus]);

    INI_Close(File);
    return 1;
}
Naslov: Odg: Pomoc
Poruka od: TONY x poslato Avgust 24, 2024, 16:53:55 POSLE PODNE
Nije reseno i dalje ...
Naslov: Odg: Pomoc
Poruka od: Prometheus poslato Avgust 24, 2024, 18:40:46 POSLE PODNE
Ne poklapaju ti se stavke, pogledaj do dole prema gore.

Najbolje je da prekopiras sa lokacije gde je kako je i u fajlu i to primenis na sve ostale lokacije gde se to pojavljuje.
Naslov: Odg: Pomoc
Poruka od: TONY x poslato Avgust 24, 2024, 21:39:59 POSLE PODNE
U pravu si, email nije na istim mestima ali i dalje se ovaj deo ponavlja i kad sam popravio i ponovo se registrovo
Naslov: Odg: Pomoc
Poruka od: cozmic poslato Avgust 24, 2024, 22:21:22 POSLE PODNE
meni je to sve razbacano al se ne duplira, sumnjam da je zbog toga
Naslov: Odg: Pomoc
Poruka od: Prometheus poslato Avgust 24, 2024, 23:04:12 POSLE PODNE
Pokazi kako izgleda kod gde ucitava korisnika
Naslov: Odg: Pomoc
Poruka od: CroherzeNonRPer poslato Avgust 24, 2024, 23:37:12 POSLE PODNE
Provjeri gdje se jos poziva savePlayerData

Pretrazi cijeli svoj gamemode/filterscript i provjeri da li se funkcija savePlayerData (ili neka slicna funkcija koja sprema podatke) poziva na drugim mjestima osim u OnPlayerDisconnect. Ako se poziva na vise mjesta, osiguraj da se podaci spremaju samo jednom kada je to stvarno potrebno (npr. prilikom promjene podataka igraca, a ne pri svakom pozivu OnPlayerUpdate ili slicno).

Koristi INI_Clear prije spremanja podataka

Prije nego sto pocnes zapisivati nove podatke u YSI fajl, koristi funkciju INI_Clear da izbrises postojeci sadrzaj datoteke. Na taj način ćeš osigurati da se podaci ne dupliciraju.

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(Korisnici(playerid));
    INI_SetTag(File,"data");

    // Brisanje postojeceg sadrzaja datoteke
    INI_Clear(File);

    // Zapisivanje novih podataka (ostatak koda ostaje isti)
    INI_WriteInt(File,"Lozinka",PlayerData[playerid][pLozinka]);
    // ... ostali podaci ...
    INI_Close(File);
}

Naslov: Odg: Pomoc
Poruka od: TONY x poslato Avgust 25, 2024, 11:13:21 PRE PODNE
Hvala sad sam resio problem ali ini_clear ne postoji, moro sam da koristim       
Citatnew File:fajl = fopen(Korisnici(playerid), io_write);
   fclose(fajl);