[Ajuda] Mostra Kill Deaths na tela
#1

Bom meu server esta on, a cada 1 level ganha 1 de score, mas tem kills e deaths alguem pode me ajuda num contador de kill aparecendo na tela do player??
Reply
#2

Estude sobre TextDrawSetString. Com apenas isso vocк faz.
Reply
#3

usei o search aqui e achei um tente dar uma olhada
Crйditos: Wesley221

PHP код:
new Kills[MAX_PLAYERS];
new 
Deaths[MAX_PLAYERS];

// callback OnPlayerDeath
Kills[killerid]++;
Deaths[playerid]++;
new 
PIDstring[50], TIDstring[50];
format(PIDstringsizeof PIDstring"Kills: %i Deaths: %i"Kills[playerid], Deaths[playerid]);
format(TIDstringsizeof TIDstring"Kills: %i Deaths: %i"Kills[killerid], Deaths[killerid]
TextDrawSetString(Textdraw[playerid], PIDstring);
TextDrawSetString(Textdraw[killerid], TIDstring); 
Reply
#4

Quote:
Originally Posted by K1w0
Посмотреть сообщение
usei o search aqui e achei um tente dar uma olhada
Crйditos: Wesley221

PHP код:
new Kills[MAX_PLAYERS];
new 
Deaths[MAX_PLAYERS];
// callback OnPlayerDeath
Kills[killerid]++;
Deaths[playerid]++;
new 
PIDstring[50], TIDstring[50];
format(PIDstringsizeof PIDstring"Kills: %i Deaths: %i"Kills[playerid], Deaths[playerid]);
format(TIDstringsizeof TIDstring"Kills: %i Deaths: %i"Kills[killerid], Deaths[killerid]
TextDrawSetString(Textdraw[playerid], PIDstring);
TextDrawSetString(Textdraw[killerid], TIDstring); 
A textdraw nгo foi criada e vai dar erro, variбvel Textdraw nгo foi criada. E teria que usar o uma textdraw para o jogador que seria:
pawn Код:
CreatePlayerTextDraw
Se nгo for usar uma textdraw para o jogador mesmo, em OnGameModeInit teria que usar uma loop, para criar todas as textdraw.
Reply
#5

Use o Criador de text draw do zamaroth para cria o textdraw e depois so usar variбveis
Reply
#6

Fiz um aqui para vocк bem simples...
Imagem de como ficou:

http://i.imgur.com/XFOiNVW.png

Cуdigo:
pawn Код:
enum e_PlayerStats
{
    pMatou,
    pMorreu
};

new pStats[MAX_PLAYERS][e_PlayerStats];

//Texts
new PlayerText:StatusBox[MAX_SLOTS];
new PlayerText:StatusInfo[MAX_SLOTS];
new PlayerText:StatusMatou[MAX_SLOTS];
new PlayerText:StatusMorreu[MAX_SLOTS];

new Updater;

//Ongamemodeinit
Updater = SetTimer("UpdateText",1000,true);

//Ongamemodeexit
KillTimer(Updater);

//OnPlayerConnect
    StatusBox[playerid] = CreatePlayerTextDraw(playerid, 621.199951, 288.220001, "usebox");
    PlayerTextDrawLetterSize(playerid, StatusBox[playerid], 0.000000, 7.564816);
    PlayerTextDrawTextSize(playerid, StatusBox[playerid], 493.200012, 0.000000);
    PlayerTextDrawAlignment(playerid, StatusBox[playerid], 1);
    PlayerTextDrawColor(playerid, StatusBox[playerid], 0);
    PlayerTextDrawUseBox(playerid, StatusBox[playerid], true);
    PlayerTextDrawBoxColor(playerid, StatusBox[playerid], 102);
    PlayerTextDrawSetShadow(playerid, StatusBox[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusBox[playerid], 0);
    PlayerTextDrawFont(playerid, StatusBox[playerid], 0);

    StatusInfo[playerid] = CreatePlayerTextDraw(playerid, 517.599975, 289.706604, "~h~~y~Status:");
    PlayerTextDrawLetterSize(playerid, StatusInfo[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawColor(playerid, StatusInfo[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusInfo[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusInfo[playerid], 51);
    PlayerTextDrawFont(playerid, StatusInfo[playerid], 2);
    PlayerTextDrawSetProportional(playerid, StatusInfo[playerid], 1);

    StatusMatou[playerid] = CreatePlayerTextDraw(playerid, 508.799987, 310.613281, "Matou:");
    PlayerTextDrawLetterSize(playerid, StatusMatou[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMatou[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMatou[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMatou[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMatou[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMatou[playerid], 1);

    StatusMorreu[playerid] = CreatePlayerTextDraw(playerid, 508.000000, 330.026519, "Morreu:");
    PlayerTextDrawLetterSize(playerid, StatusMorreu[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMorreu[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMorreu[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMorreu[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMorreu[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMorreu[playerid], 1);

    pStats[playerid][pMatou] = 0;
    pStats[playerid][pMorreu] = 0;

//Onplayerdisconnect
PlayerTextDrawDestroy(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMorreu[playerid]);

//OnPlayerSpawn
PlayerTextDrawShow(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMorreu[playerid]);

//Onplayerdeath
    pStats[playerid][pMorreu]++;
    if(killerid != 0xFFFF)
    {
        pStats[killerid][pMatou]++;
    }

public UpdateText(playerid)
{
    new
        str[128];

    format(str, sizeof(str), "Matou: ~h~~g~%d", pStats[playerid][pMatou]);
    PlayerTextDrawSetString(playerid, StatusMatou[playerid], str);
    format(str, sizeof(str), "Morreu: ~h~~r~%d", pStats[playerid][pMorreu]);
    PlayerTextDrawSetString(playerid, StatusMorreu[playerid], str);
    return 1;
}
Reply
#7

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
A textdraw nгo foi criada e vai dar erro, variбvel Textdraw nгo foi criada. E teria que usar o uma textdraw para o jogador que seria:
pawn Код:
CreatePlayerTextDraw
Se nгo for usar uma textdraw para o jogador mesmo, em OnGameModeInit teria que usar uma loop, para criar todas as textdraw.
eu nгo entendo muito e vi esse cуdigo usando o search mais se nгo valeu de nada desculpe ;x

Quote:
Originally Posted by SalvatoreBR
Посмотреть сообщение
Fiz um aqui para vocк bem simples...
Imagem de como ficou:

http://i.imgur.com/XFOiNVW.png

Cуdigo:
pawn Код:
enum e_PlayerStats
{
    pMatou,
    pMorreu
};

new pStats[MAX_PLAYERS][e_PlayerStats];

//Texts
new PlayerText:StatusBox[MAX_SLOTS];
new PlayerText:StatusInfo[MAX_SLOTS];
new PlayerText:StatusMatou[MAX_SLOTS];
new PlayerText:StatusMorreu[MAX_SLOTS];

new Updater;

//Ongamemodeinit
Updater = SetTimer("UpdateText",1000,true);

//Ongamemodeexit
KillTimer(Updater);

//OnPlayerConnect
    StatusBox[playerid] = CreatePlayerTextDraw(playerid, 621.199951, 288.220001, "usebox");
    PlayerTextDrawLetterSize(playerid, StatusBox[playerid], 0.000000, 7.564816);
    PlayerTextDrawTextSize(playerid, StatusBox[playerid], 493.200012, 0.000000);
    PlayerTextDrawAlignment(playerid, StatusBox[playerid], 1);
    PlayerTextDrawColor(playerid, StatusBox[playerid], 0);
    PlayerTextDrawUseBox(playerid, StatusBox[playerid], true);
    PlayerTextDrawBoxColor(playerid, StatusBox[playerid], 102);
    PlayerTextDrawSetShadow(playerid, StatusBox[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusBox[playerid], 0);
    PlayerTextDrawFont(playerid, StatusBox[playerid], 0);

    StatusInfo[playerid] = CreatePlayerTextDraw(playerid, 517.599975, 289.706604, "~h~~y~Status:");
    PlayerTextDrawLetterSize(playerid, StatusInfo[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawColor(playerid, StatusInfo[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusInfo[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusInfo[playerid], 51);
    PlayerTextDrawFont(playerid, StatusInfo[playerid], 2);
    PlayerTextDrawSetProportional(playerid, StatusInfo[playerid], 1);

    StatusMatou[playerid] = CreatePlayerTextDraw(playerid, 508.799987, 310.613281, "Matou:");
    PlayerTextDrawLetterSize(playerid, StatusMatou[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMatou[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMatou[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMatou[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMatou[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMatou[playerid], 1);

    StatusMorreu[playerid] = CreatePlayerTextDraw(playerid, 508.000000, 330.026519, "Morreu:");
    PlayerTextDrawLetterSize(playerid, StatusMorreu[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMorreu[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMorreu[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMorreu[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMorreu[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMorreu[playerid], 1);

    pStats[playerid][pMatou] = 0;
    pStats[playerid][pMorreu] = 0;

//Onplayerdisconnect
PlayerTextDrawDestroy(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMorreu[playerid]);

//OnPlayerSpawn
PlayerTextDrawShow(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMorreu[playerid]);

//Onplayerdeath
    pStats[playerid][pMorreu]++;
    if(killerid != 0xFFFF)
    {
        pStats[killerid][pMatou]++;
    }

public UpdateText(playerid)
{
    new
        str[128];

    format(str, sizeof(str), "Matou: ~h~~g~%d", pStats[playerid][pMatou]);
    PlayerTextDrawSetString(playerid, StatusMatou[playerid], str);
    format(str, sizeof(str), "Morreu: ~h~~r~%d", pStats[playerid][pMorreu]);
    PlayerTextDrawSetString(playerid, StatusMorreu[playerid], str);
    return 1;
}
sу faltou salvar os kills kk
mais fico уtimo (minha opiniгo)
Reply
#8

Quote:
Originally Posted by SalvatoreBR
Посмотреть сообщение
Fiz um aqui para vocк bem simples...
Imagem de como ficou:

http://i.imgur.com/XFOiNVW.png

Cуdigo:
pawn Код:
enum e_PlayerStats
{
    pMatou,
    pMorreu
};

new pStats[MAX_PLAYERS][e_PlayerStats];

//Texts
new PlayerText:StatusBox[MAX_SLOTS];
new PlayerText:StatusInfo[MAX_SLOTS];
new PlayerText:StatusMatou[MAX_SLOTS];
new PlayerText:StatusMorreu[MAX_SLOTS];

new Updater;

//Ongamemodeinit
Updater = SetTimer("UpdateText",1000,true);

//Ongamemodeexit
KillTimer(Updater);

//OnPlayerConnect
    StatusBox[playerid] = CreatePlayerTextDraw(playerid, 621.199951, 288.220001, "usebox");
    PlayerTextDrawLetterSize(playerid, StatusBox[playerid], 0.000000, 7.564816);
    PlayerTextDrawTextSize(playerid, StatusBox[playerid], 493.200012, 0.000000);
    PlayerTextDrawAlignment(playerid, StatusBox[playerid], 1);
    PlayerTextDrawColor(playerid, StatusBox[playerid], 0);
    PlayerTextDrawUseBox(playerid, StatusBox[playerid], true);
    PlayerTextDrawBoxColor(playerid, StatusBox[playerid], 102);
    PlayerTextDrawSetShadow(playerid, StatusBox[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusBox[playerid], 0);
    PlayerTextDrawFont(playerid, StatusBox[playerid], 0);

    StatusInfo[playerid] = CreatePlayerTextDraw(playerid, 517.599975, 289.706604, "~h~~y~Status:");
    PlayerTextDrawLetterSize(playerid, StatusInfo[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawColor(playerid, StatusInfo[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusInfo[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusInfo[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusInfo[playerid], 51);
    PlayerTextDrawFont(playerid, StatusInfo[playerid], 2);
    PlayerTextDrawSetProportional(playerid, StatusInfo[playerid], 1);

    StatusMatou[playerid] = CreatePlayerTextDraw(playerid, 508.799987, 310.613281, "Matou:");
    PlayerTextDrawLetterSize(playerid, StatusMatou[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMatou[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMatou[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMatou[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMatou[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMatou[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMatou[playerid], 1);

    StatusMorreu[playerid] = CreatePlayerTextDraw(playerid, 508.000000, 330.026519, "Morreu:");
    PlayerTextDrawLetterSize(playerid, StatusMorreu[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawColor(playerid, StatusMorreu[playerid], -1);
    PlayerTextDrawSetShadow(playerid, StatusMorreu[playerid], 0);
    PlayerTextDrawSetOutline(playerid, StatusMorreu[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, StatusMorreu[playerid], 51);
    PlayerTextDrawFont(playerid, StatusMorreu[playerid], 3);
    PlayerTextDrawSetProportional(playerid, StatusMorreu[playerid], 1);

    pStats[playerid][pMatou] = 0;
    pStats[playerid][pMorreu] = 0;

//Onplayerdisconnect
PlayerTextDrawDestroy(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMorreu[playerid]);

//OnPlayerSpawn
PlayerTextDrawShow(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMorreu[playerid]);

//Onplayerdeath
    pStats[playerid][pMorreu]++;
    if(killerid != 0xFFFF)
    {
        pStats[killerid][pMatou]++;
    }

public UpdateText(playerid)
{
    new
        str[128];

    format(str, sizeof(str), "Matou: ~h~~g~%d", pStats[playerid][pMatou]);
    PlayerTextDrawSetString(playerid, StatusMatou[playerid], str);
    format(str, sizeof(str), "Morreu: ~h~~r~%d", pStats[playerid][pMorreu]);
    PlayerTextDrawSetString(playerid, StatusMorreu[playerid], str);
    return 1;
}
Nгo precisa usar SetTimer, use a callback OnPlayerDeath.
Reply
#9

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
Nгo precisa usar SetTimer, use a callback OnPlayerDeath.
Й que ele falou em mostrar mais alguns status, pensei jб em um timer global para englobar mais coisas como uma base, mas vocк estб correto nesse caso.

Quote:
Originally Posted by K1w0
Посмотреть сообщение
eu nгo entendo muito e vi esse cуdigo usando o search mais se nгo valeu de nada desculpe ;x


sу faltou salvar os kills kk
mais fico уtimo (minha opiniгo)
Й sу salvar, cara. Use o dof2, dini ou algo do tipo, й bem fбcil.
Reply
#10

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
Nгo precisa usar SetTimer, use a callback OnPlayerDeath.
Muito Bom mas aqui eu abri um GM Novo e ta igualzinho tudo que estб aн mas da erro no pMorreu pMatou ajuda ai!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)