Command and Conquer: Renegade Official Forums - RDF feed
type: channel
description: C&C: Renegade --> Dying since 2003™, resurrected in 2024!
items: [script]!sellveh
items: Re: !sellveh

[script]!sellveh
type: item
description: 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,111…
creator: reborn
date: 2008-04-23T23:13:44-00:00

Re: !sellveh
type: item
description: nice work i heard that u made it possible that u could make renegade have 3 teams or it is some one else was it u ?
creator: HeavyX101- Left
date: 2008-04-23T23:17:25-00:00

Re: !sellveh
type: item
description: HeavyX101 wrote on Wed, 23 April 2008 19:17 nice work i heard that u made it possible that u could make renegade have 3 teams or it is some one else was it u ? I didn't really make the renegade engine support three teams, it could always do that really. I just wrote a team re-balancing script that worked on the player join event and map load event. Plus wrote a spawn manager because the start-up spawners don't really work for any other team besides GDI and Nod. But yeah, the effect was three teams at the same time all playing together. The systems was not without flaws though, some assembly on the clients is required to display the endgame results properly and also make the clients on the third team not able to kill eachother. But it was all going well until I started focusing more time on cnc_reborn. I do intend to get back to it eventually...
creator: reborn
date: 2008-04-23T23:22:01-00:00

Re: !sellveh
type: item
description: kewl u sound like 1337 coder i have asked every one this question but no one answered me i have visual studio 2005 and i heard that it could modify renegade engine or the game.exe do u kno if i could change the codings of game.exe like make a new button in the menu and make functions for it (using vs 2005) lol dont worry i'm not going to ask u lots of stuff this is only the thing i need to ask
creator: HeavyX101- Left
date: 2008-04-23T23:26:47-00:00

Re: !sellveh
type: item
description: Can't you make a scrap building (a building where a player can sell him/herself/vehicle inside)? I mean, proffessional games aren't usually played via text...
creator: BlueThen
date: 2008-04-23T23:30:29-00:00

Re: !sellveh
type: item
description: a path beyond kinda supports that but it is bit different then what u wanted
creator: HeavyX101- Left
date: 2008-04-23T23:32:39-00:00

Re: !sellveh
type: item
description: Originally Blue wrote on Wed, 23 April 2008 19:30 Can't you make a scrap building (a building where a player can sell him/herself/vehicle inside)? I mean, proffessional games aren't usually played via text... This is just a concept really, cnc_reborn will probably have a service depot where this kind of thing can happen, I just liked the feature in DA and was curious if I could reproduce it. But for renegade it is a little too late to add a building such as this... I thought others might get some use from it really...
creator: reborn
date: 2008-04-23T23:34:05-00:00

Re: !sellveh
type: item
description: I'm seeing problems with this. Couldn't someone sell their vehicle before it is killed? Getting money and denying the other player points?
creator: Canadacdn
date: 2008-04-23T23:42:05-00:00

Re: !sellveh
type: item
description: I think it says u have to close to ur WF/AS that you must be out of your veh it takes 15 seconds if u did or its stolen it stops the sell. Seems fair.
creator: KobraOps
date: 2008-04-23T23:52:01-00:00

Re: !sellveh
type: item
description: Canadacdn wrote on Wed, 23 April 2008 18:42 I'm seeing problems with this. Couldn't someone sell their vehicle before it is killed? Getting money and denying the other player points? umm that is no big deal if the code contains this E.g Medium Tank 300 health 300 armor 800 credits cost if sell credits = 800/2=400$ Light tank damaged Medium tank medium tank - 300 armour = sell credits = 200$ sorry but that is how i could of explain
creator: HeavyX101- Left
date: 2008-04-24T00:03:32-00:00

Re: !sellveh
type: item
description: Canadacdn wrote on Wed, 23 April 2008 19:42 I'm seeing problems with this. Couldn't someone sell their vehicle before it is killed? Getting money and denying the other player points? Sorry, I should of explained it a little better... For a player to sue the command he has to be pretty close to his vehicle factory. He has to wait 15 seconds before the vehicle is destroyed and the money is granted to him. He cannot simply type it just before the enemy is about to blow him to kingdom come.
creator: reborn
date: 2008-04-24T06:09:45-00:00

