27.11.2013, 17:45 
	
	
	
		seeking function of the vehicle near the player data
Explame
Converter unix time to hours, minutes (and seconds)
Time_Convert - minutes, seconds.
Time_ConvertEx - hours, minutes, seconds.
Explame #1
Explame #2
	
	
	
	
Код:
stock visible_vehicles(playerid){
	new Float:distrace,Float:pos[ 4 ], vid ;
	GetPlayerPos( playerid, pos[0], pos[1], pos[2] );
	for(new i;i<MAX_VEHICLES;i++){
		distrace = GetVehicleDistanceFromPoint(i, pos[0], pos[1], pos[2] );
		if( distrace == 0.0 ) continue;
		if( distrace <= pos[ 3 ] ){	
			pos[ 3 ] = distrace;
			vid = i;
		}else if( pos[ 3 ] == 0.0 ){
			pos[ 3 ] = 5000.0;
		}
	}
	if( pos[ 3 ] != 5000.0 ){
		return vid;
	}
	return INVALID_VEHICLE_ID;
}
Код:
CMD:puth_to_vehicle( playerid, params[] ){
	
	new vehicle = visible_vehicles(playerid);
	if( vehicle == INVALID_VEHICLE_ID ) return 0;
	printf("vid %d", vehicle);
	PutPlayerInVehicle( playerid, vehicle, 0);
	
	return 1;
}
Time_Convert - minutes, seconds.
Time_ConvertEx - hours, minutes, seconds.
Код:
#define Time_Convert(%0,%1,%2) new %1 = floatround(((%0) / 60)); new %2 = floatround((%0) - (60 * (%1))) #define Time_ConvertEx(%0,%1,%2,%3) new %1 = floatround(((%0) / 3600)); new %2 = floatround(((%0) / 60) % 60); new %3 = floatround(((%0) - (60 * (%2))) - (3600 * %1) )
Код:
public OnFilterScriptInit()
{
	new czas = 99;
	
	Time_Convert(czas, tc_min, tc_sek);
	
	printf("%d sek  to %dmin %ds", czas, tc_min, tc_sek);
	
	Time_ConvertEx(czas, tcex_h, tcex_min, tcex_sek);
	
	printf("%d sek  to %dh %dmin %ds",czas, tcex_h, tcex_min, tcex_sek);
	
 	return 1;
}
Код:
#include a_samp
#include zcmd
#define Time_ConvertEx(%0,%1,%2,%3) new %1 = floatround(((%0) / 3600)); new %2 = floatround(((%0) / 60) % 60); new %3 = floatround(((%0) - (60 * (%2))) - (3600 * %1) )
new pOnline[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
	pOnline[playerid] = gettime();
	
	return 1;
}
CMD:ilegram(playerid, cmdtext[])
{
	new str[128];
	
	Time_ConvertEx(gettime()-pOnline[playerid], h, m, s);
	
	format(str, sizeof(str), "Grasz %dh %dm %ds", h, m, s);
	
	SendClientMessage(playerid, -1, str);
	return 1;
}


