SA-MP Forums Archive
[Tutorial] [TUT]Making a simple flip command - 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] [TUT]Making a simple flip command (/showthread.php?tid=162708)



[TUT]Making a simple flip command - Jay. - 24.07.2010

Making a simple /flip command
Hey all today i am going to show you how to make a very simple /flip command.

Lets start then.

now today we will be using some very simple funtions such as

pawn Code:
IsPlayerInAnyVehicle
pawn Code:
GetPlayerVehicleID
pawn Code:
GetVehicleZAngle
and
pawn Code:
SetVehicleZAngle
Now let me explain how IsPlayerInAnyVehicle works.

pawn Code:
if(!IsPlayerInAnyVehicle(playerid))
This will check if the player is in a vehicle

And if he isn't in a vehicle we can return a message.

Like this:

pawn Code:
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,color,"You must be in a vehicle");
Okay i hope i explained that well.

Now i will explain about GetPlayerVehicleID

First will need to make a varaible

pawn Code:
new vehicleid;
Now theres the varaible made lets move on

now we can use GetPlayerVehicleID

[pawn]vehicleid = GetPlayerVehicleID(playerid);/pawn]

This gets the players vehicleid.

Now we're gonna move on to

GetVehicleZAngle

Right first we need to create a Float


pawn Code:
new Float:vangle;

now we can use GetVehicleZAngle

So lets explain how this works.

[pawn]GetVehicleZAngle(vehicleid,zangle);/pawn]

this gets the players vehicle.

Ok lastly we have

SetVehicleZAngle

Now this will Set the players vehicle back to the current position.

Ok

And when your finished your code should look like this.


pawn Code:
if (strcmp("/flip", cmdtext, true, 10) == 0)
    {   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED2,"You must be in a vehicle.");
        {
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
        SendClientMessage(playerid,color,"Vehicle succesfully flipped.");
        }

        return 1;
    }

Remmeber to define "color"


Re: [TUT]Making a simple flip command - willsuckformoney - 24.07.2010

seems useful good job!


Re: [TUT]Making a simple flip command - Jay. - 24.07.2010

Quote:
Originally Posted by willsuckformoney
View Post
seems useful good job!
Thanks..


Re: [TUT]Making a simple flip command - Carlton - 24.07.2010

pawn Code:
if (strcmp("/flip", cmdtext, true, 10) == 0)
{  
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED2,"You must be in a vehicle.");
        {
             new vehicle;
             new Float:zangle;
             vehicle = GetPlayerVehicleID(playerid);
             GetVehicleZAngle(vehicle,zangle);
             SetVehicleZAngle(vehicle,zangle);
             SendClientMessage(playerid,color,"Vehicle succesfully flipped.");
        }
        return 1;
}
That won't work


Re: [TUT]Making a simple flip command - Flo_White - 24.07.2010

pawn Code:
if (strcmp("/flip", cmdtext, true, 5) == 0)
{  
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED2,"You must be in a vehicle.");
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
        SendClientMessage(playerid,color,"Vehicle succesfully flipped.");
        return 1;
}
this should work


Re: [TUT]Making a simple flip command - Agent Smith - 24.07.2010

Why would that work? You getting the zangle and then your setting the vehicle to the same zangle.. Lool


Re: [TUT]Making a simple flip command - Flo_White - 24.07.2010

read the wiki
nearly the same code is there xD
https://sampwiki.blast.hk/wiki/SetVehicleZAngle


Re: [TUT]Making a simple flip command - willsuckformoney - 24.07.2010

true ^^^^^^^^^^


Re: [TUT]Making a simple flip command - hab2ever - 25.07.2010

Great Job xD


Re: [TUT]Making a simple flip command - Jay. - 25.07.2010

Quote:
Originally Posted by hab2ever
View Post
Great Job xD
Thanks guys.

And i've tested this code and it works fine thats why i use it in my server.


Re: [TUT]Making a simple flip command - Jay. - 25.07.2010

Quote:
Originally Posted by Samdudes
View Post
Why would that work? You getting the zangle and then your setting the vehicle to the same zangle.. Lool
Lol zangle is the name of my varaible i chose you can choose anyone you want.


Re: [TUT]Making a simple flip command - CSMajor - 25.07.2010

Quote:
Originally Posted by Flo_White
View Post
pawn Code:
if (strcmp("/flip", cmdtext, true, 5) == 0)
{  
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED2,"You must be in a vehicle.");
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
        SendClientMessage(playerid,color,"Vehicle succesfully flipped.");
        return 1;
}
this should work
i do not understand the z angle thing. but this works. i thought it would stay flipped but it didnt.


Re: [TUT]Making a simple flip command - John_F - 28.07.2010

For those of you who don't understand:
setting a vehicle's z angle automatically puts it upright, so in essense this script just sets the car back to the position it was when you entered the command, except, it will be upright.