Re: !sellveh
type: item
description: reborn wrote on Thu, 24 April 2008 07:09 Canadacdn wrote on Wed, 23 April 2008 19:42 I'm seeing problems with this. Couldn't someone sell their vehicle before it is killed? Getting money and denying the other player points? Sorry, I should of explained it a little better... For a player to sue the command he has to be pretty close to his vehicle factory. He has to wait 15 seconds before the vehicle is destroyed and the money is granted to him. He cannot simply type it just before the enemy is about to blow him to kingdom come. That and it'd need some serious fast typing skills to get the command out in time.
creator: CarrierII
date: 2008-04-24T09:44:04-00:00

Re: !sellveh
type: item
description: Nice code Reborn! I remember BC has (or had) the !sellveh command inside their scripts, is yours similar to that? At least I read something about this on their Wiki.
creator: EA-DamageEverything
date: 2008-04-24T11:25:21-00:00

Re: !sellveh
type: item
description: EA-DamageEverything wrote on Thu, 24 April 2008 07:25 Nice code Reborn! I remember BC has (or had) the !sellveh command inside their scripts, is yours similar to that? At least I read something about this on their Wiki. Yeah, I created this based on my experiance in the Black-cell server. In my opinion it's always been, and still is the best renegade server out there. I need to update this code at some point to make it halt the sale on the MDB_SSGM_Vehicle_Owner::Custom event, specifically on this conditional: else if (message == CUSTOM_EVENT_VEHICLE_ENTER) { so that it halts if the owner of the vehicle gets back in the vehicle. But other then that it works pretty much identically to DA (although DA doesn't restrict where you can sell it). I feel bad posting code here sometimes, black-cell has done loads for the renegade scene, and I seem to always plaguerise there features. And WD is normally the first person i go to if I have a problem that I don't understand. But I hope that the black-cell community see this more as a homage to DA's excellence ather then trying to be a stinky little butt-hole.
creator: reborn
date: 2008-04-24T11:41:59-00:00

Re: !sellveh
type: item
description: Updated to halt the sale if you re-enter, and a sale message... 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()); sellingveh = false; } void reb_sell_veh::Timer_Expired(GameObject *obj, int number){ if(number == 1){ if(Commands->Find_Object(VehID)){ float value = GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))); Console_Input(StrFormat("ppage %d Your vehicle was successfully sold for $%f.",Get_Player_ID(obj),value).c_str()); Commands->Give_Money(obj,GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))), 0); Commands->Destroy_Object(Find_My_Veh(obj)); sellingveh = false; } } } 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 you re-enter it or it is stolen/destroyed.",ID,GetValue(Commands->Get_Preset_Name(MyVeh))).c_str()); sellingveh = true; } if (MyVeh && Value == 0) { Console_Input(StrFormat("ppage %d This vehicle is not supported by this command, please report this bug.",ID).c_s…
creator: reborn
date: 2008-04-24T15:56:20-00:00

Re: !sellveh
type: item
description: Originally Blue wrote on Wed, 23 April 2008 18:30 Can't you make a scrap building (a building where a player can sell him/herself/vehicle inside)? I mean, proffessional games aren't usually played via text... Runs on my Test Server...
creator: mrãçķz
date: 2008-04-24T16:02:03-00:00

Re: !sellveh
type: item
description: I'm really really sorry that i'm posting on this old thread. But i'm having problems with this code. When i compile the project, i get these errors: Quote: .\sell.cpp(14) : error C2228: left of '.c_str' must have class/struct/union type is ''unknown-type'' .\sell.cpp(14) : error C3861: 'StrFormat': identifier not found .\sell.cpp(15) : error C2065: 'sellingveh' : undeclared identifier .\sell.cpp(21) : error C3861: 'GetValue': identifier not found .\sell.cpp(22) : error C2228: left of '.c_str' must have class/struct/union type is ''unknown-type'' .\sell.cpp(22) : error C3861: 'StrFormat': identifier not found .\sell.cpp(23) : error C3861: 'GetValue': identifier not found Can you guys please help me.
creator: HeavyX101- Left
date: 2008-06-12T05:13:24-00:00

