24.07.2010, 13:39
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
pawn Code:
SetVehicleZAngle
pawn Code:
if(!IsPlayerInAnyVehicle(playerid))
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");
Now i will explain about GetPlayerVehicleID
First will need to make a varaible
pawn Code:
new vehicleid;
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"