SA-MP Forums Archive
Need help with Textdraw bar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with Textdraw bar (/showthread.php?tid=582279)



Need help with Textdraw bar - SpikY_ - 19.07.2015

Hellu,
I am working on a Gamemode and there are many gamemodes in gamemode folder which changes by a timer one by one. OT: there is a stealing gamemode in which we have to steal the cargobob from the Security Guards.
For that i have created a textdraw which will show the Delievering progress of cargobob.
I want to make it like when the thieve enter the cargobob and go for the CHECKPOINT to Deliever it so the progress bar should increase as much as the player go near the checkpoint. and at a specific destination, progress bar should stop after delievering it to the checkpoint.
Have a look on the textdraw below ( attachments ):


Re: Need help with Textdraw bar - SilentSoul - 19.07.2015

Use progress bar include :- https://sampforum.blast.hk/showthread.php?tid=537468

And create your own bar where ever you want. and create a timer which repeat itself and check if the player is still on checkpoint ( IsPlayerInDynamicCP if you're using streamer ) increase the player progress bar. and when its 100% destroy the timer and hide the progress bar


Re: Need help with Textdraw bar - SpikY_ - 19.07.2015

Can i have some tips(codes) how to make :c?
Don't have much knowledge about Textdraws update


Re: Need help with Textdraw bar - SilentSoul - 19.07.2015

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.


Re: Need help with Textdraw bar - SpikY_ - 19.07.2015

Textdraw and progressbar ain't appearing.


Re: Need help with Textdraw bar - SilentSoul - 19.07.2015

Make sure you change the x, y, z location for all the code. Specially the timer one ( isplayerinrangeof.. )

I tested it and its working fine.


Re: Need help with Textdraw bar - SpikY_ - 19.07.2015

I know, Thats why i already change the co-ordinates but that textdraw ain't appear.

I have changed the xyz of
Код:
CreatePlayerTextDraw( playerid , 253.000000, 381.000000 , "Deliver progress...0%" );
and
Код:
CreatePlayerProgressBar( playerid , 253.000000, 381.000000, 121.000000, 5.000000, 11206655, 100.000000 , BAR_DIRECTION_RIGHT );



Re: Need help with Textdraw bar - SilentSoul - 19.07.2015

No, i mean the SetPlayerCheckpoint and IsPlayerInRangeOfPoint co-ordinates!


Re: Need help with Textdraw bar - SpikY_ - 19.07.2015

i just removed the line SetPlayerCheckpoint cause i have one under OnPlayerEnterVehicle
and about IsPlayerInRangeOfPoint i have added xyz coordinates of Checkpoint


Re: Need help with Textdraw bar - SilentSoul - 19.07.2015

May i see your code?