Liberty Unleashed
Scripting => Script Help => Topic started 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:
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:
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:
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.
-
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;
}
function onVehicleHealthChange( vehspc, oldhp, newhp )
{
if ( newhp < 1000 )
{
if ( vehspc.Driver.Name == "ADFENO" && IsSpecial == true ) vehspc.Fix();
}
return 1;
}
-
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;
}
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
-
It won't work, Tamas cocked up something :P.
Needs to be;
IsSpecial <- true;
Instead of;
IsSpecial = true;
Oh, and remove the;
CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );
It's not needed, will automatically go off when that vehicle is damaged.
-
It won't work, Tamas cocked up something :P.
Needs to be;
IsSpecial <- true;
Instead of;
IsSpecial = true;
Oh, and remove the;
CallFunc( "Scripts/Main/specials.nut", "onVehicleHealthChange", vehspc );
It's not needed, will automatically go off when that vehicle is damaged.
Still not worling.
-
If you want to answer, please make a exemple, like Tamas did.
Att. ADFENO
Have a nice day.
-
You may have to try a bit harder, since those scripts are perfectly fine.