[Tutorial] [TUT]Making a simple flip command
#1

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"
Reply
#2

seems useful good job!
Reply
#3

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

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
Reply
#5

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
Reply
#6

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

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

true ^^^^^^^^^^
Reply
#9

Great Job xD
Reply
#10

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.
Reply
#11

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.
Reply
#12

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.
Reply
#13

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)