Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: pokerface poslato Maj 03, 2019, 18:40:13 POSLE PODNE

Naslov: Shoes Count (/top lista)
Poruka od: pokerface poslato Maj 03, 2019, 18:40:13 POSLE PODNE
Problem(error/warning): Zelim napraviti komandu /top koja ce prikazati offline ime igraca I koliko je sakupio onih konjskih potkova kao pickup. Ja sam napravio ali prikaze samo mene, ali nece ostale.

Primjer kako treba biti:

1. Pero - Potkova ukupno: 50
2. Kruh - Potkova ukupno: 16
itd...

Deo skripte:

CMD:topshoes(playerid,params[])
{
new count;
new string[1000];
new file[48], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "Shoes/%s.ini", name);
if(!fexist(file)) SavePlayerProgress(playerid);
INI_ParseFile(file, "ReadCollectibleProgress", .bExtra = true, .extra = playerid);

for(new i; i < sizeof(CollectibleTypes); i++)
{
count++;
format(string, 256, "ID: %d - Name: %s --- %d", count, name, GetCollectedCount(playerid, i));
SendClientMessage(playerid, -1, string);
  }

return 1;
}


Ovo je nacin neki cuvanja I ucitavanja.

GetCollectedCount(playerid, type)
{
new count = 0;
for(new i; i < sizeof(CollectibleData); i++) if(CollectibleData[i][colType] == type && CollectiblePicked[playerid][i] > 0) count++;
return count;
}

GetCollectibleCount(type)
{
new count = 0;
for(new i; i < sizeof(CollectibleData); i++) if(CollectibleData[i][colType] == type) count++;
return count;
}

LoadPlayerProgress(playerid)
{
    for(new i; i < sizeof(CollectibleData); i++) CollectiblePicked[playerid][i] = 0;

    new file[48], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "Shoes/%s.ini", name);
if(!fexist(file)) SavePlayerProgress(playerid);
INI_ParseFile(file, "ReadCollectibleProgress", .bExtra = true, .extra = playerid);
return 1;
}

SavePlayerProgress(playerid)
{
    new file[48], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "Shoes/%s.ini", name);

new INI: fHandle = INI_Open(file), key[24];
    if(fHandle != INI_NO_FILE)
    {
    INI_SetTag(fHandle, "CollectibleData");

for(new i; i < sizeof(CollectibleData); ++i)
{
format(key, sizeof(key), "ColPicked_%d", i);
  INI_WriteInt(fHandle, key, CollectiblePicked[playerid][i]);
    }

INI_Close(fHandle);
}

return 1;
}

Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [ code ]vaš odgovor[ /code ]
Slika/video ingame problema(obavezno ako je ingame problem): link slike
Naslov: Odg: Shoes Count (/top lista)
Poruka od: Dobrica poslato Maj 03, 2019, 21:24:31 POSLE PODNE
Koristis da ti ispisuje playerid za sve sakupljene?
For za playerid?
Naslov: Odg: Shoes Count (/top lista)
Poruka od: NaTsu poslato Maj 03, 2019, 23:08:52 POSLE PODNE
Jel imaš neki fajl u kom su sortirani /top igrači tipa TOP1=Pera TOP2=Kruh ili...?
EDIT 2: Video sam da ta skripta ima SQLITE verziju tkd nju koristi, ne treba ti nista, lakse je sa SQLom sortirati stvari ;)