problema con textdraws de cargado
#1

Bueno estuve haciendo un textdraw que sale al entrar en un interior y te muestra un porcentaje de 0 a 100% bueno todo funciona bien pero lo que no me sirve es que llega a 100 y vuelve a caer en 0 y vuelve a cargar este es el codigo:

Код:
public CargadoObj()
{
switch (CargObj)
{
case 0:
{
new stringinv[50];
format(stringinv, sizeof(stringinv), "10", CargObj++);
TextDrawSetString(Textdraw3, stringinv);
}
case 1:
{
new stringinv[128];
format(stringinv, sizeof(stringinv), "20", CargObj++);
TextDrawSetString(Textdraw3, stringinv);
}
case 2:
{
new stringinv[128];
format(stringinv, sizeof(stringinv), "35", CargObj++);
TextDrawSetString(Textdraw3, stringinv);
}
case 3:
{
new stringinv[128];
format(stringinv, sizeof(stringinv), "90", CargObj++);
TextDrawSetString(Textdraw3, stringinv);
}
case 4:
{
new stringinv[128];
format(stringinv, sizeof(stringinv), "100", CargObj = 0);
TextDrawSetString(Textdraw3, stringinv);
}
}
return 1;
}
Ya se que es por el CargObj = 0 es que si no lo pongo asн me funciona peor porque solo se queda en un numero no avanza mas
Reply
#2

Si vas a trabajar con textdraws que no son iguales para todos, utiliza per-player textdraws y per-player variables.

Codigo para empezar a cargar los objetos:
pawn Код:
pPorcentaje[playerid] = 0;
KillTimer(tmCargarObjetos[playerid]);
tmCargarObjetos[playerid] = SetTimerEx("CargarObjetos", 500, true, "i", playerid);
Codigo que hara el trabajo:
pawn Код:
new tmCargarObjetos[MAX_PLAYERS],
pPorcentaje[MAX_PLAYERS];

forward CargarObjetos(playerid);
public CargarObjetos(playerid)
{
    new string[4];
    pPorcentaje[playerid] ++;

    if(pPorcentaje[playerid] < 100)
    {
        format(string, sizeof(string), "%d", pPorcentaje[playerid]);
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], string);
    }
    else // Termino de cargar los objetos.
    {
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], "100");
        pPorcentaje[playerid] = 0;
        KillTimer(tmCargarObjetos[playerid]);
    }
    return 1;
}
Nota: Convierta el textdraw utilizado a un per-player textdraw ( PlayerText: ).
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Si vas a trabajar con textdraws que no son iguales para todos, utiliza per-player textdraws y per-player variables.

Codigo para empezar a cargar los objetos:
pawn Код:
pPorcentaje[playerid] = 0;
KillTimer(tmCargarObjetos[playerid]);
tmCargarObjetos[playerid] = SetTimerEx("CargarObjetos", 500, true, "i", playerid);
Codigo que hara el trabajo:
pawn Код:
new tmCargarObjetos[MAX_PLAYERS],
pPorcentaje[MAX_PLAYERS];

forward CargarObjetos(playerid);
public CargarObjetos(playerid)
{
    new string[4];
    pPorcentaje[playerid] ++;

    if(pPorcentaje[playerid] < 100)
    {
        format(string, sizeof(string), "%d", pPorcentaje[playerid]);
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], string);
    }
    else // Termino de cargar los objetos.
    {
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], "100");
        pPorcentaje[playerid] = 0;
        KillTimer(tmCargarObjetos[playerid]);
    }
    return 1;
}
Nota: Convierta el textdraw utilizado a un per-player textdraw ( PlayerText: ).


Recomendaria mejor usar:

Codigo que hara el trabajo:
pawn Код:
new tmCargarObjetos[MAX_PLAYERS],
pPorcentaje[MAX_PLAYERS];

function CargarObjetos(playerid)
{
    new string[4];
    pPorcentaje[playerid] ++;

    if(pPorcentaje[playerid] < 100)
    {
        format(string, sizeof(string), "%d", pPorcentaje[playerid]);
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], string);
    }
    else // Termino de cargar los objetos.
    {
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], "100");
        pPorcentaje[playerid] = 0;
        KillTimer(tmCargarObjetos[playerid]);
    }
    return 1;
}
para asi evitar el public y el forward ya que es lo mismo y aparte es mas rapido, saludos
Reply
#4

Quote:
Originally Posted by iimma
Посмотреть сообщение
Recomendaria mejor usar:

Codigo que hara el trabajo:
pawn Код:
new tmCargarObjetos[MAX_PLAYERS],
pPorcentaje[MAX_PLAYERS];

function CargarObjetos(playerid)
{
    new string[4];
    pPorcentaje[playerid] ++;

    if(pPorcentaje[playerid] < 100)
    {
        format(string, sizeof(string), "%d", pPorcentaje[playerid]);
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], string);
    }
    else // Termino de cargar los objetos.
    {
        PlayerTextDrawSetString(playerid, Textdraw3[playerid], "100");
        pPorcentaje[playerid] = 0;
        KillTimer(tmCargarObjetos[playerid]);
    }
    return 1;
}
para asi evitar el public y el forward ya que es lo mismo y aparte es mas rapido, saludos
Eso ni existe, lo tienes que definir. Y es exactamente lo mismo:

pawn Код:
#define function%0(%1) forward%0(%1); public%0(%1)
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Eso ni existe, lo tienes que definir. Y es exactamente lo mismo:

pawn Код:
#define function%0(%1) forward%0(%1); public%0(%1)
Gracias SickAttack me funciono como me dijiste y estoy de acuerdo con lo que dijiste que usar public creo que es lo mismo que function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)