[ajuda] textdraw
#1

Galera nгo sei pq mais o textdraw abaixo que mostra quantos jogadores tem online, fica duplicado com um texto branco atras, como se fosse dois textos.

pawn Код:
#include <a_samp>
#define SEC1 1000
#define SEC2 2000
#define SEC5 5000

new Text:PlayersOnServer;
new string[16];
new MaxP;
new totalon;

public OnFilterScriptInit()
{
 print("\n--------------------------------------");
 print("  Show Players who are online by Adsy ");
 print("--------------------------------------\n");
 MaxP = GetMaxPlayers();

 drawagain();
 SetTimer("pOnline", SEC2, 1);
 return 1;
}

public OnFilterScriptExit()
{
    for(new i=0; i<MAX_PLAYERS; i++) {
        TextDrawHideForPlayer(i, PlayersOnServer);
    }
    return 1;
}

forward drawagain();
public drawagain(){
    if(PlayersOnServer){
        TextDrawDestroy(PlayersOnServer);
    }
    format(string, sizeof(string), "%i/%i PLAYERS", totalon, MaxP);
    PlayersOnServer = TextDrawCreate(30,326, string);
    return 1;
}

forward pOnline();
public pOnline(){
    totalon = 0;
    for(new i=0; i<MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(totalon == 0){
                totalon = 1;
            }
            else if (totalon > 0){
                totalon++;
            }
        }

    }

    drawagain();
    TextDrawFont(PlayersOnServer,1);
    TextDrawUseBox(PlayersOnServer,0);
    TextDrawColor(PlayersOnServer,0xFF7100FF);
    TextDrawBackgroundColor(PlayersOnServer,0x000000AA);
    TextDrawAlignment(PlayersOnServer, 1);
    TextDrawSetOutline(PlayersOnServer,1);
    TextDrawSetShadow(PlayersOnServer,0);

    for(new i=0; i<MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            TextDrawShowForPlayer(i, PlayersOnServer);
        }
        else{
            TextDrawHideForPlayer(i, PlayersOnServer);
        }
    }

    return 1;
}
Reply
#2

Troque:
pawn Код:
new Text:PlayersOnServer;
Por:
pawn Код:
new Text:PlayersOnServer[MAX_PLAYERS];
E todos os lugares que forem usado a variбvel PlayersOnServer, mude para playerid ou o valor do loop.
Reply
#3

Quote:
Originally Posted by Hardware
Посмотреть сообщение
Troque:
pawn Код:
new Text:PlayersOnServer;
Por:
pawn Код:
new Text:PlayersOnServer[MAX_PLAYERS];
E todos os lugares que forem usado a variбvel PlayersOnServer, mude para playerid ou o valor do loop.
Eu mudei tudo que estava PlayersOnServer para playerid e deu 11 erros

pawn Код:
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(41) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(44) : warning 217: loose indentation
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(49) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(50) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(62) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(81) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(82) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(83) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(84) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(85) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(93) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(97) : error 017: undefined symbol "playerid"
C:\Users\Alex\Desktop\samp03dsvr_R2_win32\filterscripts\online.pwn(103) : warning 203: symbol is never used: "PlayersOnServer"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


11 Errors.
Veja se esta certo

pawn Код:
#include <a_samp>
#define SEC1 1000
#define SEC2 2000
#define SEC5 5000

new Text:PlayersOnServer[MAX_PLAYERS];
new Text:LastPOnServer;
new string[32];
new string2[50];
new PName[MAX_PLAYER_NAME];
new MaxP;
new totalon;
new onoff = 0;

public OnFilterScriptInit()
{
 print("\n--------------------------------------");
 print(" Show Players who are online by Adsy ");
 print("--------------------------------------\n");
 MaxP = GetMaxPlayers();
 drawagain();
 SetTimer("pOnline", SEC2, 1);
 return 1;
}

public OnPlayerConnect(playerid){
 GetPlayerName(playerid, PName, sizeof(PName));
 onoff = 1;
 return 0;
}

public OnPlayerDisconnect(playerid, reason){
 GetPlayerName(playerid, PName, sizeof(PName));
 onoff = 0;
 return 0;
}

public OnFilterScriptExit()
{
  for(new i=0; i<MAX_PLAYERS; i++) {
    TextDrawHideForPlayer(i, playerid);
    TextDrawHideForPlayer(i, LastPOnServer);
  }
    return 1;
}

forward drawagain();
public drawagain(){
  if(playerid){
    TextDrawDestroy(playerid);
  }
  if(LastPOnServer){
    TextDrawDestroy(LastPOnServer);
  }
  format(string, sizeof(string), "%i/%i Online", totalon, MaxP);
  if(onoff == 1){
    format(string2, sizeof(string2), "Last on: %s", PName);
  }
  if(onoff == 0){
    format(string2, sizeof(string2), "Last off: %s", PName);
  }
  playerid = TextDrawCreate(30,326, string);
  LastPOnServer = TextDrawCreate(30,318, string2);
  return 0;
}

