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
#2

Код:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
	return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );
}
Take a look at that stock

Код HTML:
if(GetDistance(x, y, z, xPoint, yPoint, zPoint) < X) // Your stuff | x, y, z are cargobob pos ...
I hope this will help you
Reply
#3

-REMOVED-
lag xd
Reply
#4

You mean it will get The distance remain between cargobob and the checkpoint?
If yes, Then how can i use it with my codes :c
Reply
#5

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
You mean it will get The distance remain between cargobob and the checkpoint?
If yes, Then how can i use it with my codes :c
Yes , X1,Y1,Z1 = Cargo Bob pos
X2,Y2,Z2 = Reach point

It will get position in meters (i think)

Код HTML:
if(GetPosition(100.0, 50.0, 11.5, 200.0, 50.0, 11.0) < 50.0)
{
       new String[128];
       format(String, sizeof(String), "You are at the distance of %0.2f from point !", GetPosition(100.0, 50.0, 11.5, 200.0, 50.0, 11.0));
       SendClientMessage(playerid, -1, String);

       return 1;
}
I'm not sure but i think that's how it's used ..
Reply
#6

I used this type of codes from wiki. but the problem was same.
Reply
#7

That it's different of what you found on wiki .. (P.S: https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint - maybe that will be helpful)
Reply
#8

Can you please Tell me how can i use your codes with my script?
Reply
#9

Quote:
Originally Posted by Mariciuc223
Посмотреть сообщение
That it's different of what you found on wiki .. (P.S: https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint - maybe that will be helpful)
I used this to fix this bug but didn't work, Spiky I told where is the problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)