Need Help - Spectate Textdraws
#1

hi guys,

my problem is I want to update the textdraws every second it's showing the textdraws but not updating it and I want to show all weapons in the textdraw but it's just showing only one weapon pls someone help. :\

my code is
pawn Код:
function StartSpectate( playerid, specplayerid )
{
    foreach(new x: Player)
        if ( GetPlayerState( x ) == PLAYER_STATE_SPECTATING && PlayerInfo[ x ][ SpecID ] == playerid )
           AdvanceSpectate( x );

    SetPlayerInterior( playerid, GetPlayerInterior( specplayerid ) );
    SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( specplayerid ) );
    TogglePlayerSpectating( playerid, 1 );
    SavePlayerCoords(playerid);

    if ( IsPlayerInAnyVehicle( specplayerid ) )
    {
        PlayerSpectateVehicle( playerid, GetPlayerVehicleID( specplayerid ) );
        PlayerInfo[ playerid ][ SpecID ]   = specplayerid;
        PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_VEHICLE;
    }
    else
    {
        PlayerSpectatePlayer( playerid, specplayerid );
        PlayerInfo[ playerid ][ SpecID ]   = specplayerid;
        PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_PLAYER;
    }

    gsString[ 0 ] = EOS;
    new
        Float:hp,
        Float:ar
    ;

    GetPlayerHealth( specplayerid, hp );
    GetPlayerArmour( specplayerid, ar );
    new ppPing = GetPlayerPing(specplayerid);
    new Float:ppPacket = GetPlayerPacketLoss(specplayerid);
   
    format( gsString, sizeof( gsString ), "~y~~h~FPS: ~r~~h~%d ~y~~h~Ping: ~r~~h~%d ~y~~h~PL: ~r~~h~%.1f%%",pFPS[specplayerid], ppPing, ppPacket  );
    PlayerTextDrawSetString(playerid, Spec_TD[1][playerid], gsString);
   
    format( gsString, sizeof( gsString ), "~g~~h~~h~%s [%d]",getPlayerName(specplayerid), specplayerid );
    PlayerTextDrawSetString(playerid, Spec_TD[2][playerid], gsString);
   
    format( gsString, sizeof( gsString ), "~y~~h~IP: ~r~~h~%s", GetPlayerIPEx(specplayerid) );
    PlayerTextDrawSetString(playerid, Spec_TD[3][playerid], gsString);
   
    format( gsString, sizeof( gsString ), "~y~~h~Health: ~r~~h~%.0f ~y~~h~Armour: ~r~~h~%.0f", hp, ar );
    PlayerTextDrawSetString(playerid, Spec_TD[4][playerid], gsString);
   
    format( gsString, sizeof( gsString ), "~y~~h~Money: ~g~~h~$~r~~h~%d", GetPlayerMoney( specplayerid ) );
    PlayerTextDrawSetString(playerid, Spec_TD[5][playerid], gsString);
   
    PlayerTextDrawShow(playerid, Spec_TD[0][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[6][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[1][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[2][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[3][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[4][playerid]);
    PlayerTextDrawShow(playerid, Spec_TD[5][playerid]);

        new
        slot,
        weap,
        ammos,
        Count,
        x
    ;

    for ( slot = 0; slot < 14; slot++ )
    {
        GetPlayerWeaponData( specplayerid, slot, weap, ammos );
        if ( ammos != 0 && weap != 0 ) Count++;
    }
    if ( Count < 1 )
        return format( gsString, sizeof( gsString ), "~r~~h~No Weapons", GetPlayerMoney( specplayerid ) ),
    PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
    PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);

    gsString[ 0 ] = EOS;
    new
        WeapName[ 24 ]
    ;
    if ( Count >= 1 )
    {
        for ( slot = 0; slot < 14; slot++ )
        {
            GetPlayerWeaponData( specplayerid, slot, weap, ammos );
            if ( ammos != 0 && weap != 0 )
            {
                GetWeaponName( weap, WeapName, sizeof( WeapName ) );

                if ( ammos == 65535 || ammos == 1 )
                    format( gsString, sizeof( gsString ),"%s~y~~h~%s: ~r~~h~(1)~n~", gsString, WeapName );
                else
                    format( gsString, sizeof( gsString ),"%s~y~~h~%s: ~r~~h~(%d)~n~", gsString, WeapName, ammos );

                x++;
                if ( x >= 5 )
                {
                    PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
                    PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);
                    x = 0;
                    format( gsString, sizeof( gsString ), "" );
                }
                else format( gsString, sizeof( gsString ), "%s,  ", gsString );
            }
        }
        if ( x <= 4 && x > 0 )
        {
            gsString[ strlen( gsString )-3 ] = '.';
            PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
            PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);
        }
    }
    return ( 1 );
}
Reply
#2

Код:
function StartSpectate( playerid, specplayerid )
{
	foreach(new x: Player)
	    if ( GetPlayerState( x ) == PLAYER_STATE_SPECTATING && PlayerInfo[ x ][ SpecID ] == playerid )
	       AdvanceSpectate( x );

	SetPlayerInterior( playerid, GetPlayerInterior( specplayerid ) );
	SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( specplayerid ) );
	TogglePlayerSpectating( playerid, 1 );
	SavePlayerCoords(playerid);

	if ( IsPlayerInAnyVehicle( specplayerid ) )
	{
		PlayerSpectateVehicle( playerid, GetPlayerVehicleID( specplayerid ) );
		PlayerInfo[ playerid ][ SpecID ]   = specplayerid;
		PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_VEHICLE;
	}
	else
	{
		PlayerSpectatePlayer( playerid, specplayerid );
		PlayerInfo[ playerid ][ SpecID ]   = specplayerid;
		PlayerInfo[ playerid ][ SpecType ] = ADMIN_SPEC_TYPE_PLAYER;
	}

	gsString[ 0 ] = EOS;
	new
		Float:hp,
		Float:ar
	;

	GetPlayerHealth( specplayerid, hp );
	GetPlayerArmour( specplayerid, ar );
	new ppPing = GetPlayerPing(specplayerid);
	new Float:ppPacket = GetPlayerPacketLoss(specplayerid);
	
	format( gsString, sizeof( gsString ), "~y~~h~FPS: ~r~~h~%d ~y~~h~Ping: ~r~~h~%d ~y~~h~PL: ~r~~h~%.1f%%",pFPS[specplayerid], ppPing, ppPacket  );
	PlayerTextDrawSetString(playerid, Spec_TD[1][playerid], gsString);
	
	format( gsString, sizeof( gsString ), "~g~~h~~h~%s [%d]",getPlayerName(specplayerid), specplayerid );
	PlayerTextDrawSetString(playerid, Spec_TD[2][playerid], gsString);
	
	format( gsString, sizeof( gsString ), "~y~~h~IP: ~r~~h~%s", GetPlayerIPEx(specplayerid) );
	PlayerTextDrawSetString(playerid, Spec_TD[3][playerid], gsString);
	
	format( gsString, sizeof( gsString ), "~y~~h~Health: ~r~~h~%.0f ~y~~h~Armour: ~r~~h~%.0f", hp, ar );
	PlayerTextDrawSetString(playerid, Spec_TD[4][playerid], gsString);
	
	format( gsString, sizeof( gsString ), "~y~~h~Money: ~g~~h~$~r~~h~%d", GetPlayerMoney( specplayerid ) );
	PlayerTextDrawSetString(playerid, Spec_TD[5][playerid], gsString);
	
 	PlayerTextDrawShow(playerid, Spec_TD[0][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[6][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[1][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[2][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[3][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[4][playerid]);
	PlayerTextDrawShow(playerid, Spec_TD[5][playerid]);

    	new
		slot,
		weap,
		ammos,
		Count,
		x
	;

    for ( slot = 0; slot < 14; slot++ )
    {
        GetPlayerWeaponData(specplayerid, slot, weap[i][0], weapo[i][1],ammos);
        if ( ammos != 0 && weap != 0 ) Count++;
    }
    if ( Count < 1 )
		return format( gsString, sizeof( gsString ), "~r~~h~No Weapons", GetPlayerMoney( specplayerid ) ),
	PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
	PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);

	gsString[ 0 ] = EOS;
	new
		WeapName[ 24 ]
	;
    if ( Count >= 1 )
    {
        for ( slot = 0; slot < 14; slot++ )
        {
               GetPlayerWeaponData(specplayerid, slot, weap[i][0], weapo[i][1],ammos);
            if ( ammos != 0 && weap != 0 )
            {
                GetWeaponName( weap, WeapName, sizeof( WeapName ) );

                if ( ammos == 65535 || ammos == 1 )
					format( gsString, sizeof( gsString ),"%s~y~~h~%s: ~r~~h~(1)~n~", gsString, WeapName );
                else
					format( gsString, sizeof( gsString ),"%s~y~~h~%s: ~r~~h~(%d)~n~", gsString, WeapName, ammos );

				x++;
                if ( x >= 5 )
                {
                    PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
					PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);
                    x = 0;
                    format( gsString, sizeof( gsString ), "" );
                }
                else format( gsString, sizeof( gsString ), "%s,  ", gsString );
            }
        }
        if ( x <= 4 && x > 0 )
        {
            gsString[ strlen( gsString )-3 ] = '.';
            PlayerTextDrawSetString(playerid, Spec_TD[7][playerid], gsString),
			PlayerTextDrawShow(playerid, Spec_TD[7][playerid]);
        }
    }
	return ( 1 );
}
No idea if it should work but give it a try
Reply
#3

TextDraws do not get updated automatically.You must manually the set the string every second.

Use SetTimer/SetTimerEx to create a timer which will update the textdraws every second.Or you can use OnPlayerUpdate to update the textdraws.

Код:
public OnPlayerUpdate()
{
      if(PlayerBeingSpeced[playerid] && (GetTickCount() - PreviousPlayerTick[playerid] > 1000)
      {
            PreviousPlayerTick[playerid] = GetTickCount();
            //Update all your textdraws here
      }
      return 1;
}
Reply
#4

Ok bro thanks I will try it but I also want to show the player weapons. Pls help
Reply
#5

sorry for the double post .
the textdraw update is working fine but it's just showing only 1 weapon but the player has 4 weapons. I want to show all weapons somebody help pls :\
Reply
#6

Bump please help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)