/flip -
thefatshizms - 26.05.2012
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
Re: /flip -
justinnater - 26.05.2012
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;
}
Re: /flip -
thefatshizms - 26.05.2012
didnt explain bu didnt rly need to i understand! thanks +rep
Re: /flip -
Faisal_khan - 26.05.2012
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.
Re: /flip -
thefatshizms - 26.05.2012
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
)
AW: Re: /flip -
Nero_3D - 26.05.2012
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
Re: /flip -
iggy1 - 26.05.2012
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.
Re: /flip -
MP2 - 26.05.2012
The velocity isn't stopped when using SetVehicleZAngle, so restoring the velocity is un-necessary. You never used SetVehicleVelocity anyway.