#1

im a noob i wanna know how i would make a cmd like /flip while in a car so
if ur car has gone on its back u do /flip and it flips your car and repairs it

could someone give me the code BUT! explain which each line does in comments
Reply
#2

if(strcmp(cmdtext, "/flip", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new currentveh;
new Float:angle;
currentveh = GetPlayerVehicleID(playerid);
GetVehicleZAngle(currentveh, angle);
SetVehicleZAngle(currentveh, angle);
SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
RepairVehicle(tmpcar);
return 1;
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You are not in any vehicle!");
return 1;
}
}
return 0;
}
Reply
#3

didnt explain bu didnt rly need to i understand! thanks +rep
Reply
#4

I will explain you:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

  if(strcmp(cmdtext, "/flip", true) == 0)
  {
  if(IsPlayerInAnyVehicle(playerid))
  {
    new currentveh;
    new Float:angle;
    currentveh = GetPlayerVehicleID(playerid);//with this we will get the vehicle id
    GetVehicleZAngle(currentveh, angle);//we will get to know the current Z angle of vehicle, i.e. Z angle of the vehicle which will let us know how the vehicle is.
    SetVehicleZAngle(currentveh, angle);//if we use this the Z angel of the vehicle will become the opposite of the Z angle of wat we got from the above function
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
    return 1;
  }
  else
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "You are not in any vehicle!");
    return 1;
  }
  }
   return 0;
}
That's it, hope you understand.
Reply
#5

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
I will explain you:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

  if(strcmp(cmdtext, "/flip", true) == 0)
  {
  if(IsPlayerInAnyVehicle(playerid))
  {
    new currentveh;
    new Float:angle;
    currentveh = GetPlayerVehicleID(playerid);//with this we will get the vehicle id
    GetVehicleZAngle(currentveh, angle);//we will get to know the current Z angle of vehicle, i.e. Z angle of the vehicle which will let us know how the vehicle is.
    SetVehicleZAngle(currentveh, angle);//if we use this the Z angel of the vehicle will become the opposite of the Z angle of wat we got from the above function
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
    return 1;
  }
  else
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "You are not in any vehicle!");
    return 1;
  }
  }
   return 0;
}
That's it, hope you understand.
yeh thanks i understood it but his indentication was awful ( no offence justinnater )
Reply
#6

The truth is that the function SetVehicleZAngle sets the vehicle x (pitch) and y (roll) to 0.0 and the z (yaw) angle to the value passed
Reply
#7

You could make one that lets the car continue moving too. Most of this is from Faisal_khan.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

  if(strcmp(cmdtext, "/flip", true) == 0)
  {
      if(IsPlayerInAnyVehicle(playerid))
      {
            new currentveh;
            new Float:angle, Float:fVx, Float:fVy, Float:fVz;
            currentveh = GetPlayerVehicleID(playerid);//with this we will get the vehicle id
            GetVehicleVelocity( currentveh, fVx, fVy, fVz );//get velocity before flip
            GetVehicleZAngle(currentveh, angle);//we will get to know the current Z angle of vehicle, i.e. Z angle of the vehicle which will let us know how the vehicle is.
            SetVehicleZAngle(currentveh, angle);//if we use this the Z angel of the vehicle will become the opposite of the Z angle of wat we got from the above function
            GetVehicleVelocity( currentveh, fVx, fVy, fVz );//set velocity after flip
            SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
            return 1;
      }
      else
      {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are not in any vehicle!");
            return 1;
      }
  }
   return 0;
}
EDIT: Not sure you need to do this with this method of flipping "SetVehicleZAngle", but you do need to with the "SetVehiclePos" method because it stops the vehicle. So oops if this was pointless.
Reply
#8

The velocity isn't stopped when using SetVehicleZAngle, so restoring the velocity is un-necessary. You never used SetVehicleVelocity anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)