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; } //==============================================================================//
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 ) ) ) ) ); }
if(GetDistance(x, y, z, xPoint, yPoint, zPoint) < X) // Your stuff | x, y, z are cargobob pos ...
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 |
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; }
That it's different of what you found on wiki .. (P.S: https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint - maybe that will be helpful)
|