Author Topic: why this doesn't work ?  (Read 2002 times)

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
why this doesn't work ?
« on: July 28, 2012, 12:46:20 pm »
why this doesn't work ?


Code: [Select]
const RAMP_OBJECT = 1378;

objects <- array( GetMaxPlayers(), -1 );


function SpawnRamp( id, boost )
{
   local plr = FindPlayer( id );
   if ( plr )
   {
      local pos = plr.Pos;
      local rot = plr.Angle, rad = rot * PI / 180.0;
     
      local x = pos.x, y = pos.y;
      local x2 = x + 1.0 * cos(rad) - 25.0 * sin(rad);
      local y2 = y + 1.0 * sin(rad) + 25.0 * cos(rad);
     
      if ( objects[id] != -1 )
      {
         local obj = FindObject( objects[id] );
         if ( obj )
         {
            obj.Pos = Vector( x2, y2, pos.z - 0.3 );
            obj.Angle = Vector( 0.0, 0.0, rot + 270.0 );
         }
      }
      else
      {
         local obj = CreateObject( RAMP_OBJECT, Vector( x2, y2, pos.z ), Vector( 0.0, 0.0, rot + 270.0 ) );
         if ( obj )
         {
            objects[id] = obj.ID;
         }
      }
     
      if ( boost ) Boost( plr );
   }
}

function Boost( plr )
{
   local veh = plr.Vehicle;
   if ( veh )
   {
      local vel = veh.Velocity;
      vel.x *= 1.5;
      vel.y *= 1.5;
      vel.z *= 1.5;
     
      veh.Velocity = vel;
   }
}

function Fix( plr )
{
   local veh = plr.Vehicle;
   if ( veh )
   {
   plr.Vehicle.Fix();
   }
}

function Flip( plr )
{
   local veh = plr.Vehicle;
   if ( veh )
   {
    plr.Vehicle.Fix();
   local rot = plr.Vehicle.Angle;
   plr.Vehicle.Pos = plr.Vehicle.Pos;
   plr.Vehicle.Angle = rot;
   }
}

function Jump( plr )
{
   local veh = plr.Vehicle;
   if ( veh )
   {
   local vel = veh.Velocity;
   vel.x += 0;
   vel.y += 0;
   vel.z += 0.5;

    veh.Velocity = vel;
   }
}

function onPlayerPart( plr, reason )
{
   local id = plr.ID;
   if ( objects[id] != -1 )
   {
      local obj = FindObject( objects[id] );
      if ( obj )
      {
         obj.Remove();
         objects[id] = -1;
      }
   }
   
   return 1;
}

_______________________________________________________________________________


Code: [Select]
function onScriptLoad()
{
   BindKey( 'O', BINDTYPE_DOWN, "Ramp" );
   BindKey( 'P', BINDTYPE_DOWN, "RampWithBoost" );
   BindKey( 'I', BINDTYPE_DOWN, "Boost" );
   BindKey( 'U', BINDTYPE_DOWN, "Fix" );
   BindKey( 'Z', BINDTYPE_DOWN, "Flip" );
   BindKey( '2', BINDTYPE_DOWN, "Jump" );

   g_pLocalPlayer <- FindLocalPlayer();
   
   return 1;
}

function Ramp()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Ramp", g_pLocalPlayer.ID, false );
      }
   }
}

function RampWithBoost()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Ramp", g_pLocalPlayer.ID, true );
      }
   }
}

function Boost()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Boost", g_pLocalPlayer );
      }
   }
}

function Fix()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Fix", g_pLocalPlayer );
      }
   }
}

function Flip()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Flip", g_pLocalPlayer );
      }
   }
}

function Jump()
{
   local veh = g_pLocalPlayer.Vehicle;
   if ( veh )
   {
      local driver = veh.Driver;
      if ( driver && driver.ID == g_pLocalPlayer.ID )
      {
         CallServerFunc( "binds/binds.nut", "Jump", g_pLocalPlayer );
      }
   }
}
« Last Edit: July 30, 2012, 07:19:24 pm by SugarD »



Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: why this doesn't work ?
« Reply #1 on: July 28, 2012, 01:53:54 pm »
It does. Are you sure you are loading the client script as client script?
Also make sure you keep the original script names and folder.

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: why this doesn't work ?
« Reply #2 on: July 28, 2012, 02:03:59 pm »
yes



Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: why this doesn't work ?
« Reply #3 on: August 20, 2012, 11:14:09 am »
???

 

© Liberty Unleashed Team.