Need Help with Progress2.inc
#1

Hi,
I created Progress bar. Let me tell you my Problem. I have created checkpoint and Add one vehicle ( cargobob ). I want that when i enter Cargobob and go for delivering it, the progress bar should increase as Far as i don't reach the checkpoint and it should decrease when i go far'away from the checkpoint.

BUT here i Managed some codes, These codes have a problem That when i enter cargobob and go for delivery, The progress bar don't increase nor decrease but when i enter the checkpoint it starts increasing.

I hope you got what i'm trying to say!

Here are the codes:

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vehicleid2;

	if(newstate == PLAYER_STATE_DRIVER)
	{
		vehicleid2 = GetPlayerVehicleID(playerid);

		if(vehicleid2 == OBJECTIVE_VEHICLE) ///WHEN PLAYER ENTERS CARGOBOB
		{
		//===================================================
        	PlayerTimer[ playerid ] = SetTimerEx("deliverupdate", 1000, true, "i", playerid );
         	PlayerDelieverValue[ playerid ] = 0;
                //===================================================
		}
	}
    return 1;
}

public OnPlayerConnect(playerid)
{
//=======================================================================//
    Progress[ playerid ] = CreatePlayerProgressBar( playerid , 5.00, 432.00, 111.50, 9.50, -1048321, 100.000000 , BAR_DIRECTION_RIGHT );
	Capturing[playerid] = CreatePlayerTextDraw( playerid , 81.600112, 433.066741 , "Deliver progress...0%" );
	PlayerTextDrawLetterSize(playerid , Capturing[playerid] , 0.205199, 1.226666);
	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;
    //=======================================
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
 	new playervehicleid = GetPlayerVehicleID(playerid);
    new name[MAX_PLAYER_NAME], string[100];
    GetPlayerName(playerid, name, sizeof(name));

 	if(ObjectiveReached) return 1;

	if(playervehicleid == OBJECTIVE_VEHICLE && gTeam[playerid] == TEAM_ATTACKERS)
	{
        format(string, sizeof(string), "{E1CC2B}» %s has Successfully delivered the Cargobob from Security Guards.", name);
        SendClientMessageToAll(-1, string);
        SendClientMessage(playerid,-1,"{7C7C7C}» You've Recieved 5 Points and $6,000 for delivering the Cargobob.");
       	GivePlayerMoney(playerid, 6000);
	    SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
	    ObjectiveReached = 1;
		SetTimerEx("NoExplode",500,false,"i", playerid);
        DestroyVehicle(OBJECTIVE_VEHICLE);
    	}
	    return 1;
	}
Код:
//==============================================================================//
forward deliverupdate( playerid );
public deliverupdate( playerid )
{
	if( !IsPlayerInRangeOfPoint( playerid, 20.0,  -290.0820,1873.8983,42.2891 )) //CHECKPOINT COORDINATES
	{
		//left the checkpoint
		KillTimer( PlayerTimer[ 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;
}
//==============================================================================//
Reply


Messages In This Thread
Need Help with Progress2.inc - by SpikY_ - 02.08.2015, 09:05
Re: Need Help with Progress2.inc - by Mariciuc223 - 02.08.2015, 09:34
Re: Need Help with Progress2.inc - by SpikY_ - 02.08.2015, 09:37
Re: Need Help with Progress2.inc - by SpikY_ - 02.08.2015, 09:39
Re: Need Help with Progress2.inc - by Mariciuc223 - 02.08.2015, 09:42
Re: Need Help with Progress2.inc - by SpikY_ - 02.08.2015, 09:44
Re: Need Help with Progress2.inc - by Mariciuc223 - 02.08.2015, 09:47
Re: Need Help with Progress2.inc - by SpikY_ - 03.08.2015, 12:55
Re: Need Help with Progress2.inc - by SecretBoss - 03.08.2015, 13:22

Forum Jump:


Users browsing this thread: 2 Guest(s)