Home » Renegade Discussions » Mod Release Forum » [script]!sellveh
( ) 3 Votes
Re: !sellveh [message #334879 is a reply to message #327514] |
Thu, 12 June 2008 09:36   |
 |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
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.
|
|
|
|
|
Re: !sellveh [message #334889 is a reply to message #334886] |
Thu, 12 June 2008 10:50   |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
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.
This account is no longer being active.
[Updated on: Thu, 12 June 2008 10:56] Report message to a moderator
|
|
|
|
|
|
Re: !sellveh [message #335129 is a reply to message #327514] |
Fri, 13 June 2008 12:35   |
 |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
The last one, especially if you use temped vehicle presets.
|
|
|
Re: !sellveh [message #341643 is a reply to message #327514] |
Fri, 18 July 2008 17:25   |
a000clown
Messages: 364 Registered: May 2005 Location: Canada
Karma: 0
|
Commander |
|
|
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.
|
|
|
Re: !sellveh [message #341985 is a reply to message #341643] |
Sun, 20 July 2008 05:29   |
 |
wittebolx
Messages: 332 Registered: May 2007 Location: the netherlands
Karma: 0
|
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);
}
}
}
http://www.wittebolx.com
|
|
|
|
Re: !sellveh [message #342237 is a reply to message #341988] |
Mon, 21 July 2008 08:22   |
 |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
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.
|
|
|
|
Goto Forum:
Current Time: Mon Apr 28 01:29:40 MST 2025
Total time taken to generate the page: 0.01008 seconds
|