Sziasztok! kurta999 kérte ezt a kis inc-et..
Készítõ: Fl0rian - Horváth Flórián
Teljesen mûködik!
A lényege hogy beállítja a jármû sebességét. ( km/h -ban )
Tesztelve!
Használata( pl mikor beszállsz a kocsiba állítsa be a sebességet 100-ra ):
public OnPlayerStateChange( playerid, newstate, oldstate ) {
new vehicleid = GetPlayerVehicleID( playerid );
if( newstate == PLAYER_STATE_DRIVER ) { SetVehicleSpeed( vehicleid, 100 ); }
return 1;
}
Letöltés [sOLIDFILES]^ Hibás. A kód a legfrissebb verzió!
KÓD: // Készítõ: Fl0rian @ sampforum.hu
new in_Timer[ MAX_VEHICLES ];
new de_Timer[ MAX_VEHICLES ];
stock GetVehicleSpeed( vehicleid ) {
new Float:vSpeed[3];
GetVehicleVelocity( vehicleid, vSpeed[0], vSpeed[1], vSpeed[2] );
new Float:vSpeed_Float;
vSpeed_Float = floatsqroot( ((vSpeed[0] * vSpeed[0]) + (vSpeed[1] * vSpeed[1])) + (vSpeed[2] * vSpeed[2])) * 161.0;
new vSpeed_Int;
vSpeed_Int = floatround( vSpeed_Float, floatround_round );
return vSpeed_Int;
}
stock SetVehicleSpeed( vehicleid, speed ) {
new iSpeed = GetVehicleSpeed( vehicleid );
if( iSpeed < speed ) {
KillTimer( de_Timer[ vehicleid ] );
in_Timer[ vehicleid ] = SetTimerEx( \"inCreaseVehicleSpeed\", 10, true, \"ii\", vehicleid, speed );
}
else {
KillTimer( in_Timer[ vehicleid ] );
de_Timer[ vehicleid ] = SetTimerEx( \"deCreaseVehicleSpeed\", 10, true, \"ii\", vehicleid, speed );
}
return 1;
}
forward inCreaseVehicleSpeed( vehicleid, speed );
public inCreaseVehicleSpeed( vehicleid, speed ) {
new Float: vSpeed[ 3 ];
new Float: Angle;
GetVehicleZAngle( vehicleid, Angle );
Angle += 90.0;
GetVehicleVelocity( vehicleid, vSpeed[0], vSpeed[1], vSpeed[2] );
new iSpeed = GetVehicleSpeed( vehicleid );
if( iSpeed < speed ) {
SetVehicleVelocity( vehicleid, vSpeed[0] + (floatcos(Angle, degrees) * 0.05 ), vSpeed[1] + (floatsin(Angle, degrees) * 0.05 ), vSpeed[2] );
}
if( iSpeed >= speed ) {
KillTimer( in_Timer[ vehicleid ] );
}
return 1;
}
forward deCreaseVehicleSpeed( vehicleid, speed );
public deCreaseVehicleSpeed( vehicleid, speed ) {
new Float: vSpeed[ 3 ];
new Float: Angle;
GetVehicleZAngle( vehicleid, Angle );
//Angle = Angle + 90.0;
GetVehicleVelocity( vehicleid, vSpeed[0], vSpeed[1], vSpeed[2] );
new iSpeed = GetVehicleSpeed( vehicleid );
SetVehicleVelocity( vehicleid, vSpeed[0] + (floatsin(Angle, degrees) * 0.05 ) * -1.0, vSpeed[1] + (floatcos(Angle, degrees) * 0.05 ) * -1.0, vSpeed[2] );
if( iSpeed >= speed ) {
KillTimer( de_Timer[ vehicleid ] );
}
return 1;
}