[Problema] Top 5
#1

Tengo un problema en este cуdigo:

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

new score[MAX_PLAYERS];
new scoreid[MAX_PLAYERS];

new Textdraw0;

enum PlayerInfo
{
	pKills,
	pDeaths,
}

new pInfo[MAX_PLAYERS][PlayerInfo];

#define DIALOG_TOP 1

public OnFilterScriptInit()
{
	Textdraw0 = TextDrawCreate(168.000000, 312.000000, "");
	TextDrawBackgroundColor(Textdraw0, 255);
	TextDrawFont(Textdraw0, 2);
	TextDrawLetterSize(Textdraw0, 0.210000, 1.200000);
	TextDrawColor(Textdraw0, -1);
	TextDrawSetOutline(Textdraw0, 1);
	TextDrawSetProportional(Textdraw0, 1);
	
	for(new i=0;i<MAX_PLAYERS;++i)    score[i] = 0;
	
    return 1;
}
#endif

public OnPlayerSpawn(playerid)
{
    new temp;
    for(new i = 0;i<MAX_PLAYERS;++i)
    {
        for(new j = i;j<MAX_PLAYERS;++j)
        {
            if(score[j] > score[i])
            {
                temp = score[i];
                score[i] = score[j];
                score[j] = temp;
                temp = scoreid[i];
                scoreid[i] = scoreid[j];
                scoreid[j] = temp;
            }
        }
    }

    new string[5][200];
    
    new rango[400];
    if((pInfo[playerid][pKills]>= 0 && pInfo[playerid][pKills] <= 150)) { rango = "NEWBIE SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 151 && pInfo[playerid][pKills] <= 300 )) { rango = "DEDICATED SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 301 && pInfo[playerid][pKills] <= 550)) { rango = "THE REAL SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 551 && pInfo[playerid][pKills] <= 700)) { rango = "IGI SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 701 && pInfo[playerid][pKills] <= 1000)) { rango = "INSANE SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 1000 && pInfo[playerid][pKills] <= 1500)) { rango = "PROFESSIONAL SHOOTER"; }
    
    for(new i =0;i<5;++i)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(scoreid[i],name,sizeof(name));
        format(string[i],200,"%d. %s - %s - %d",i+1,name,rango,score[i]);
    }
    

    new fstring[300];
    format(fstring,300,"%s~n~%s~n~%s~n~%s~n~%s",string[0],string[1],string[2],string[3],string[4]);
    for(new i=0;i<MAX_PLAYERS;++i)
    {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, Textdraw0);
            TextDrawSetString(i, fstring);
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    score[killerid]++;
    return 1;
}
Resulta que estoy yo sуlo en el servidor y aparezco en las cinco posiciones del top.

Imagen:

Reply
#2

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

new score[MAX_PLAYERS];
new scoreid[MAX_PLAYERS];

new Textdraw0;

enum PlayerInfo
{
    pKills,
    pDeaths,
}

new pInfo[MAX_PLAYERS][PlayerInfo];

#define DIALOG_TOP 1

public OnFilterScriptInit()
{
    Textdraw0 = TextDrawCreate(168.000000, 312.000000, "");
    TextDrawBackgroundColor(Textdraw0, 255);
    TextDrawFont(Textdraw0, 2);
    TextDrawLetterSize(Textdraw0, 0.210000, 1.200000);
    TextDrawColor(Textdraw0, -1);
    TextDrawSetOutline(Textdraw0, 1);
    TextDrawSetProportional(Textdraw0, 1);

    for(new i=0;i<MAX_PLAYERS;++i)    score[i] = 0;

    return 1;
}
#endif

public OnPlayerSpawn(playerid)
{
    new temp;
    for(new i = 0;i<MAX_PLAYERS;++i)
    {
        for(new j = i;j<MAX_PLAYERS;++j)
        {
            if(score[j] > score[i])
            {
                temp = score[i];
                score[i] = score[j];
                score[j] = temp;
                temp = scoreid[i];
                scoreid[i] = scoreid[j];
                scoreid[j] = temp;
            }
        }
    }

    new string[5][200];

    new rango[400];
    if((pInfo[playerid][pKills]>= 0 && pInfo[playerid][pKills] <= 150)) { rango = "NEWBIE SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 151 && pInfo[playerid][pKills] <= 300 )) { rango = "DEDICATED SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 301 && pInfo[playerid][pKills] <= 550)) { rango = "THE REAL SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 551 && pInfo[playerid][pKills] <= 700)) { rango = "IGI SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 701 && pInfo[playerid][pKills] <= 1000)) { rango = "INSANE SHOOTER"; }
    else if((pInfo[playerid][pKills]>= 1000 && pInfo[playerid][pKills] <= 1500)) { rango = "PROFESSIONAL SHOOTER"; }
   

    for(new i =0;i<5;++i)
    {
        if(IsPlayerConnected(i)) //Magia, cuenta si hay por lo menos 5 players, si no hay dicha cantidad, pondrб 3 o 4 textdraws. EJ: 3 users = 3 textdraws.
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(scoreid[i],name,sizeof(name));
            format(string[i],200,"%d. %s - %s - %d",i+1,name,rango,score[i]);
        }
    }


    new fstring[300];
    format(fstring,300,"%s~n~%s~n~%s~n~%s~n~%s",string[0],string[1],string[2],string[3],string[4]);
    for(new i=0;i<MAX_PLAYERS;++i)
    {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, Textdraw0);
            TextDrawSetString(i, fstring);
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    score[killerid]++;
    return 1;
}
Asн quedarнa:



Si hay 1 user, solo habrб 1 textdraw, si hay 2 users, habrб 2 textdraws, si hay 3 users, habrбn 3 textdraws, si hay 4 users, habrбn 4 textdraws, si hay 5 users, habrбn 5 textdraws, si hay 6 users, habrбn 5 textdraws

Edit: Alto n0b3it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)