Home » Renegade Discussions » Mod Release Forum » [script]!sellveh
() 3 Votes
[script]!sellveh [message #327514] |
Wed, 23 April 2008 16:13 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma:
|
General (3 Stars) |
|
|
I have been writing some code for when the new patch of cnc_reborn comes out with vehicles. I wanted to ability to enable or disable the selling of vehicles in my server. I havn't tested it out very much, other then a couple of attempts. I thought the renegade community might like it and if someone does use it then they could also report back any issues/problems ahead of the reborn release so I might be able to resolve them before the patch release.
The code is based on SSGM, you will need to adapt it for renegade slightly, but I have made it clear in the comments where...
I will restate that I havn't tested it too much, there will most likely be issues, I am aware that after being ejected you can get back in, I will write code at some point to make sure that halts the sale of the vehicle, unless someone submits it...
Include this function somewhere, I chose GMMAIN.cpp
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,"GDI_AAPC") == 0) VehValue = 3;
else if (stricmp(Preset,"GDI_Disruptor") == 0) VehValue = 100;
return VehValue;
}
Here's the chat hook:
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 == 2){
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);
Here's the script that does the selling:
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);
}
}
}
ScriptRegistrant<reb_sell_veh> reb_sell_veh_Registrant("reb_sell_veh","");
class reb_sell_veh : public ScriptImpClass {
void Created(GameObject *obj);
void Timer_Expired(GameObject *obj, int number);
void Killed(GameObject *obj, GameObject *shooter);
int VehID;
};
[Updated on: Fri, 30 January 2009 14:31] by Moderator Report message to a moderator
|
|
|
|
|
[script]!sellveh
By: reborn on Wed, 23 April 2008 16:13
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Wed, 23 April 2008 16:22
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: BlueThen on Wed, 23 April 2008 16:30
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Wed, 23 April 2008 16:34
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: KobraOps on Wed, 23 April 2008 16:52
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Wed, 23 April 2008 23:09
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Thu, 24 April 2008 04:41
|
|
|
Re: !sellveh
By: reborn on Thu, 24 April 2008 08:56
|
|
|
Re: !sellveh
By: reborn on Thu, 12 June 2008 03:09
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Thu, 12 June 2008 08:04
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Thu, 12 June 2008 08:55
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Thu, 12 June 2008 09:36
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Thu, 12 June 2008 10:32
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Fri, 13 June 2008 03:18
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: reborn on Fri, 13 June 2008 12:35
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
|
|
|
Re: !sellveh
By: Hex on Sun, 20 July 2008 06:21
|
|
|
Re: !sellveh
By: reborn on Mon, 21 July 2008 08:22
|
|
|
Re: !sellveh
By: Hex on Mon, 21 July 2008 08:49
|
Goto Forum:
Current Time: Fri Nov 22 16:29:39 MST 2024
Total time taken to generate the page: 0.01254 seconds
|