Re: !sellveh
type: item
description: I've actually changed that quite a bit now anyway, for cnc_reborn there have been some map releases with temped vehicles so it makes sense to do it the way I did with GetValue, however for renegade you can get the cost directly from the preset itself. Actually this will still most likely work for renegade, and still allow you to adapt if you have temped vehicle presets in your server too. Here's my updated version. 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){ float Dist = Commands->Get_Distance(Commands->Get_Position(Own),Commands->Get_Position(Find_Soldier_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 && 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 you re-enter it or it is stolen/destroyed.",ID,GetValue(Commands->Get_Preset_Name(MyVeh))).c_str()); sellingveh = true; } if (Dist > 20.0f) { Console_Input(StrFormat("ppage %d To use this command you must be in close proximity to the Nod HON",ID).c_str()); } } else{ float Dist = Commands->Get_Distance(Commands->Get_Position(Own),Commands->Get_Position(Find_Soldier_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 && 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 wil…
creator: reborn
date: 2008-06-12T10:09:58-00:00

Re: !sellveh
type: item
description: Worst. Now i got even more errors. Quote: ------ Build started: Project: SSGM, Configuration: Debug Win32 ------ Compiling... sell.cpp .\sell.cpp(14) : error C2228: left of '.c_str' must have class/struct/union type is ''unknown-type'' .\sell.cpp(14) : error C3861: 'StrFormat': identifier not found .\sell.cpp(15) : error C2065: 'sellingveh' : undeclared identifier .\sell.cpp(24) : error C2228: left of '.c_str' must have class/struct/union type is ''unknown-type'' .\sell.cpp(24) : error C3861: 'StrFormat': identifier not found .\sell.cpp(25) : error C3861: 'GetValue': identifier not found .\sell.cpp(30) : error C3861: 'GetValue': identifier not found .\sell.cpp(31) : error C2228: left of '.c_str' must have class/struct/union type is ''unknown-type'' .\sell.cpp(31) : error C3861: 'StrFormat': identifier not found .\sell.cpp(32) : error C3861: 'GetValue': identifier not found dllmain.cpp gmsettingsclass.cpp gmscripts.cpp .\gmscripts.cpp(1413) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1414) : error C2065: 'IsLocked' : undeclared identifier .\gmscripts.cpp(1415) : error C2065: 'Team' : undeclared identifier .\gmscripts.cpp(1415) : error C3861: 'Get_Int_Parameter': identifier not found .\gmscripts.cpp(1420) : error C2065: 'IconID' : undeclared identifier .\gmscripts.cpp(1429) : error C2065: 'IconID2' : undeclared identifier .\gmscripts.cpp(1436) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1440) : error C3861: 'Destroy_Script': identifier not found .\gmscripts.cpp(1444) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1479) : error C2228: left of '.c_str' must have class/struct/union .\gmscripts.cpp(1479) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1482) : error C3861: 'Destroy_Script': identifier not found .\gmscripts.cpp(1484) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1486) : error C2673: 'Custom' : global functions do not …
creator: HeavyX101- Left
date: 2008-06-12T14:39:18-00:00

Re: !sellveh
type: item
description: I said I had to edit 'MDB_SSGM_Vehicle_Owner', not create it. You need to edit the existing one. I placed and migrated the the other existing scripts into gmmain.cpp to make it work. You might want to try something a bit easier at first and build your confidence up a bit :-/
creator: reborn
date: 2008-06-12T15:04:56-00:00

Re: !sellveh
type: item
description: Umm, i did modify it. I modifyed the one that is in the gmscrips.cpp
creator: HeavyX101- Left
date: 2008-06-12T15:47:30-00:00

Re: !sellveh
type: item
description: Send me your entire solution and I'll fix it for you. But please take the advice and start smaller.
creator: reborn
date: 2008-06-12T15:55:17-00:00

Re: !sellveh
type: item
description: I'm getting problems with it, as i said in the other topic.
creator: HeavyX101- Left
date: 2008-06-12T16:15:02-00:00

Re: !sellveh
type: item
description: HeavyX101 wrote on Thu, 12 June 2008 11:15 I'm getting problems with it, as i said in the other topic. Therefore you should.. reborn wrote on Thu, 12 June 2008 10:04 try something a bit easier at first and build your confidence up a bit :-/
creator: cnc95fan
date: 2008-06-12T16:19:12-00:00

