| Vetach plugin [message #438008] | 
			Sat, 16 October 2010 11:29   | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		Well I Have made a vtach detach plugin for servers  
 
it has 2 chatcommand keys 
 
VTVTACH 
VTDETACH 
 
download link: 
 
http://www.megaupload.com/?d=PFEC7X38 
 
 
it attaches a vehicle to your apache/orca with !vtach 
and it detaches it again with !detach 
you can block it with !metach and deblock it with !metach 
 
ps:  
its a bit buggy when picking up vehicles after dead and stuff am willing to give code because i cant find the problem myself  
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		[Updated on: Sun, 17 October 2010 02:32] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	| 
		
 | 
	
		
		
			| Re: Vetach plugin [message #438039 is a reply to message #438008] | 
			Sun, 17 October 2010 02:36    | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		ok these are the scripts 
 
Toggle Spoiler
/*	Renegade Scripts.dll
	Vetach Plugin Code
	Copyright 2010 Robby Driesen
	This file is part of the Renegade scripts.dll
	The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
	the terms of the GNU General Public License as published by the Free
	Software Foundation; either version 2, or (at your option) any later
	version. See the file COPYING for more details.
	In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
	Only the source code to the module(s) containing the licenced code has to be released.
*/
#include "includes.h"
void VT_CarryAll::Created(GameObject *obj)
{	
		GameObject *driver = Get_Vehicle_Occupant(obj, 0);
		int team = Get_Object_Type(driver);
		int pID = Get_Player_ID(driver);
		Vector3 CurPosition = Commands->Get_Position(obj);
		bool test=false;
		GenericSLNode *x = BaseGameObjList->HeadNode;
		while (x)
		{
			GameObject *o = (GameObject *)x->NodeData;
			if (o && Is_Vehicle(o) && o!=obj)
			{
				Vector3 CurPositiono = Commands->Get_Position(o);
				float Dist = Commands->Get_Distance(CurPosition, CurPositiono);
							
				GameObject *driver2 = Get_Vehicle_Occupant(o, 0);
				if(Dist <= 6.0f)
				{
					if(Is_VTOLVehicle(o)||Is_Script_Attached(o,"VT_CARRYALL_ATTACHED"))
					{
						Remove_Script(obj,"VT_CarryAll");
						return;
					}
					else
					{
						if(driver2)
						{
							if(Get_Object_Type(driver2) == team && (Is_Script_Attached(driver2,"VT_Carrytest")==false))
							{
								//do some shit
								Commands->Attach_To_Object_Bone(o, obj, "v_fuselage3");
								Commands->Disable_Physical_Collisions(o);
								Console_Input(StrFormat("CMSGP %d 208,104,0 You have attached a friendly vehicle",pID).c_str());
								test = true;
								return;
							
							}
							else{Remove_Script(obj,"VT_CarryAll");return;}
						}
						if (Is_Script_Attached(o,"VT_CARRYALL_ATTACHED" )== false)
						{
							//do some shit																																
							Commands->Attach_To_Object_Bone(o, obj, "v_fuselage3");
							Commands->Disable_Physical_Collisions(o);
							Console_Input(StrFormat("CMSGP %d 208,104,0 You have attached a neutral vehicle",pID).c_str());
							test = true;
							return;
						}
					}
				}
			}
			x = x->NodeNext;
		}
		if(test == false)
		{
			Remove_Script(obj,"VT_CarryAll");
		}
};
ScriptRegistrant<VT_CarryAll> VT_CarryAll_Reg("VT_CarryAll","");
void VT_Detach::Created(GameObject *obj)
{	
	int pID = Get_Player_ID(obj);
	Vector3 CurPosition = Commands->Get_Position(obj);
		GenericSLNode *x = BaseGameObjList->HeadNode;
		while (x)
		{
				
			GameObject *o = (GameObject *)x->NodeData;
			if (o &&  o!=obj && Is_Vehicle(o))
			{
					
				Console_Input("CMSGP %d 208,104,0 Found someone");
				Vector3 CurPositiono = Commands->Get_Position(o);
				float Dist = Commands->Get_Distance(CurPosition, CurPositiono);
					
				if(Dist <= 1.0f)
				{
					// lets make an obj below our attached veh
					Vector3 posdetobj = CurPositiono;
					posdetobj.Z -= 3.25f;
					GameObject *detobj = Commands->Create_Object("Invisible_Object",posdetobj);
					Commands->Attach_To_Object_Bone(o, o, "v_fuselage3");
					Commands->Set_Position(o,posdetobj);
					Commands->Attach_To_Object_Bone(o, detobj, "v_fuselage3"); //attach to the thing below our veh
					Commands->Destroy_Object(detobj); // destroy our thing there is no need for it
					Commands->Enable_Collisions(o); // ok you cant run trough me
					Remove_Script(obj,"VT_CarryAll");
					Console_Input(StrFormat("CMSGP %d 208,104,0 You have just detached a veh",pID).c_str());
					return;
				}
				else
				{
					Remove_Script(obj,"VT_CarryAll");
				}
			}
			x = x->NodeNext;
		}
		Remove_Script(obj,"VT_Detach");
	
}
ScriptRegistrant<VT_Detach> VT_Detach_Reg("VT_Detach","");
void VT_Carrytest :: Created(GameObject *obj)
{
// just to make an decision
};
ScriptRegistrant<VT_Carrytest> VT_Carrytest_Reg("VT_Carrytest","");
void VT_CARRYALL_ATTACHED :: Created(GameObject *obj)
{
// just to make an decision
};
ScriptRegistrant<VT_CARRYALL_ATTACHED> VT_CARRYALL_ATTACHED_Reg("VT_CARRYALL_ATTACHED","");
 
   
 
some bugs i remember: 
 
if you just bought a vehicle and you vtach it without anyone in it it says it attaches a neutral vehicle but the veh doesnt attach 
 
if you bought a vehicle to attach and die sometimes you cant pick it up although he says you do 
 
ps: in plugin harvester pickup is secured
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		[Updated on: Wed, 20 October 2010 07:06] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	
		
		
			| Re: Vetach plugin [message #438052 is a reply to message #438051] | 
			Sun, 17 October 2010 09:24    | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		| trooprm02 wrote on Sun, 17 October 2010 18:21 |  
 | trooprm02 wrote on Sat, 16 October 2010 14:55 |   Please explain what it does or maybe provide a screenshot?
  |  
  
  |  
  
ever tried to reread a first post after it was editted
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	
		
		
			| Re: Vetach plugin [message #438073 is a reply to message #438008] | 
			Mon, 18 October 2010 04:36    | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		yea i releases bcause i hope maybe someone can help me with the bugs  .
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	
		
		
			| Re: Vetach plugin [message #438082 is a reply to message #438078] | 
			Mon, 18 October 2010 07:51    | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		| danpaul88 wrote on Mon, 18 October 2010 15:42 |   Hmm, your script seems to disable itself if there is a VTOL on the map which is not the one you are driving and is older than any vehicles within 12m of your VT_CarryAll vehicle... (note: BaseGameObjList is NOT in order of distance from the current object, but in order of when they were created) 
 
 
Specifically this bit; 
 
if(Is_VTOLVehicle(o)||Is_Script_Attached(o,"VT_CARRYALL_ATTACHED"))
				{
					Remove_Script(obj,"VT_CarryAll");
					return;
				}
 
 
 
From what I can see you iterate through EVERY object in the game, so if it hits this one BEFORE it hit's the one which can be attached (ie: within 12m of you) it's going to cancel itself.
  |  
  
 
 
its supposed to disable itself when it finds a vtol nearby its so you cant attach vtols ^^ 
the bugs are mainly in the part where it has to identify a driver or neutral vehicle
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Vetach plugin [message #438111 is a reply to message #438008] | 
			Tue, 19 October 2010 03:09    | 
		 
		
			
				
				
				  | 
					
						  
						danpaul88
						 Messages: 5795 Registered: June 2004  Location: England
						
	Karma: 0
 
					 | 
					General (5 Stars)  | 
					 | 
		 
		 
	 | 
 
	
		That check I quoted doesn't check the distance though, so it would appear to disable itself if there is a VTOL anywhere on the map, not just close to you. Perhaps I am just reading it wrong but it seems that way to me. 
 
Might also be an idea to make sure the item to be picked up is actually below you as well, would be funny to see an orca park alongside a medium tank then lol-warp it underneath into bluehell    Sensible check might be; 
 
Their X >= Your X-2.5 and <= Your X+2.5 
Their Y >= Your Y-2.5 and <= Your Y+2.5 
Their Z < Your Z 
 
This forces you to hover almost directly above the unit to be picked up. Also a pickup range of 12 seems quite high to me, I would have thought about 8 would be more realistic.
		
		
 
  
		[Updated on: Tue, 19 October 2010 03:17] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 | 
	
		
		
			| Re: Vetach plugin [message #438118 is a reply to message #438008] | 
			Tue, 19 October 2010 08:51    | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		OK ^^ thanks alot guys that fixes a bug indeed. 
and about x y z ill try to add it but i think it will make it alot harder to attach a veh. it should stay pretty easy. 
ill take a look into it thanks for the hint. 
    
 
ive updated the source check previous post its editted. 
 
only bug ive found is sometimes empty vehicles dont get picked up dont know if it happens wit manned vehicles to cant test that decently
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		[Updated on: Tue, 19 October 2010 12:06] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Vetach plugin [message #438127 is a reply to message #438008] | 
			Wed, 20 October 2010 03:01    | 
		 
		
			
				
				
				  | 
					
						  
						danpaul88
						 Messages: 5795 Registered: June 2004  Location: England
						
	Karma: 0
 
					 | 
					General (5 Stars)  | 
					 | 
		 
		 
	 | 
 
	
		From your latest code, just spotted this; 
 
else{return;Remove_Script(obj,"VT_CarryAll");} 
 
 
The Remove_Script will never be called because it will return first. You should swap the order of these calls around if you want the script to get removed properly. I am a bit surprised the compiler didn't warn you about unreachable code actually... 
 
 
 
 
EDIT; 
Also, this check 
 
if (o && As_ScriptableGameObj(o) && Is_Vehicle(o) && o!=obj)  
 
Has a redundant part, a VehicleGameObj is *always* scriptable, so there's no need to test for As_ScriptableGameObj(o). You can safely remove this check to leave you with; 
 
if (o && Is_Vehicle(o) && o!=obj)  
		
		
 
  
		[Updated on: Wed, 20 October 2010 03:03] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 | 
	
		
		
			| Re: Vetach plugin [message #438133 is a reply to message #438008] | 
			Wed, 20 October 2010 08:43   | 
		 
		
			
				
				
				
					
						  
						robbyke
						 Messages: 348 Registered: September 2010  Location: Belgium
						
	Karma: 0
 
					 | 
					Recruit  | 
					 | 
		 
		 
	 | 
 
	
		ok thnx dan only that doesnt changes bug of not being able to pickup empty vehicles it says it attaches a neutral vehicle but the vehicle isnt attached    
		
		
  Owner of kambot TT server 
 
kambot.freeforums.org
		
 |  
	| 
		
	 | 
 
 
 |