Ayuda con el textdraw
#1

Alguien me puede ayudar con esto:

Lo que pasa es que creй un script para mostar el nivel y la exp, no soy muy bueno en esto pero intentй hacer lo que mejor pude y no me lanza errores pero cuando incio al servidor me muestra la exp de un personaje en otro:





No se si debo hacer un bucle for, alguien me dice que esta mal?

Este es mi script:

Код:
En el public OnGameModeInit():

SetTimer("setlevel", 1000, true);
	
	Nivel = TextDrawCreate(499.5 ,114 , "--");
	TextDrawFont(Nivel , 3);
	TextDrawLetterSize(Nivel , 0.6, 2.0);
	TextDrawColor(Nivel , 0x185fd9FF);
	TextDrawSetOutline(Nivel , false);
	TextDrawSetProportional(Nivel , true);
	TextDrawSetShadow(Nivel , 1);
	
	Exp = TextDrawCreate(496, 136, "--");
	TextDrawFont(Exp , 3);
	TextDrawLetterSize(Exp , 0.6, 2.0);
	TextDrawColor(Exp , 0x185fd9FF);
	TextDrawSetOutline(Exp , false);
	TextDrawSetProportional(Exp , true);
	TextDrawSetShadow(Exp , 1);
	
	Tel = TextDrawCreate(501, 158 ,"--");
	TextDrawFont(Tel , 3);
	TextDrawLetterSize(Tel , 0.6, 2.0);
	TextDrawColor(Tel , 0x185fd9FF);
	TextDrawSetOutline(Tel , false);
	TextDrawSetProportional(Tel , true);
	TextDrawSetShadow(Tel , 1);
Код:
En el public OnPlayerSpawn(playerid)

        if(Player[playerid][Authenticated] == 1)
 	{
  		SetPlayerScore(playerid, Player[playerid][PlayerScore]);
    		TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
		TextDrawShowForPlayer(playerid, Nivel), TextDrawShowForPlayer(playerid, Exp), TextDrawShowForPlayer(playerid, Tel);
	}
Код:
public setlevel(playerid)
{
	new string[256];
	if(Player[playerid][Level] == Player[playerid][MaxLevel])
	{
	    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
	    Player[playerid][PlayerScore] = GetPlayerScore(playerid);
	    Player[playerid][Level] = 0;
	    Player[playerid][MaxLevel] = Player[playerid][MaxLevel]+11;
	    format(string, sizeof(string), "Felicidades has subido un nivel, ahora eres nivel %d.", Player[playerid][PlayerScore]);
	    SendClientMessage(playerid, WHITE, string);
	}
	format(string, sizeof(string), "Nivel: %d", Player[playerid][PlayerScore]);
	TextDrawSetString(Nivel, string);
	
	format(string, sizeof(string), "Exp: %d/%d", Player[playerid][Level], Player[playerid][MaxLevel]);
	TextDrawSetString(Exp, string);
	
	format(string, sizeof(string), "Tel: %d", Player[playerid][PhoneN]);
	TextDrawSetString(Tel, string);

	if(Player[playerid][SecondsToLevel] == 0)
	{
	    Player[playerid][SecondsToLevel] = 3600;
	    Player[playerid][Level]++;
	}
}
Reply
#2

en ongamemodeinit estбs usando un timer sin parametros

pawn Код:
SetTimer("setlevel", 1000, true);
esto servirнa asн:
pawn Код:
public setlevel()
Pero tu lo tienes asн:
pawn Код:
public setlevel(playerid)
la solucion, un bucle en ongamemodeinit o en setlevel().

si es en ongamemodeinit serнa asн:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    SetTimerEx("setlevel",1000,true,"i",i);
}
O de la otra manera como lo tienes serнa asн:
pawn Код:
SetTimer("setlevel", 1000, true);


public setlevel()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        new string[256];
        if(Player[playerid][Level] == Player[playerid][MaxLevel])
        {
            SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
            Player[playerid][PlayerScore] = GetPlayerScore(playerid);
            Player[playerid][Level] = 0;
            Player[playerid][MaxLevel] = Player[playerid][MaxLevel]+11;
            format(string, sizeof(string), "Felicidades has subido un nivel, ahora eres nivel %d.", Player[playerid][PlayerScore]);
            SendClientMessage(playerid, WHITE, string);
        }
        format(string, sizeof(string), "Nivel: %d", Player[playerid][PlayerScore]);
        TextDrawSetString(Nivel, string);

        format(string, sizeof(string), "Exp: %d/%d", Player[playerid][Level], Player[playerid][MaxLevel]);
        TextDrawSetString(Exp, string);

        format(string, sizeof(string), "Tel: %d", Player[playerid][PhoneN]);
        TextDrawSetString(Tel, string);

        if(Player[playerid][SecondsToLevel] == 0)
        {
            Player[playerid][SecondsToLevel] = 3600;
            Player[playerid][Level]++;
        }
    }
}
Reply
#3

Aun no me da, intente hacerlo por los lados pero me lanza errores con estos en el setlevel()

Код:
   SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
            Player[playerid][PlayerScore] = GetPlayerScore(playerid);
            Player[playerid][Level] = 0;
            Player[playerid][MaxLevel] = Player[playerid][MaxLevel]+11;

                 if(Player[playerid][SecondsToLevel] == 0)
		{
			Player[playerid][SecondsToLevel] = 3600;
	  		Player[playerid][Level]++;
		}
Cuando acaba el contador de los minutos para dar el punto de experiencia me saca del server.
Reply
#4

Tendrбs que proporcionar mas informaciуn para poder ayudarte.
Reply
#5

Mira esto es todo lo que tengo sobre el textdraw:

Код:
GamemodeInit