Re: !sellveh
type: item
description: cnc95fan wrote on Thu, 12 June 2008 12:19 HeavyX101 wrote on Thu, 12 June 2008 11:15 I'm getting problems with it, as i said in the other topic. Therefore you should.. reborn wrote on Thu, 12 June 2008 10:04 try something a bit easier at first and build your confidence up a bit :-/ What does he mean "build you confidence up a bit."
creator: HeavyX101- Left
date: 2008-06-12T16:31:59-00:00

Re: !sellveh
type: item
description: It was a nice way of suggesting you might want to try something easier, something that might not cause you too much trouble figuring out. The offer stands, send it to me and I'll fix it for you, but I hope you perhaps try buying a book on C++ or something afterwards.
creator: reborn
date: 2008-06-12T16:36:44-00:00

Re: !sellveh
type: item
description: I fixed the errors i had today, but still cant compile your code. Here is the source. http://files.filefront.com/sourcezip/;10609477;/fileinfo.html
creator: HeavyX101- Left
date: 2008-06-12T17:28:09-00:00

Re: !sellveh
type: item
description: I don't have access to a compiler at work, but when I get home in around five-six hours time I will look over it and fix your mistakes.
creator: reborn
date: 2008-06-12T17:32:53-00:00

Re: !sellveh
type: item
description: Thanks mate. And can you tell me what files you edited and put "//Done by REBORN" near the stuff that u put or edited. That way i could understand what was the problem.
creator: HeavyX101- Left
date: 2008-06-12T17:50:49-00:00

Re: !sellveh
type: item
description: Link to source: http://www.game-maps.net/staff/reborn/ferkat.zip Edits and changes have been commented. I havn't been able to test it as I do not have a renegade server anymore, but I am pretty sure it will work
creator: reborn
date: 2008-06-13T10:18:29-00:00

Re: !sellveh
type: item
description: Works now Thank you very much. I'm going to go see how u did it so then i woulld know how to do it
creator: HeavyX101- Left
date: 2008-06-13T16:03:27-00:00

Re: !sellveh
type: item
description: Reborn which version of !sllveh is best for renegade
creator: Gen_Blacky
date: 2008-06-13T19:19:30-00:00

Re: !sellveh
type: item
description: The last one, especially if you use temped vehicle presets.
creator: reborn
date: 2008-06-13T19:35:15-00:00

Re: !sellveh
type: item
description: 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.
creator: a000clown
date: 2008-07-19T00:25:43-00:00

Re: !sellveh
type: item
description: 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; els…
creator: wittebolx
date: 2008-07-20T12:29:36-00:00

Re: !sellveh
type: item
description: I would use Get_Cost(Commands->Get_Preset_Name(obj))/2 rarther than having to do it for each vehicle
creator: Hex
date: 2008-07-20T13:21:31-00:00

Re: !sellveh
type: item
description: Hex wrote on Sun, 20 July 2008 09:21 I would use Get_Cost(Commands->Get_Preset_Name(obj))/2 rarther than having to do it for each vehicle I did update the code to do this and posted it earlier in the thread: void reb_sell_veh::Timer_Expired(GameObject *obj, int number){ if(number == 1){ if(Commands->Find_Object(VehID)){ unsigned int worth; worth = (Get_Cost((Commands->Get_Preset_Name(Commands->Find_Object(VehID))))/2); if (worth > 0){ Console_Input(StrFormat("ppage %d Your vehicle was successfully sold for $%i.",Get_Player_ID(obj),worth).c_str()); Commands->Give_Money(obj,GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))), 0); Commands->Destroy_Object(Find_My_Veh(obj)); sellingveh = false; } else { float value = GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))); Console_Input(StrFormat("ppage %d Your vehicle was successfully sold for $%f.",Get_Player_ID(obj),value).c_str()); Commands->Give_Money(obj,GetValue(Commands->Get_Preset_Name(Find_My_Veh(obj))), 0); Commands->Destroy_Object(Find_My_Veh(obj)); sellingveh = false; } } } } The only reason I don't rely on get_cost is because allot of the maps on my server use temped presets with varying costs, and that function will not work with them. But for renegade that else would most likely never get called.
creator: reborn
date: 2008-07-21T15:22:25-00:00

Re: !sellveh
type: item
description: Was replying to wittebolx, didn't see your post
creator: Hex
date: 2008-07-21T15:49:05-00:00