Updating the TextDraw values.
#1

Hi all !

I'm making a text draw, who helps admins detecting cheaters.
The problem is that the TextDraw values are not updating, or the whole TextDraw is updating, making the values unreadable.

I'm trying to update the values, not the TextDraw, but I failed at doing this, so I ask you for help.


This is what i've done. Can you help me out ?
pawn Код:
#include <a_samp>



#define FILTERSCRIPT
forward PlayerInfo( playerid );
new Text:Info[ MAX_PLAYERS ];
public OnFilterScriptInit()
{
    SetTimer( "PlayerInfo", 1000, 1 );
    return 1;
   
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerCommandText( playerid, cmdtext[] )
{

 new
          PInfo,
        idx,
        cmd[ 128 ];
 cmd = strtok( cmdtext, idx );
 if(strcmp(cmd, "/info", true) == 0 )
 {
     new
       tmp[ 128 ],
       id;
     tmp = strtok( cmdtext, idx );
     id = strval( tmp );
     if ( !strlen( tmp ) )
     {
      SendClientMessage( playerid, 0x000000, "-Info- USAGE: /info <id>" ); return true;
     }

     PInfo = strval( tmp );
     if ( !IsPlayerConnected( PInfo ) )
     {
          SendClientMessage( playerid, 0x000000, "-Info- That player is not online." ); return true;
     }
       
     PlayerInfo( id );
     return true;
 }
 return false;
 
}

stock Weapons( playerid )
{
    new
      count,
        weapons,
        ammo,
        wepname[ 32 ],
        string[ 128 ];

    for ( new i = 0; i < 13; i++ )
    {
        GetPlayerWeaponData( playerid, i, weapons, ammo );
      if ( weapons != 0 )
        {
        count++;
        if ( weapons <= 15 || weapons == 46)
            {
             ammo = 1;
            }

            GetWeaponName( weapons, wepname, sizeof wepname );
            if ( count == 1 )
      {
              format( string, sizeof string,"%s(%d)",wepname,ammo );
        }
              else
        {
              format( string, sizeof string, "%s, %s(%d)", string, wepname, ammo );
      }
        }
    }
    if ( !count )
    {
      string = "None";
    }
    return string;
}

stock GetName( playerid )
{

  new name[ MAX_PLAYERS ];
 
  GetPlayerName( playerid, name, sizeof name );
  return name;
 
}

stock GetIp( playerid )
{

  new Ip[ 20 ];

    GetPlayerIp(playerid, Ip, sizeof Ip );
    return Ip;

}

strtok( const string[], &index, seperator = ' ' )
{
    new
      length = strlen( string ),
      offset = index,
      result[128];
    while ( ( index < length ) && ( string[ index ] != seperator ) && ( ( index - offset ) < ( sizeof( result ) - 1 ) ) )
    {
        result[ index - offset ] = string[ index ];
        index++;
    }

    result[ index - offset ] = EOS;
    if ( ( index < length ) && ( string[ index ] == seperator ) )
    {
        index++;
    }
    return result;
}

forward PlayerInfo( playerid );
public PlayerInfo( playerid )
{
    if ( IsPlayerConnected( playerid ) )
    {
        for ( new i = 0; i <= MAX_PLAYERS; i++ )
        {
       
         new
             string[ 256 ],
             Float:PHealth,
             Float:PArmour,
             //Float:VHealth,
         Money = GetPlayerMoney( i ),
         Ping = GetPlayerPing( i );
         //PVehicle = GetPlayerVehicleID( i );
         
         GetPlayerHealth( i, PHealth );
         GetPlayerArmour( i, PArmour );
         //GetVehicleHealth( PVehicle, VHealth );
         
         format( string, sizeof string, "%s (ID: %d) [ %s ]: ~n~Health/Armour: %.f/%.f | Ping: %d | Money: $%d ~n~Weapons: %s", GetName( i ), i, GetIp( i ), PHealth, PArmour, Ping, Money, Weapons( i ) );
         Info[ i ] = TextDrawCreate( 150, 300, string );
         TextDrawLetterSize( Info[ i ], 0.5, 1 );
         TextDrawShowForPlayer( i, Info[ i ] );
         }
    }
}
________
Zoloft settlements
Reply
#2

Sorry for bumping a 24 hourds old topic, but i've fixed the TextDraw values issue with the help of a friend, but it works only for ID 0. If I type /info 2, it will show the info for ID 0 and the TextDraw won't update.

pawn Код:
#include <a_samp>



#define FILTERSCRIPT
forward PlayerInfo( playerid );
new Text:Info[ MAX_PLAYERS ];
new y;
new Timer;
public OnFilterScriptInit()
{
 for( new playerid = 0; playerid <= MAX_PLAYERS; playerid++ )
 {
  Info[playerid] = TextDrawCreate( 150, 385, " " );
  TextDrawLetterSize( Info[ playerid ], 0.3, 0.8 );
  TextDrawColor( Info[ playerid ], 0x0066FFFF );
  TextDrawSetShadow( Info[ playerid ], 1 );
  TextDrawShowForPlayer( playerid, Info[ playerid ] );
 }
 return 1;
   
}

public OnFilterScriptExit()
{
 return 1;
}

public OnPlayerCommandText( playerid, cmdtext[] )
{

 new
          PInfo,
        idx,
        cmd[ 128 ];
        //id;
       
 cmd = strtok( cmdtext, idx );
 
 if( strcmp( cmd, "/info", true ) == 0 )
 {
       if( !IsPlayerAdmin( playerid ) ) return false;
     new
       tmp[ 128 ],
       id;
     tmp = strtok( cmdtext, idx );
     id = strval( tmp );
     if ( !strlen( tmp ) )
     {
      SendClientMessage( playerid, 0x000000, "-Info- USAGE: /info <id>" ); return true;
     }

     PInfo = strval( tmp );
     if ( !IsPlayerConnected( PInfo ) )
     {
          SendClientMessage( playerid, 0x000000, "-Info- That player is not online." ); return true;
     }
     TextDrawShowForPlayer( playerid, Info[ id ]);
     //SetTimer( "PlayerInfo", 600, 1 );
     Timer = SetTimerEx( "PlayerInfo", 600, 1, "i", PInfo );
     y = id;
         return true;
 }
 if( strcmp(cmdtext, "/infoff", true) == 0 )
 {
         if( IsPlayerAdmin( playerid ) ) return false;
         
     KillTimer( Timer );
         TextDrawHideForPlayer( playerid, Info[ playerid ] );
         SendClientMessage(playerid, 0x000000, ".: Debug :." );
         return true;
 }
 return true;

}
     

stock Weapons( playerid )
{
    new
      count,
        weapons,
        ammo,
        wepname[ 32 ],
        string[ 128 ];

    for ( new i = 0; i < 13; i++ )
    {
        GetPlayerWeaponData( playerid, i, weapons, ammo );
      if ( weapons != 0 )
        {
        count++;
        if ( weapons <= 15 || weapons == 46)
            {
             ammo = 1;
            }

            GetWeaponName( weapons, wepname, sizeof wepname );
            if ( count == 1 )
      {
              format( string, sizeof string,"%s(%d)",wepname,ammo );
        }
              else
        {
              format( string, sizeof string, "%s, %s(%d)", string, wepname, ammo );
      }
        }
    }
    if ( !count )
    {
      string = "None";
    }
    return string;
}

stock GetName( playerid )
{

  new name[ MAX_PLAYERS ];
 
  GetPlayerName( playerid, name, sizeof name ); return name;
 
}

stock GetIp( playerid )
{

  new Ip[ 20 ];

    GetPlayerIp(playerid, Ip, sizeof Ip ); return Ip;

}


forward PlayerInfo(playerid);
public PlayerInfo(playerid)
{
    if ( IsPlayerConnected( playerid ) )
    {

       
         new
             string[ 256 ],
             Float:Health,
             Float:Armour,
             tmp[ 128 ],
             id,
             //Float:VHealth,
         Money = GetPlayerMoney( playerid ),
         Ping = GetPlayerPing( playerid );
         //PVehicle = GetPlayerVehicleID( playerid );
         
         GetPlayerHealth( playerid, Health );
         GetPlayerArmour( playerid, Armour );
         //GetVehicleHealth( PVehicle, VHealth );
         id = strval( tmp );
         
         format( string, sizeof string, "%s (ID: %d) [ %s ]: ~n~Health/Armour: %.f/%.f | Ping: %d | Money: $%d ~n~Weapons: %s", GetName( id ), id, GetIp( id ), Health, Armour, Ping, Money, Weapons( id ) );
         TextDrawSetString( Info[ y ], string );
    }
}


strtok( const string[], &index, seperator = ' ' )
{
    new
      length = strlen( string ),
      offset = index,
      result[128];
    while ( ( index < length ) && ( string[ index ] != seperator ) && ( ( index - offset ) < ( sizeof( result ) - 1 ) ) )
    {
        result[ index - offset ] = string[ index ];
        index++;
    }

    result[ index - offset ] = EOS;
    if ( ( index < length ) && ( string[ index ] == seperator ) )
    {
        index++;
    }
    return result;
}
________
CamGirlHottie84
Reply
#3

i got some sort of bug to.
id 0 sees the textdraw normal but other id's see the textdraw from all players mixed on that spot and i dunno how thats possible.
Reply
#4

pawn Код:
TextDrawShowForPlayer( playerid, Info[ id ]);
change that to

pawn Код:
TextDrawShowForPlayer( PInfo, Info[ id ]);
and the same with

pawn Код:
TextDrawHideForPlayer( playerid, Info[ id ]);
change that to

pawn Код:
TextDrawHideForPlayer( PInfo, Info[ id ]);


This might not fix it, cuz it seems like this code is full of bugs and unecesarry vars.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)