Updating the TextDraw values.
#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


Messages In This Thread
Updating the TextDraw values. - by [NoV]LaZ - 10.08.2009, 18:51
*&gt;&lt;*&gt;&lt;* Updating the TextDraw values. *&gt;&lt;*&gt;&lt;* - by [NoV]LaZ - 11.08.2009, 13:35
Re: *><*><* Updating the TextDraw values. *><*><* - by notime - 17.11.2009, 20:32
Re: *><*><* Updating the TextDraw values. *><*><* - by LarzI - 17.11.2009, 21:10

Forum Jump:


Users browsing this thread: 1 Guest(s)