[Ajuda] TextDraw
#1

Galera eu criei um textdraw que mostra o nick do player nos status do player no canto da tela, mais quando esta 1 player so no server fica certo , mais quando entra 2 player, ai buga fica mudando os nick, como eu concerto isso?
Reply
#2

Posta o cуdigo pfvr, sу o que chama ela
Reply
#3

#include <a_samp>
#include <zcmd>
#define PLAYERS 200

new Text:Name;
new strt[256];

public OnPlayerConnect(playerid)
{
Name = TextDrawCreate(1.000000, 328.000000," ");
TextDrawBackgroundColor(Name, 255);
TextDrawFont(Name, 2);
TextDrawLetterSize(Name, 0.500000, 1.000000);
TextDrawColor(Name, 16711935);
TextDrawSetOutline(Name, 1);
TextDrawSetProportional(Name, 1);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

TextDrawHideForAll(Name);
return 1;
}

public OnPlayerSpawn(playerid)
{

TextDrawHideForPlayer(playerid,Name);
return 1;
}

if(IsPlayerConnected(playerid))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name,sizeof(name));
format(strt,sizeof(strt),"Nick: ~b~%s",name);
TextDrawSetString(Name,strt);
TextDrawShowForPlayer(playerid,Name);
}
return 1;
}

COMMANDnhaoff(playerid,params[])
{
TextDrawHideForPlayer(playerid,Name);
return 1;
}
Reply
#4

PHP код:
new Text:NameMAX_PLAYERS ]; 
OnGameModeInit
PHP код:
for( new 0MAX_PLAYERS; ++)
    {
        
Name] = TextDrawCreate(1.000000328.000000," ");
        
TextDrawBackgroundColor(Name], 255);
        
TextDrawFont(Name], 2);
        
TextDrawLetterSize(Name], 0.5000001.000000);
        
TextDrawColor(Name], 16711935);
        
TextDrawSetOutline(Name], 1);
        
TextDrawSetProportional(Name], 1);
    } 
OnPlayerSpawn
PHP код:
foreach(Player)
    {
        if(
IsPlayerConnected(i))
        {
            new 
name[MAX_PLAYER_NAME];
            
GetPlayerName(iname,sizeof(name));
            
format(strt,sizeof(strt),"Nick: ~b~%s",name));
            
TextDrawSetString(Name],strt);
        }
        return 
1;
    } 
Reply
#5

pegou nao deu erro pra todo lado
Reply
#6

Editei, tenta ae.

PHP код:
new Text:NameMAX_PLAYERS ]; 
OnGameModeInit
PHP код:
for( new 0MAX_PLAYERS; ++
    { 
        
Name] = TextDrawCreate(1.000000328.000000," "); 
        
TextDrawBackgroundColor(Name], 255); 
        
TextDrawFont(Name], 2); 
        
TextDrawLetterSize(Name], 0.5000001.000000); 
        
TextDrawColor(Name], 16711935); 
        
TextDrawSetOutline(Name], 1); 
        
TextDrawSetProportional(Name], 1); 
    }
SetTimer"NickInfo"5000false ); 
PHP код:
forward NickInfo( );
public 
NickInfo( )
{
    foreach(
Player)
    {
        new 
strt[256];
        
formatstrtsizeofstrt ), "Nick: ~b~%s ~w~ID: ~b~%d" PlayerName), );
        
TextDrawSetStringName], strt );
    }
    return 
1;

OnPlayerSpawn
PHP код:
TextDrawShowForPlayerplayeridNameplayerid ] ); 
Reply
#7

PlayerTextDraw foi feito exatamente para isto. Vamos simplificar.

PHP код:
#include <a_samp>
#include <zcmd>
#define PLAYERS 200
new PlayerText:Name[MAX_PLAYERS];
new 
bool:loggedFirstTime[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
loggedFirstTime[playerid] = true;
    
    
Name[playerid] = CreatePlayerTextDraw(playerid1.000000328.000000," ");
    
PlayerTextDrawBackgroundColor(playeridName[playerid], 255);
    
PlayerTextDrawFont(playeridName[playerid], 2);
    
PlayerTextDrawLetterSize(playeridName[playerid], 0.5000001.000000);
    
PlayerTextDrawColor(playeridName[playerid], 16711935);
    
PlayerTextDrawSetOutline(playeridName[playerid], 1);
    
PlayerTextDrawSetProportional(playeridName[playerid], 1);
    
    new 
playerName[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME 10];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    
format(strsizeof(str), "Nick: ~b~%s"playerName);
    
PlayerTextDrawSetString(playeridName[playerid], str);
    
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    if(
loggedFirstTime[playerid]) {
        
loggedFirstTime[playerid] = false;
        
PlayerTextDrawShow(playeridName[playerid]);
    }
    
    return 
1;
}
COMMAND:pnhaoff(playerid,params[])
{
    
PlayerTextDrawHide(playeridName[playerid]);
    return 
1;

Reply
#8

Para Mostrar o nick do jogador para ele mesmo use "CreatePlayerTextDraw" que sгo criadas apenas para um jogador especнfico, se vocк usar "TextDrawCreate" ira mostrar o nick de dodos os jogadores online e ira bugar. porque? porque a "TextDrawCreate" ela й global. fiz o codй pra vocк!

variбvel

PHP код:
new
    
PlayerText:MeuNick[MAX_PLAYERS],
    
Nick[24],
    
Format[50]

Coloque em OnPlayerConnect

PHP код:
    MeuNick[playerid] = CreatePlayerTextDraw(playerid,1.000000328.000000," ");
    
PlayerTextDrawBackgroundColor(playerid,MeuNick[playerid], 255);
    
PlayerTextDrawFont(playerid,MeuNick[playerid], 2);
    
PlayerTextDrawLetterSize(playerid,MeuNick[playerid], 0.5000001.000000);
    
PlayerTextDrawColor(playerid,MeuNick[playerid], 16711935);
    
PlayerTextDrawSetOutline(playerid,MeuNick[playerid], 1);
    
PlayerTextDrawSetProportional(playerid,MeuNick[playerid], 1); 
Agora vamos mostrar ao jogador o nick dele na textdraw, Coloque em OnPlayerSpawn

PHP код:
    if(IsPlayerConnected(playerid)){
    
GetPlayerName(playeridNicksizeof(Nick));
    
format(Formatsizeof(Format), "Nick: %s"Nick);
    
PlayerTextDrawSetString(playeridMeuNick[playerid], Format);
    
PlayerTextDrawShow(playeridPlayerText:MeuNick[playerid]);
    } 
Para Terminar em OnPlayerDisconnect
PHP код:
PlayerTextDrawDestroy(playeridMeuNick[playerid]); // Destruir text draw ao desconectar 
Eu nгo cheguei a testar, mas se de algo de errado poste aqui o erro!
Reply
#9

Quote:
Originally Posted by IgorLuiz
Посмотреть сообщение
Para Terminar em OnPlayerDisconnect
PHP код:
PlayerTextDrawDestroy(playeridMeuNick[playerid]); // Destruir text draw ao desconectar 
Eu nгo cheguei a testar, mas se de algo de errado poste aqui o erro!
Vocк disse exatamente o que eu disse, sу que com algumas coisas erradas.

Reply
#10

Quote:
Originally Posted by Lуs
Посмотреть сообщение
Vocк disse exatamente o que eu disse, sу que com algumas coisas erradas.

Realmente!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)