Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [script]!sellveh  () 3 Votes
Re: !sellveh [message #341985 is a reply to message #341643] Sun, 20 July 2008 05:29 Go to previous messageGo to previous message
wittebolx is currently offline  wittebolx
Messages: 332
Registered: May 2007
Location: the netherlands
Karma:
Recruit
Clown wrote on Sat, 19 July 2008 02:25

I know this is a little old, but I noticed the team number is wrong in the first portion of the code, line 6.
class sellvehChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *MyVeh = Find_My_Veh(Get_GameObj(ID));
		GameObject *Own = Get_GameObj(ID);
		int Type = Commands->Get_Player_Type(Own);
		if (Type == 2){

It should be (Type == 0) instead of (Type == 2)


Another thing, when you type !sellveh it says it will be sold for $0.000000 but after the 15 seconds it gets sold for the correct price.
I haven't figured out how to fix this.


float GetValue(const char* Preset) {
	float VehValue = 0;
// These preset names need to be changed to renegade vehicle preset names, you also need to make the cost whatever you feel is the right amount to get for the sale of the vehicle
if (stricmp(Preset,"CnC_Nod_APC") == 0) VehValue = 250;
else if (stricmp(Preset,"CnC_GDI_APC") == 0) VehValue = 250;
else if (strstr(Preset,"CnC_GDI_Humm-vee") == 0) VehValue = 175;
else if (strstr(Preset,"CnC_GDI_MRLS") == 0) VehValue = 225;
else if (strstr(Preset,"CnC_Civilian_Pickup01_Secret") == 0) VehValue = 50;
else if (strstr(Preset,"CnC_Civilian_Sedan01_Secret") == 0) VehValue = 50;
else if (strstr(Preset,"CnC_Nod_Buggy") == 0) VehValue = 150;
else if (strstr(Preset,"CnC_Nod_Mobile Artillery") == 0) VehValue = 225;
else if (strstr(Preset,"Nod_Chameleon") == 0) VehValue = 100;
else if (strstr(Preset,"CnC_Nod_Recon_Bike") == 0) VehValue = 150;
else if (strstr(Preset,"CnC_Nod_Transport") == 0) VehValue = 400;
else if (strstr(Preset,"CnC_GDI_Transport") == 0) VehValue = 400;
else if (strstr(Preset,"CnC_GDI_Medium_Tank") == 0) VehValue = 400;
else if (strstr(Preset,"CnC_GDI_Mammoth_Tank") == 0) VehValue = 600;
else if (strstr(Preset,"CnC_Nod_Light_Tank") == 0) VehValue = 300;
else if (strstr(Preset,"CnC_Nod_Flame_Tank") == 0) VehValue = 400;
else if (strstr(Preset,"CnC_Nod_Stealth_Tank") == 0) VehValue = 450;
else if (strstr(Preset,"CnC_Nod_Apache") == 0) VehValue = 450;
else if (strstr(Preset,"CnC_GDI_Orca") == 0) VehValue = 450;
else if (strstr(Preset,"CnC_GDI_Harvester") == 0) VehValue = 500;
else if (strstr(Preset,"CnC_Nod_Harvester") == 0) VehValue = 500;

	return VehValue;
}

class sellvehChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *MyVeh = Find_My_Veh(Get_GameObj(ID));
		GameObject *Own = Get_GameObj(ID);
		float Value = GetValue(Commands->Get_Preset_Name(MyVeh));
		int Type = Commands->Get_Player_Type(Own);
		if (Type == 0){
float Dist = Commands->Get_Distance(Commands->Get_Position(Own),Commands->Get_Position(Find_War_Factory(0)));
		if (!MyVeh) {
			Console_Input(StrFormat("ppage %d You must have a vehicle bound to you to use this command. Type !bind in teamchat to bind the vehicle you are currently in.",ID).c_str());
		}
		if (MyVeh && Value > 0 && Dist <= 20.0f) {
			Force_Occupants_Exit(MyVeh);
            Commands->Send_Custom_Event(Own,MyVeh,1112,0,0);
			Commands->Attach_Script(Own,"reb_sell_veh","");
			Console_Input(StrFormat("ppage %d Your vehicle will be sold in 15 seconds for $%f, unless it is stolen/destroyed.",ID,GetValue(Commands->Get_Preset_Name(MyVeh))).c_str());
		}
		if (MyVeh && Value == 0) {
			Console_Input(StrFormat("ppage %d This vehicle is not supported by this command, please report this bug.",ID).c_str());
		}
				if (Dist > 20.0f) {
			Console_Input(StrFormat("ppage %d To use this command you must be in close proximity to the Nod WarFactory",ID).c_str());
		}
		}
		else{
float Dist = Commands->Get_Distance(Commands->Get_Position(Own),Commands->Get_Position(Find_War_Factory(1)));
		if (!MyVeh) {
			Console_Input(StrFormat("ppage %d You must have a vehicle bound to you to use this command. Type !bind in teamchat to bind the vehicle you are currently in.",ID).c_str());
		}
		if (MyVeh && Value > 0 && Dist <= 20.0f) {
			Force_Occupants_Exit(MyVeh);
            Commands->Send_Custom_Event(Own,MyVeh,1112,0,0);
			Commands->Attach_Script(Own,"reb_sell_veh","");
			Console_Input(StrFormat("ppage %d Your vehicle will be sold in 15 seconds for $%f, unless it is stolen/destroyed.",ID,GetValue(Commands->Get_Preset_Name(MyVeh))).c_str());
		}
		if (MyVeh && Value == 0) {
			Console_Input(StrFormat("ppage %d This vehicle is not supported by this command, please report this bug.",ID).c_str());
		}
				if (Dist > 20.0f) {
			Console_Input(StrFormat("ppage %d To use this command you must be in close proximity to the GDI WarFactory",ID).c_str());
		}
		}
	}
};
ChatCommandRegistrant<sellvehChatCommand> sellvehChatCommandReg("!sellveh",CHATTYPE_ALL,0,GAMEMODE_AOW);

void reb_sell_veh::Created(GameObject *obj) {
GameObject *MyVeh = Find_My_Veh(obj);
VehID = Commands->Get_ID(MyVeh);


Commands->Start_Timer(obj, this, 15.0f, 1);
}

void reb_sell_veh::Killed(GameObject *obj, GameObject *shooter){
Console_Input(StrFormat("ppage %d Your vehicle sale has been halted",Get_Player_ID(obj)).c_str());
}

void reb_sell_veh::Timer_Expired(GameObject *obj, int number){
if(number == 1){
	if(Commands->Find_Object(VehID)){
Commands->Destroy_Object(Find_My_Veh(obj));
Commands->Give_Money(obj,GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))), 0);
	}
}
}



 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [script]Parachute function
Next Topic: BloodMod
Goto Forum:
  


Current Time: Fri Aug 02 05:32:38 MST 2024

Total time taken to generate the page: 0.01302 seconds