←  Problemy z pluginami

AMXX.pl: Support AMX Mod X i SourceMod

»

3 najlepszych graczy | zle rozdaje expa


Najlepsza odpowiedź PANDA_2zl 06.11.2024 17:05

nad plugin_init

enum data{ index, frags }; 

i podmienić kod 'przyznanie_doswiadczenia()' na

public przyznanie_doswiadczenia(){
    new Array: players;
    players=ArrayCreate(data);
    new maxplayers=get_maxplayers(), item[data];
    for(new i=1; i<=maxplayers; i++){
        if(!is_user_connected(i)) continue;
        item[index]=i;
        item[frags]=get_user_frags(i);
        ArrayPushArray(players, item);
    }
    ArraySort(players, "sort_frags");
    ArrayGetArray(players, 0, item);
    Poke_Give_XP(item[index], -1, 300);
    ArrayGetArray(players, 1, item);
    Poke_Give_XP(item[index], -1, 200);
    ArrayGetArray(players, 2, item);
    Poke_Give_XP(item[index], -1, 100);
}

public sort_frags(Array:array, id_a, id_b){
    static item_a[data], item_b[data];
    ArrayGetArray(array, id_a, item_a);
    ArrayGetArray(array, id_b, item_b);
    return (item_a[frags] < item_b[frags]) ? 1 : (item_a[frags] > item_b[frags]) ? -1 : 0;
}

rozwiązane na pv, wrzucam dla potomnych

Przejdź do postu

  • +
  • -
^^DeeD^^ - zdjęcie ^^DeeD^^ 05.11.2024

Witam.
Problem jest taki,że za 3 miejsce prawidłowo przyznaje 100 expa natomiast za 2 miejsce przyznaje 300 expa (zadeklarowane 200),a za pierwsze miejsce 600 expa(zadeklarowane 300).

 

public przyznanie_doswiadczenia()
{
	
	new players[32], num;
	get_players(players, num, "h");
	
	new tempfrags, id;
	
	new swapfrags, swapid;
	
	new starfrags[3]; //0 - 3 miejsce / 1 - 2 miejsce / 2 - 1 miejsce
	new starid[3];
	
	for (new i = 0; i < num; i++)
	{
		id = players[i];
		new PobierzPD = pm_get_user_pd(id)
		tempfrags = get_user_frags(id);
		if ( tempfrags > starfrags[0])
		{
			starfrags[0] = tempfrags;
			starid[0] = id;
			Poke_Give_XP(starid[0], -1, 100);
	
			if ( tempfrags > starfrags[1])
			{
				swapfrags = starfrags[1];
				swapid = starid[1];
				starfrags[1] = tempfrags;
				starid[1] = id;
				starfrags[0] = swapfrags;
				starid[0] = swapid;
				Poke_Give_XP(starid[1], -1, 200);
				
				if ( tempfrags > starfrags[2])
				{
					swapfrags = starfrags[2];
					swapid = starid[2];
					starfrags[2] = tempfrags;
					starid[2] = id;
					starfrags[1] = swapfrags;
					starid[1] = swapid;
					Poke_Give_XP(starid[2], -1, 300);
					
				}
			}
		}
	}	
}
Odpowiedz

  • +
  • -
Najlepsza odpowiedź PANDA_2zl - zdjęcie PANDA_2zl 06.11.2024

nad plugin_init

enum data{ index, frags }; 

i podmienić kod 'przyznanie_doswiadczenia()' na

public przyznanie_doswiadczenia(){
    new Array: players;
    players=ArrayCreate(data);
    new maxplayers=get_maxplayers(), item[data];
    for(new i=1; i<=maxplayers; i++){
        if(!is_user_connected(i)) continue;
        item[index]=i;
        item[frags]=get_user_frags(i);
        ArrayPushArray(players, item);
    }
    ArraySort(players, "sort_frags");
    ArrayGetArray(players, 0, item);
    Poke_Give_XP(item[index], -1, 300);
    ArrayGetArray(players, 1, item);
    Poke_Give_XP(item[index], -1, 200);
    ArrayGetArray(players, 2, item);
    Poke_Give_XP(item[index], -1, 100);
}

public sort_frags(Array:array, id_a, id_b){
    static item_a[data], item_b[data];
    ArrayGetArray(array, id_a, item_a);
    ArrayGetArray(array, id_b, item_b);
    return (item_a[frags] < item_b[frags]) ? 1 : (item_a[frags] > item_b[frags]) ? -1 : 0;
}

rozwiązane na pv, wrzucam dla potomnych

Odpowiedz