Author Topic: Can I make a specified vehicle everythingproof  (Read 4073 times)

ADFENO

  • Guest
Can I make a specified vehicle everythingproof
« on: December 30, 2010, 04:53:24 pm »
I am trying to make special admin vehicles, and make them everythingproof, in exemple, I will call a admin Patriot as Special Patriot.

When the admin type the command to spawn the Special Patriot, it will be always fixed when damaged. (Good  ;D)

But if a normal player spawn a vehicle, it will be always fixed too. (Bad ;D)

One part of my normal vehicle script is:
Code: [Select]
function onPlayerCommand( pPlayer, szCommand, szText )
{
                if ( szCommand == "patriot" )
                {
                                local pos = pPlayer.Pos;
                                local pVehicle = CreateVehicle( VEH_PATRIOT, Vector( pos.x + 5, pos.y, pos.z + 2 ), pPlayer.Angle, -1, -1 );
                                pVehicle.OneTime = true;
                }
                return 1;
}

My Special Patriot script is:
Code: [Select]
function onPlayerCommand( pPlayer, szCommand, szText )
{
                if ( szCommand == "veh_special" )
                {
                                if ( szText == "1" )
                                {
                                                local pos = pPlayer.Pos;
                                                local vehspc = CreateVehicle( VEH_PATRIOT, Vector( pos.x + 5, pos.y, pos.z + 2 ), pPlayer.Angle, 0, 6 );
                                                vehspc.OneTime = true;
                                                CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );
                                }
                }
                return 1;
}

The "specials.nut", called in my Special Patriot script:
Code: [Select]
function onVehicleHealthChange( vehspc, oldhp, newhp )
{
                if ( oldhp > newhp )
                {
                                vehspc.Fix();
                }
                else if ( oldhp < newhp )
                {
                                vehspc.Fix();
                }
return 1;
}

I want this: Only the Special Patriot is always fixed when damaged, not the normal player vehicles.

I hope you understand.

Att. ADFENO
Have a nice day.
« Last Edit: December 30, 2010, 04:55:44 pm by ADFENO »

Tamas

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
    • LCDM
Re: Can I make a specified vehicle everythingproof
« Reply #1 on: January 01, 2011, 01:37:35 am »
Code: [Select]
IsSpecial <- false;

function onPlayerCommand( pPlayer, szCommand, szText )
{
                if ( szCommand == "veh_special" )
                {
                                if ( szText == "1" )
                                {
                                                local pos = pPlayer.Pos;
                                                local vehspc = CreateVehicle( VEH_PATRIOT, Vector( pos.x + 5, pos.y, pos.z + 2 ), pPlayer.Angle, 0, 6 );
                                                vehspc.OneTime = true;
                                                CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );
                                                IsSpecial = true;
                                }
                }
                return 1;
}

Code: [Select]
function onVehicleHealthChange( vehspc, oldhp, newhp )
{
                if ( newhp < 1000 )
                {
                                if ( vehspc.Driver.Name == "ADFENO" && IsSpecial == true ) vehspc.Fix();
                }
return 1;
}

ADFENO

  • Guest
:(
« Reply #2 on: January 01, 2011, 05:10:36 am »
Code: [Select]
IsSpecial <- false;

function onPlayerCommand( pPlayer, szCommand, szText )
{
                if ( szCommand == "veh_special" )
                {
                                if ( szText == "1" )
                                {
                                                local pos = pPlayer.Pos;
                                                local vehspc = CreateVehicle( VEH_PATRIOT, Vector( pos.x + 5, pos.y, pos.z + 2 ), pPlayer.Angle, 0, 6 );
                                                vehspc.OneTime = true;
                                                CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );
                                                IsSpecial = true;
                                }
                }
                return 1;
}

Code: [Select]
function onVehicleHealthChange( vehspc, oldhp, newhp )
{
                if ( newhp < 1000 )
                {
                                if ( vehspc.Driver.Name == "ADFENO" && IsSpecial == true ) vehspc.Fix();
                }
return 1;
}

For me, this doesn't work.
 ;D

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Can I make a specified vehicle everythingproof
« Reply #3 on: January 01, 2011, 03:29:37 pm »
It won't work, Tamas cocked up something :P.

Needs to be;

Code: [Select]
IsSpecial <- true;

Instead of;

Code: [Select]
IsSpecial = true;

Oh, and remove the;

Code: [Select]
CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );

It's not needed, will automatically go off when that vehicle is damaged.
« Last Edit: January 01, 2011, 03:31:22 pm by Force »
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

ADFENO

  • Guest
Re: Can I make a specified vehicle everythingproof
« Reply #4 on: January 02, 2011, 03:05:01 am »
It won't work, Tamas cocked up something :P.

Needs to be;

Code: [Select]
IsSpecial <- true;

Instead of;

Code: [Select]
IsSpecial = true;

Oh, and remove the;

Code: [Select]
CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );

It's not needed, will automatically go off when that vehicle is damaged.

Still not worling.

ADFENO

  • Guest
Please...
« Reply #5 on: January 03, 2011, 12:33:28 am »
If you want to answer, please make a exemple, like Tamas did.

Att. ADFENO
Have a nice day.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Can I make a specified vehicle everythingproof
« Reply #6 on: January 03, 2011, 04:36:01 pm »
You may have to try a bit harder, since those scripts are perfectly fine.

 

© Liberty Unleashed Team.