forward pOnline();
public pOnline(){
  totalon = 0;
  for(new i=0; i<MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i)) {
      if(totalon == 0){
        totalon = 1;
      }
      else if (totalon > 0){
        totalon++;
      }
    }
  }
  drawagain();
  TextDrawFont(playerid,2);
  TextDrawUseBox(playerid,0);
  TextDrawColor(playerid,0xFFFFFFFF);
  TextDrawAlignment(playerid, 1);
  TextDrawLetterSize(playerid, 0.6, 0.8);
  TextDrawFont(LastPOnServer,1);
  TextDrawUseBox(LastPOnServer,0);
  TextDrawColor(LastPOnServer,0xFFFFFFFF);
  TextDrawAlignment(LastPOnServer, 1);
  TextDrawLetterSize(LastPOnServer, 0.5, 0.8);
  for(new i=0; i<MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i) && GetPlayerInterior(i) < 1) {
      TextDrawShowForPlayer(i, playerid);
      TextDrawShowForPlayer(i, LastPOnServer);
    }
    else{
      TextDrawHideForPlayer(i, playerid);
      TextDrawHideForPlayer(i, LastPOnServer);
    }
  }
  return 1;
}
Reply
#4

Odeio POG ( Programaзгo Orientada a Gambiarra)
por isto eu reformulei o script, tornando mais rбpido e eficiente.

pawn Код:
#include <a_samp>

new Text:PlayersOnServer;

public OnFilterScriptInit()
{
    print("\n------------------------------------------------------------------");
    print("  Show Players who are online by Adsy fixed by: DarkScripter");
    print("------------------------------------------------------------------\n");
   
    PlayersOnServer = TextDrawCreate(30,326, #);
    TextDrawUseBox(PlayersOnServer,0);
    TextDrawColor(PlayersOnServer,0xFF7100FF);
    TextDrawBackgroundColor(PlayersOnServer,0x000000AA);
    TextDrawAlignment(PlayersOnServer, 1);
    TextDrawSetOutline(PlayersOnServer,1);
    TextDrawSetShadow(PlayersOnServer,0);
    return 1;
}

public OnFilterScriptExit()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        TextDrawHideForPlayer(i, PlayersOnServer);
    }
    TextDrawDestroy(PlayersOnServer);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return f_OnPlayerConnect(playerid);
}


forward f_OnPlayerConnect(p);
public f_OnPlayerConnect(p)
{
    new conected = 0, string[15];
    for(new i, e = GetMaxPlayers(); i != e; ++i)
    {
        conected += IsPlayerConnected(i);
    }
    format(string, sizeof(string), "%i/%i PLAYERS", conected, GetMaxPlayers());
    TextDrawSetString(PlayersOnServer, string);
    TextDrawShowForAll(PlayersOnServer);
    return 1;
}
Reply
#5

Quote:
Originally Posted by DarkScripter
Посмотреть сообщение
Odeio POG ( Programaзгo Orientada a Gambiarra)
por isto eu reformulei o script, tornando mais rбpido e eficiente.

pawn Код:
#include <a_samp>

new Text:PlayersOnServer;

public OnFilterScriptInit()
{
    print("\n------------------------------------------------------------------");
    print("  Show Players who are online by Adsy fixed by: DarkScripter");
    print("------------------------------------------------------------------\n");
   
    PlayersOnServer = TextDrawCreate(30,326, #);
    TextDrawUseBox(PlayersOnServer,0);
    TextDrawColor(PlayersOnServer,0xFF7100FF);
    TextDrawBackgroundColor(PlayersOnServer,0x000000AA);
    TextDrawAlignment(PlayersOnServer, 1);
    TextDrawSetOutline(PlayersOnServer,1);
    TextDrawSetShadow(PlayersOnServer,0);
    return 1;
}

public OnFilterScriptExit()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        TextDrawHideForPlayer(i, PlayersOnServer);
    }
    TextDrawDestroy(PlayersOnServer);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return f_OnPlayerConnect(playerid);
}


forward f_OnPlayerConnect(p);
public f_OnPlayerConnect(p)
{
    new conected = 0, string[15];
    for(new i, e = GetMaxPlayers(); i != e; ++i)
    {
        conected += IsPlayerConnected(i);
    }
    format(string, sizeof(string), "%i/%i PLAYERS", conected, GetMaxPlayers());
    TextDrawSetString(PlayersOnServer, string);
    TextDrawShowForAll(PlayersOnServer);
    return 1;
}
Valeu cara funcionou!!! +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)