SA-MP Forums Archive
[Tutorial] Flip with a Key - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Flip with a Key (/showthread.php?tid=451107)



Flip with a Key - NerdCompany - 15.07.2013

Good evening all, today I wish to present my guide on how to make a button that flips the vehicle.

OK, start:

STEP 1: Define the key button. (For another key visit Here)

PHP Code:
#define flip KEY_NO //KEY NO IS "N" 
STEP 2: Now under the OnPlayerKeyStateChange callback we add our command.

PHP Code:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    
//THE FUNCTION HERE(THANKS TO RedFusion for the correction)
    
return 1;

STEP 3: Function, the code to insert into the callback is this:

PHP Code:
if( newkeys flip )
{
    if( 
IsPlayerInAnyVehicleplayerid ) )//This need to know if you are in a vehicle
    
{
        new 
currentveh GetPlayerVehicleIDplayerid ), Float:angle//This is for the id of your vehicle
        
        
GetVehicleZAnglecurrentvehangle ); //This get the Z angle
        
SetVehicleZAnglecurrentvehangle );//This SET the Z angle for our vehicle
        
        
SendClientMessageplayerid0xFFFFFFFF"The vehicle was flipped." ); //Is a message
    
}
}
return 
1;//remember this!!

Thanks, BYE


Re: Flip with a Key - gtakillerIV - 15.07.2013

Fix your indentation. Maybe also explain more?


Re: Flip with a Key - NerdCompany - 15.07.2013

Is the first tutorial, I'll do better soon ^^


Re: Flip with a Key - RedFusion - 15.07.2013

I don't really see how this is a tutorial.. So simple.
Yet, you did explain the small amount of information that was in there, that's good!

Btw i believe it's called a function, not a command


Re: Flip with a Key - NerdCompany - 15.07.2013

It is a small error,yes is a function ^^

Thanks RedFusion ^^