SetTimer("setlevel", 1000, true);

	Nivel = TextDrawCreate(499.5 ,114 , "--");
	TextDrawFont(Nivel , 3);
	TextDrawLetterSize(Nivel , 0.6, 2.0);
	TextDrawColor(Nivel , 0x185fd9FF);
	TextDrawSetOutline(Nivel , false);
	TextDrawSetProportional(Nivel , true);
	TextDrawSetShadow(Nivel , 1);
	
	Exp = TextDrawCreate(496, 136, "--");
	TextDrawFont(Exp , 3);
	TextDrawLetterSize(Exp , 0.6, 2.0);
	TextDrawColor(Exp , 0x185fd9FF);
	TextDrawSetOutline(Exp , false);
	TextDrawSetProportional(Exp , true);
	TextDrawSetShadow(Exp , 1);
	
	Tel = TextDrawCreate(501, 158 ,"--");
	TextDrawFont(Tel , 3);
	TextDrawLetterSize(Tel , 0.6, 2.0);
	TextDrawColor(Tel , 0x185fd9FF);
	TextDrawSetOutline(Tel , false);
	TextDrawSetProportional(Tel , true);
	TextDrawSetShadow(Tel , 1);

  	SetTimer("settime",1000,true);
	
	// Fecha
 	Date = TextDrawCreate(547.000000, 11.000000, "--");
	TextDrawFont(Date, 3);
	TextDrawLetterSize(Date, 0.5, 1.6);
    TextDrawColor(Date, 0xFFFFFFFF);

	// tiempo
	Time = TextDrawCreate(547.000000, 28.000000, "--");
 	TextDrawFont(Time, 3);
  	TextDrawLetterSize(Time, 0.5, 1.6);
   	TextDrawColor(Time, 0xFFFFFFFF);

Public OnPlayerSpawn
{
        if(Player[playerid][Authenticated] == 1)
 	{
  			SetPlayerScore(playerid, Player[playerid][PlayerScore]);
    		TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
			TextDrawShowForPlayer(playerid, Nivel), TextDrawShowForPlayer(playerid, Exp), TextDrawShowForPlayer(playerid, Tel);
	}
}

public setlevel()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
		new string[256];
		if(Player[playerid][Level] == Player[playerid][MaxLevel])
		{
	 		SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
			Player[playerid][PlayerScore] = GetPlayerScore(playerid);
	  		Player[playerid][Level] = 0;
	    	Player[playerid][MaxLevel] = Player[playerid][MaxLevel]+11;
	   		format(string, sizeof(string), "Felicidades has subido un nivel, ahora eres nivel %d.", Player[playerid][PlayerScore]);
		    SendClientMessage(playerid, WHITE, string);
		}
		format(string, sizeof(string), "Nivel: %d", Player[playerid][PlayerScore]);
		TextDrawSetString(Nivel, string);

		format(string, sizeof(string), "Exp: %d/%d", Player[playerid][Level], Player[playerid][MaxLevel]);
		TextDrawSetString(Exp, string);

		format(string, sizeof(string), "Tel: %d", Player[playerid][PhoneN]);
		TextDrawSetString(Tel, string);

		if(Player[playerid][SecondsToLevel] == 0)
		{
			Player[playerid][SecondsToLevel] = 3600;
	  		Player[playerid][Level]++;
		}
	}
}
Asi lo tengo, y la consola me lanza este error:

Quote:

[join] Matthew_Hudson has joined the server (0:190.250.83.121)
[18:31:14] Warning: client exceeded 'ackslimit' 190.250.83.121:57257 (3326) Limit: 3000/sec
[18:31:25] [part] Matthew_Hudson has left the server (0:0)

Reply
#6

Una y si desactivas esos textdraw ya no tienes problemas?
Tambien agregale una condicion para que el ciclo pase solamente a jugadores conectados, osino se hace un largisimo proceso de 500 repeticiones :O
pawn Код:
public setlevel()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            new string[256];
            if(Player[playerid][Level] == Player[playerid][MaxLevel])
            {
                SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
                Player[playerid][PlayerScore] = GetPlayerScore(playerid);
                Player[playerid][Level] = 0;
                Player[playerid][MaxLevel] = Player[playerid][MaxLevel]+11;
                format(string, sizeof(string), "Felicidades has subido un nivel, ahora eres nivel %d.", Player[playerid][PlayerScore]);
                SendClientMessage(playerid, WHITE, string);
            }
            format(string, sizeof(string), "Nivel: %d", Player[playerid][PlayerScore]);
            TextDrawSetString(Nivel, string);

            format(string, sizeof(string), "Exp: %d/%d", Player[playerid][Level], Player[playerid][MaxLevel]);
            TextDrawSetString(Exp, string);

            format(string, sizeof(string), "Tel: %d", Player[playerid][PhoneN]);
            TextDrawSetString(Tel, string);

            if(Player[playerid][SecondsToLevel] == 0)
            {
                Player[playerid][SecondsToLevel] = 3600;
                Player[playerid][Level]++;
            }
        }
    }
}
Reply
#7

No debo retornar ningun valor?
Reply
#8

Quote:
Originally Posted by TheMatius
Посмотреть сообщение
No debo retornar ningun valor?
Vas a usarlo ese valor?
Reply
#9

De pronto, si voy a usarlo lo agrego?, listo ahora si me da, el problema eran las 500 repeticiones y agrege el "Si el jugador esta conectado" y me dio muchas gracias.
Reply
#10

Quote:
Originally Posted by TheMatius
Посмотреть сообщение
De pronto, si voy a usarlo lo agrego?, listo ahora si me da, el problema eran las 500 repeticiones y agrege el "Si el jugador esta conectado" y me dio muchas gracias.
Claro si vas a usar un valor retornado de todo el callback si sino retornalo a 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)