Need help with Textdraw bar
#4

pawn Код:
#include <a_samp>
#include <progress2>
#include <streamer>

new
        PlayerBar:Progress[ MAX_PLAYERS ],
        PlayerText:Capturing[ MAX_PLAYERS ],
        PlayerTimer[ MAX_PLAYERS ] = -1,
        PlayerDelieverValue[ MAX_PLAYERS ] = 0;
public OnPlayerConnect(playerid)
{
        Progress[ playerid ] = CreatePlayerProgressBar( playerid , 253.000000, 381.000000, 121.000000, 5.000000, 11206655, 100.000000 , BAR_DIRECTION_RIGHT );
    Capturing[playerid] = CreatePlayerTextDraw( playerid , 253.000000, 381.000000 , "Deliver progress...0%" );
    PlayerTextDrawLetterSize( playerid , Capturing[playerid] , 0.220000, 0.9 );
    PlayerTextDrawAlignment( playerid , Capturing[playerid] , 1 );
    PlayerTextDrawColor( playerid , Capturing[playerid] , -1 );
    PlayerTextDrawSetShadow( playerid , Capturing[playerid] , 0 );
    PlayerTextDrawSetOutline( playerid , Capturing[playerid] , -1 );
    PlayerTextDrawBackgroundColor( playerid , Capturing[playerid] , 255 );
    PlayerTextDrawFont( playerid , Capturing[playerid] , 1 );
    PlayerTextDrawSetProportional( playerid , Capturing[playerid] , 1 );
    PlayerTextDrawSetShadow( playerid , Capturing[playerid] , 0 );
   
    PlayerDelieverValue[ playerid ] = 0;
    SetPlayerCheckpoint( playerid, 2566, 256, 12, 20.0 );//just example
    return true;
}
public OnPlayerEnterCheckpoint(playerid)
{
    PlayerTimer[ playerid ] = SetTimerEx("deliverupdate", 1000, true, "i", playerid );
    PlayerDelieverValue[ playerid ] = 0;
    return true;
}
forward deliverupdate( playerid );
public deliverupdate( playerid )
{
    if( !IsPlayerInRangeOfPoint( playerid, 20.0,  2566, 256, 12 ))
    {
        //left the checkpoint
        KillTimer( PlayerTimer[ playerid ] );
        HidePlayerProgressBar( playerid, Progress[ playerid ] );
        PlayerTextDrawHide( playerid, Capturing[ playerid ] );
        return true;
    }
   
    new
        str[ 32 ];
    PlayerDelieverValue[ playerid ] += 5;
    SetPlayerProgressBarValue( playerid, Progress[ playerid ] , PlayerDelieverValue[ playerid ] );
    format( str, sizeof( str ) , "Deliver progress...%d%", PlayerDelieverValue[ playerid ] );
    PlayerTextDrawSetString( playerid, Capturing[playerid], str );

    ShowPlayerProgressBar( playerid, Progress[ playerid ] );
    PlayerTextDrawShow( playerid, Capturing[ playerid ] );
   
    if( PlayerDelieverValue[ playerid ] >= 100 )
    {
        KillTimer( PlayerTimer[ playerid ] );
        HidePlayerProgressBar( playerid, Progress[ playerid ] );
        PlayerTextDrawHide( playerid, Capturing[ playerid ] );
        //delivered.
    }
    return true;
}
EDIT: Sorry forgot to say, you need to check if the player inside the vehicle, if not destroy the timer, hope you got the idea of it.
Reply


Messages In This Thread
Need help with Textdraw bar - by SpikY_ - 19.07.2015, 14:33
Re: Need help with Textdraw bar - by SilentSoul - 19.07.2015, 14:52
Re: Need help with Textdraw bar - by SpikY_ - 19.07.2015, 15:07
Re: Need help with Textdraw bar - by SilentSoul - 19.07.2015, 15:25
Re: Need help with Textdraw bar - by SpikY_ - 19.07.2015, 15:44
Re: Need help with Textdraw bar - by SilentSoul - 19.07.2015, 15:47
Re: Need help with Textdraw bar - by SpikY_ - 19.07.2015, 15:50
Re: Need help with Textdraw bar - by SilentSoul - 19.07.2015, 15:54
Re: Need help with Textdraw bar - by SpikY_ - 19.07.2015, 16:07
Re: Need help with Textdraw bar - by SilentSoul - 19.07.2015, 16:11

Forum Jump:


Users browsing this thread: 4 Guest(s)