Liberty Unleashed

Scripting => Script Help => Topic started by: ADFENO on December 30, 2010, 03:53:24 pm

Title: Can I make a specified vehicle everythingproof
Post by: ADFENO on December 30, 2010, 03: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.
Title: Re: Can I make a specified vehicle everythingproof
Post by: Tamas on January 01, 2011, 12: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;
}
Title: :(
Post by: ADFENO on January 01, 2011, 04: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
Title: Re: Can I make a specified vehicle everythingproof
Post by: Force on January 01, 2011, 02: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.
Title: Re: Can I make a specified vehicle everythingproof
Post by: ADFENO on January 02, 2011, 02: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.
Title: Please...
Post by: ADFENO on January 02, 2011, 11:33:28 pm
If you want to answer, please make a exemple, like Tamas did.

Att. ADFENO
Have a nice day.
Title: Re: Can I make a specified vehicle everythingproof
Post by: Thijn on January 03, 2011, 03:36:01 pm
You may have to try a bit harder, since those scripts are perfectly fine.