Command and Conquer: Renegade Official Forums - RDF feed
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
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; };
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 ?
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...
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
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...
a path beyond kinda supports that but it is bit different then what u wanted
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...
I'm seeing problems with this. Couldn't someone sell their vehicle before it is killed? Getting money and denying the other player points?
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.
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
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.
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.
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.
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.
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_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 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_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); declare and initialise sellingveh at the top of your .cpp file (I choose GMMAIN.cpp). bool sellingveh = false; I also added this code to the "else if (message == CUSTOM_EVENT_VEHICLE_ENTER) {" conditional in the "void MDB_SSGM_Vehicle_Owner::Custom(GameObject *obj, int message, int param, GameObject *sender) {" script. I moved this script over to GMMAIN.cpp long ago, but if you do not want to do that then you must remember to externalise the sellingveh boolean. if (IsLocked && Commands->Get_ID(Get_Vehicle_Occupant(obj,0)) == Commands->Get_ID(sender) && Commands->Get_ID(sender) == MyOwner(3)) { if(sellingveh){ Remove_Script(Get_GameObj(MyOwner(2)),"reb_sell_veh"); Console_Input(StrFormat("ppage %d Your vehicle sale has been halted because you re-entered your vehicle.",MyOwner(2)).c_str()); sellingveh = false; }
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...
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.
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 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 GDI Barracks",ID).c_str()); } } } }; ChatCommandRegistrant<sellvehChatCommand> sellvehChatCommandReg("!sellveh",CHATTYPE_ALL,0,GAMEMODE_AOW); This will now mean that it gets the vehicles value directly from the preset itself and halves it, unless the preset doesn't exist (i.e it's a temped preset you made yourself), then it will try to get the value from GetValue. 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; } } } } 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; }; Had to change MDB_SSGM_Vehicle_Owner a little bit... void MDB_SSGM_Vehicle_Owner::Custom(GameObject *obj, int message, int param, GameObject *sender) { if (message == 1111) { Commands->Destroy_Object(Commands->Find_Object(IconID)); Commands->Destroy_Object(Commands->Find_Object(IconID2)); Destroy_Script(); } else if (message == 1112) { IsLocked = true; if (Commands->Get_ID(Get_Vehicle_Occupant(obj,0)) != MyOwner(3)) Force_Occupant_Exit(obj,0); if (GetIconBone(obj,1)) { Commands->Destroy_Object(Commands->Find_Object(IconID)); GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object",GetIconBone(obj,1)); Commands->Set_Model(Icon,"p_keycrd_red"); Commands->Attach_To_Object_Bone(Icon,obj,GetIconBone(obj,1)); IconID = Commands->Get_ID(Icon); } if (GetIconBone(obj,2)) { Commands->Destroy_Object(Commands->Find_Object(IconID2)); GameObject *Icon2 = Commands->Create_Object_At_Bone(obj,"Invisible_Object",GetIconBone(obj,2)); Commands->Set_Model(Icon2,"p_keycrd_red"); Commands->Attach_To_Object_Bone(Icon2,obj,GetIconBone(obj,2)); IconID2 = Commands->Get_ID(Icon2); } } else if (message == 1113) { IsLocked = false; if (GetIconBone(obj,1)) { Commands->Destroy_Object(Commands->Find_Object(IconID)); GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object",GetIconBone(obj,1)); Commands->Set_Model(Icon,"o_em_apc"); Commands->Attach_To_Object_Bone(Icon,obj,GetIconBone(obj,1)); IconID = Commands->Get_ID(Icon); } if (GetIconBone(obj,2)) { Commands->Destroy_Object(Commands->Find_Object(IconID2)); GameObject *Icon2 = Commands->Create_Object_At_Bone(obj,"Invisible_Object",GetIconBone(obj,2)); Commands->Set_Model(Icon2,"o_em_apc"); Commands->Attach_To_Object_Bone(Icon2,obj,GetIconBone(obj,2)); IconID2 = Commands->Get_ID(Icon2); } } else if (message == CUSTOM_EVENT_VEHICLE_ENTER) { if (Commands->Get_Player_Type(sender) != Team) { Console_Input(StrFormat("ppage %d The enemy has stolen your vehicle!",MyOwner(2)).c_str()); Commands->Destroy_Object(Commands->Find_Object(IconID)); Commands->Destroy_Object(Commands->Find_Object(IconID2)); Destroy_Script(); } else if (IsLocked && Commands->Get_ID(Get_Vehicle_Occupant(obj,0)) == Commands->Get_ID(sender) && Commands->Get_ID(sender) != MyOwner(3)) { Commands->Control_Enable(sender,false); Commands->Start_Timer(obj,this,0.5f,3); Console_Input(StrFormat("pamsg %d The vehicle you entered is locked and belongs to %ls.",Get_Player_ID(sender),Get_Wide_Player_Name_By_ID(MyOwner(2))).c_str()); } else if (Commands->Get_ID(Get_Vehicle_Occupant(obj,0)) == Commands->Get_ID(sender) && Commands->Get_ID(sender) != MyOwner(3)) { Console_Input(StrFormat("ppage %d Warning! %ls has entered your bound vehicle. If you wish to remove them type !vkick in teamchat.",MyOwner(2),Get_Wide_Player_Name(sender)).c_str()); } if (IsLocked && Commands->Get_ID(Get_Vehicle_Occupant(obj,0)) == Commands->Get_ID(sender) && Commands->Get_ID(sender) == MyOwner(3)) { if(sellingveh){ Remove_Script(Get_GameObj(MyOwner(2)),"reb_sell_veh"); Console_Input(StrFormat("ppage %d Your vehicle sale has been halted because you re-entered your vehicle.",MyOwner(2)).c_str()); sellingveh = false; } } } } float GetValue(const char* Preset) { float VehValue = 0; if (stricmp(Preset,"test") == 0) VehValue = 1; else if (stricmp(Preset,"GDI Harvester MP2") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Harverster MP") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Titan") == 0) VehValue = 700; else if (stricmp(Preset,"GDI Wolverine") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Orca") == 0) VehValue = 500; else if (stricmp(Preset,"GDI Orca Bomber") == 0) VehValue = 500; else if (stricmp(Preset,"NOD Harverster MP") == 0) VehValue = 300; else if (stricmp(Preset,"Nod TickTank TS") == 0) VehValue = 550; else if (stricmp(Preset,"Nod TickTank") == 0) VehValue = 525; else if (stricmp(Preset,"Nod Buggy") == 0) VehValue = 200; else if (stricmp(Preset,"GDI Titan TS") == 0) VehValue = 600; else if (stricmp(Preset,"Nod TickTank TS") == 0) VehValue = 550; else if (stricmp(Preset,"Nod Buggy TS") == 0) VehValue = 250; return VehValue; } You will need to change this to your renegade temped presets (if you have any, if not you should change the reb_sell_veh script and nt even bother with this at all. float GetValue(const char* Preset) { float VehValue = 0; if (stricmp(Preset,"test") == 0) VehValue = 1; else if (stricmp(Preset,"GDI Harvester MP2") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Harverster MP") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Titan") == 0) VehValue = 700; else if (stricmp(Preset,"GDI Wolverine") == 0) VehValue = 300; else if (stricmp(Preset,"GDI Orca") == 0) VehValue = 500; else if (stricmp(Preset,"GDI Orca Bomber") == 0) VehValue = 500; else if (stricmp(Preset,"NOD Harverster MP") == 0) VehValue = 300; else if (stricmp(Preset,"Nod TickTank TS") == 0) VehValue = 550; else if (stricmp(Preset,"Nod TickTank") == 0) VehValue = 525; else if (stricmp(Preset,"Nod Buggy") == 0) VehValue = 200; else if (stricmp(Preset,"GDI Titan TS") == 0) VehValue = 600; else if (stricmp(Preset,"Nod TickTank TS") == 0) VehValue = 550; else if (stricmp(Preset,"Nod Buggy TS") == 0) VehValue = 250; return VehValue; } Also, you need to include this as a global variable bool sellingveh = false;
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 have 'this' pointers .\gmscripts.cpp(1487) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1489) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1490) : error C2228: left of '.c_str' must have class/struct/union .\gmscripts.cpp(1490) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1492) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1493) : error C2065: 'sellingveh' : undeclared identifier .\gmscripts.cpp(1494) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1495) : error C2228: left of '.c_str' must have class/struct/union .\gmscripts.cpp(1495) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1503) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1504) : error C2228: left of '.c_str' must have class/struct/union .\gmscripts.cpp(1504) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1507) : error C3861: 'Destroy_Script': identifier not found .\gmscripts.cpp(1510) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1515) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1520) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1525) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1526) : error C3861: 'MyOwner': identifier not found .\gmscripts.cpp(1531) : error C2653: 'MDB_SSGM_Vehicle_Owner' : is not a class or namespace name .\gmscripts.cpp(1531) : error C2365: 'MyOwner' : redefinition; previous definition was 'formerly unknown identifier' .\gmscripts.cpp(1533) : error C3861: 'Get_Int_Parameter': identifier not found .\gmscripts.cpp(1536) : error C3861: 'Get_Int_Parameter': identifier not found .\gmscripts.cpp(2158) : error C2065: 'MDB_SSGM_Vehicle_Owner' : undeclared identifier .\gmscripts.cpp(2158) : error C2514: 'ScriptRegistrant' : class has no constructors c:\westwood\renegadefds\server\scripts.h(480) : see declaration of 'ScriptRegistrant' gmmain.cpp gmkeyhook.cpp gmgamelog.cpp gmfunc.cpp gmctf.cpp gmcrate.cpp gmcommandclass.cpp engine_gm.cpp Generating Code... Creating browse information file... Microsoft Browse Information Maintenance Utility Version 8.00.50727 Copyright (C) Microsoft Corporation. All rights reserved. Build log was saved at "file://c:\Westwood\RenegadeFDS\Server\tmp\scripts\debug\BuildLog.htm" SSGM - 48 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
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 :-/
Umm, i did modify it. I modifyed the one that is in the gmscrips.cpp
Send me your entire solution and I'll fix it for you. But please take the advice and start smaller.
I'm getting problems with it, as i said in the other topic.
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 :-/
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."
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.
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
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.
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.
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
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
Reborn which version of !sllveh is best for renegade
The last one, especially if you use temped vehicle presets.
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.
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); } } }
I would use Get_Cost(Commands->Get_Preset_Name(obj))/2 rarther than having to do it for each vehicle
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.
Was replying to wittebolx, didn't see your post