SA-MP Forums Archive
Jump Vehicle w/ Image - 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)
+--- Thread: Jump Vehicle w/ Image (/showthread.php?tid=353993)



Jump Vehicle w/ Image - kbalor - 25.06.2012

Im using a normal jump script. And i need to make it kinda advance.

Here are some examples.

When im below an object.


If i press Y to jump. I want to jump my vehicle without hitting in a object.


IS THERE ANY SCRIPT LIKE THIS?


Re: Jump Vehicle w/ Image - newbienoob - 25.06.2012

Urghh this?
pawn Код:
if(newkeys & KEY_YES)
{
      new veh = GetPlayerVehicleID(playerid);
      new Float:x,Float:y,Float:z;
      GetVehiclePos(veh,x,y,z);
      SetVehiclePos(veh,x,y,z+3);
      return 1;
}



Re: Jump Vehicle w/ Image - kbalor - 25.06.2012

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
Urghh this?
pawn Код:
if(newkeys & KEY_YES)
{
      new veh = GetPlayerVehicleID(playerid);
      new Float:x,Float:y,Float:z;
      GetVehiclePos(veh,x,y,z);
      SetVehiclePos(veh,x,y,z+3);
      return 1;
}
Man can you add that to this?

Quote:

if (newkeys & KEY_HORN)
{
if(IsPlayerInAnyVehicle(playerid))
{
new VehicleID,Float:B;
VehicleID = GetPlayerVehicleID(playerid);
GetVehicleZAngle(VehicleID,B);
SetVehicleZAngle(VehicleID,B);
SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
SetVehicleAngularVelocity(VehicleID,0,0,0);
}
}

I think its more better if i use that in flip.


Re: Jump Vehicle w/ Image - newbienoob - 25.06.2012

pawn Код:
if (newkeys & KEY_HORN)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new VehicleID,Float:B;
        VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(VehicleID,B);
        SetVehicleZAngle(VehicleID,B);
        SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
        SetVehicleAngularVelocity(VehicleID,0,0,0);
    }
    return 1;
}
if(newkeys & KEY_YES)
{
      new veh = GetPlayerVehicleID(playerid);
      new Float:x,Float:y,Float:z;
      GetVehiclePos(veh,x,y,z);
      SetVehiclePos(veh,x,y,z+3);
      return 1;
}



Re: Jump Vehicle w/ Image - kbalor - 25.06.2012

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
pawn Код:
if (newkeys & KEY_HORN)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new VehicleID,Float:B;
        VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(VehicleID,B);
        SetVehicleZAngle(VehicleID,B);
        SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
        SetVehicleAngularVelocity(VehicleID,0,0,0);
    }
    return 1;
}
if(newkeys & KEY_YES)
{
      new veh = GetPlayerVehicleID(playerid);
      new Float:x,Float:y,Float:z;
      GetVehiclePos(veh,x,y,z);
      SetVehiclePos(veh,x,y,z+3);
      return 1;
}
OMG! Finally. thanks man! +Rep You know this is a good script for stunt mode. sometimes if they fall out of boundary they just jump and boom! on the ground baby


Re: Jump Vehicle w/ Image - Grand_Micha - 25.06.2012

It is NOT jumping. It is setting your position. Please choose a more appropriate title next time.


Re: Jump Vehicle w/ Image - iggy1 - 25.06.2012

I don't see how any of the code posted will help you avoid hitting objects.

You would need to loop through all objects that are close to the player, and make sure none of them are at jumping height. If they are don't allow the jump. This would be difficult because most objects are different sizes.

In fact i think the code above could spawn you inside some objects. I'd rather bounce off an object than risk getting stuck in one.

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    {
        new VehicleID,Float:B;
        VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(VehicleID,B);
        SetVehicleZAngle(VehicleID,B);
        SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
        SetVehicleAngularVelocity(VehicleID,0,0,0);
    }
^^ I don't think that will work as expected, that will stop the vehicle from moving in every direction except z by 0.2. IMO car jumps should keep the car traveling. Also something pointless in the above code is getting the angle and setting it to the same value

Better version:

pawn Код:
new VehicleID = GetPlayerVehicleID(playerid);
if(VehicleID)
{
    new Float:fVelocity[3];
    GetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]);
    SetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]+0.2);
}
EDIT: Something else i just thought of; you should add anti-abuse for car jumping, if you spam the jump button it will appear as if your flying.


Re: Jump Vehicle w/ Image - kbalor - 25.06.2012

Quote:
Originally Posted by iggy1
Посмотреть сообщение
I don't see how any of the code posted will help you avoid hitting objects.

You would need to loop through all objects that are close to the player, and make sure none of them are at jumping height. If they are don't allow the jump. This would be difficult because most objects are different sizes.

In fact i think the code above could spawn you inside some objects. I'd rather bounce off an object than risk getting stuck in one.

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    {
        new VehicleID,Float:B;
        VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(VehicleID,B);
        SetVehicleZAngle(VehicleID,B);
        SetVehicleVelocity(VehicleID, 0.0, 0.0, 0.2);
        SetVehicleAngularVelocity(VehicleID,0,0,0);
    }
^^ I don't think that will work as expected, that will stop the vehicle from moving in every direction except z by 0.2. IMO car jumps should keep the car traveling. Also something pointless in the above code is getting the angle and setting it to the same value

Better version:

pawn Код:
new VehicleID = GetPlayerVehicleID(playerid);
if(VehicleID)
{
    new Float:fVelocity[3];
    GetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]);
    SetVehicleVelocity(VehicleID, fVelocity[0], fVelocity[1], fVelocity[2]+0.2);
}
EDIT: Something else i just thought of; you should add anti-abuse for car jumping, if you spam the jump button it will appear as if your flying.
Thanks help me alot!! It's fine its freeroam stunts and everything