Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Stealth command help
Stealth command help [message #407893] Wed, 21 October 2009 10:49 Go to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
Hey! How do i make so that people who joins the game after someone has bought a stealth suit for his char/veh still will see them stealthed?

Here is my command.
class StealthChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
	GameObject *obj = Get_GameObj(ID);
	float Credits = Commands->Get_Money(obj);

	if(Credits >= 1000){	
		Commands->Give_Money(obj,-1000,false);
			char message[256];
				sprintf(message,"msg %s bought a Stealthsuit", Get_Player_Name_By_ID(ID));
				Console_Input(message); 
					Commands->Enable_Stealth(obj,true);
		}
	else {
	Console_Input(StrFormat("ppage %d You need $1000.",Get_Player_ID(obj)).c_str());  
	}
}
};
ChatCommandRegistrant<StealthChatCommand> StealthChatCommandReg("!ss",CHATTYPE_ALL,0,GAMEMODE_AOW);

[Updated on: Thu, 22 October 2009 12:57]

Report message to a moderator

Re: Stealth command help [message #407898 is a reply to message #407893] Wed, 21 October 2009 11:09 Go to previous messageGo to next message
ErroR is currently offline  ErroR
Messages: 2984
Registered: March 2008
Location: Moldova
Karma: 0
General (2 Stars)
my guess is to reatach the script whenever anyone joins
Re: Stealth command help [message #407901 is a reply to message #407898] Wed, 21 October 2009 11:47 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
ErroR wrote on Wed, 21 October 2009 13:09

my guess is to reatach the script whenever anyone joins


Thanks for the reply. Could you tell me more how to reatach the script when a player join? I'm pretty new to this. Huh
Re: Stealth command help [message #407902 is a reply to message #407898] Wed, 21 October 2009 11:48 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
If you know, that "Enable_Stealth" command isnt the solid stealth event thats from renegade. Like thats made in the latest scripts and stuff. The current scripts are made by the community so there are several bugs. Like person running original or old scripts wont see the stealth effect and that join ect problem. I guess for a better version of the "Enable_Stealth" you would have to wait until scripts 4.0 since everyone needs that to play the future renegade.
Re: Stealth command help [message #407905 is a reply to message #407901] Wed, 21 October 2009 11:54 Go to previous messageGo to next message
ErroR is currently offline  ErroR
Messages: 2984
Registered: March 2008
Location: Moldova
Karma: 0
General (2 Stars)
Hubba wrote on Wed, 21 October 2009 21:47

ErroR wrote on Wed, 21 October 2009 13:09

my guess is to reatach the script whenever anyone joins


Thanks for the reply. Could you tell me more how to reatach the script when a player join? I'm pretty new to this. Huh

sorry, know nothing about coding/scripting
Re: Stealth command help [message #407908 is a reply to message #407902] Wed, 21 October 2009 12:31 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
YazooGang wrote on Wed, 21 October 2009 14:48

If you know, that "Enable_Stealth" command isnt the solid stealth event thats from renegade. Like thats made in the latest scripts and stuff. The current scripts are made by the community so there are several bugs. Like person running original or old scripts wont see the stealth effect and that join ect problem. I guess for a better version of the "Enable_Stealth" you would have to wait until scripts 4.0 since everyone needs that to play the future renegade.


Thanks for the reply Smile Yes I know that people with scripts lower than 2.9 will see them anyway. But let says the person who joins the game have scripts 2.9 or higher. How could i attach the script to him on join? I want to learn this because it could be usefull for other thing too Smile
ErroR wrote on Wed, 21 October 2009 13:54

sorry, know nothing about coding/scripting

Thanks anyway Smile
Re: Stealth command help [message #407923 is a reply to message #407893] Wed, 21 October 2009 14:52 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
well if you are using ssgm just find where the player joins and reattach the script to those players i don't know much about scripting, maybe someone else with more experience can explain better.

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Stealth command help [message #407939 is a reply to message #407923] Wed, 21 October 2009 18:26 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
Reattaching the script when player joins is a hard thing i would ignore that.
Here is what i got and hope it works!

I havent compiled or tested this so please tell me if somethings word ok?
Ok, so what this does is when you type in command !ss it takes your money and attaches you a "Hubba_Stealth" scripts. The script is a timer and what this does is activates a timer that is over in 0.01 and it enables Stealth event in your character and then it starts another timer that is over in 3 seconds. So, why is the first one 0.01(sec) and this one is 3(sec) because when you type in !ss you will have to wait 3 seconds to have a stealth event. So now when you type in !ss you will have it in less than a second. So, then when 3 seconds is over it will give you stealth effect again replace or whatever the original one and start another time. This will loop untill you die. So, when a person joins, your chars stealth will be enabled in every 3 seconds and that new person will see you as a stealth soldier. Good luck!



gmmain.CPP (replace the original command with this)

class StealthChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
	GameObject *obj = Get_GameObj(ID);
	float Credits = Commands->Get_Money(obj);

	if(Credits >= 1000){	
		Commands->Give_Money(obj,-1000,false);
			char message[256];
				sprintf(message,"msg %s bought a Stealthsuit", Get_Player_Name_By_ID(ID));
				Console_Input(message); 
					//Commands->Enable_Stealth(obj,true);
					Commands->Attach_Script(obj,"Hubba_Stealth","");
		}
	else {
	Console_Input(StrFormat("ppage %d You need $1000.",Get_Player_ID(obj)).c_str());  
	}
}
};
ChatCommandRegistrant<StealthChatCommand> StealthChatCommandReg("!ss",CHATTYPE_ALL,0,GAMEMODE_AOW);


gmmain.CPP - add this also

void Hubba_Stealth::Created(GameObject *obj)
{
Commands->Start_Timer(obj,this,0.01,1);
}	

void Hubba_Stealth::Timer_Expired(GameObject *obj,int number)
{
 	if (number == 1){
	Commands->Enable_Stealth(obj,true);

 Commands->Start_Timer(obj,this,3,1);
	}
}
ScriptRegistrant<Hubba_Stealth> Hubba_Stealth_Registrant("Hubba_Stealth","");


gmmain.H - add this also, its for the script Hubba_Stealth

class Hubba_Stealth : public ScriptImpClass {
void  Created(GameObject *obj);
void Timer_Expired(GameObject *obj,int number);
};



And last thing is to test it out. If it works have fun, no credits needed.

Re: Stealth command help [message #407948 is a reply to message #407939] Wed, 21 October 2009 20:41 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
YazooGang wrote on Wed, 21 October 2009 20:26

Reattaching the script when player joins is a hard thing i would ignore that.
Here is what i got and hope it works!

I havent compiled or tested this so please tell me if somethings word ok?
Ok, so what this does is when you type in command !ss it takes your money and attaches you a "Hubba_Stealth" scripts. The script is a timer and what this does is activates a timer that is over in 0.01 and it enables Stealth event in your character and then it starts another timer that is over in 3 seconds. So, why is the first one 0.01(sec) and this one is 3(sec) because when you type in !ss you will have to wait 3 seconds to have a stealth event. So now when you type in !ss you will have it in less than a second. So, then when 3 seconds is over it will give you stealth effect again replace or whatever the original one and start another time. This will loop untill you die. So, when a person joins, your chars stealth will be enabled in every 3 seconds and that new person will see you as a stealth soldier. Good luck!



gmmain.CPP (replace the original command with this)

class StealthChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
	GameObject *obj = Get_GameObj(ID);
	float Credits = Commands->Get_Money(obj);

	if(Credits >= 1000){	
		Commands->Give_Money(obj,-1000,false);
			char message[256];
				sprintf(message,"msg %s bought a Stealthsuit", Get_Player_Name_By_ID(ID));
				Console_Input(message); 
					//Commands->Enable_Stealth(obj,true);
					Commands->Attach_Script(obj,"Hubba_Stealth","");
		}
	else {
	Console_Input(StrFormat("ppage %d You need $1000.",Get_Player_ID(obj)).c_str());  
	}
}
};
ChatCommandRegistrant<StealthChatCommand> StealthChatCommandReg("!ss",CHATTYPE_ALL,0,GAMEMODE_AOW);


gmmain.CPP - add this also

void Hubba_Stealth::Created(GameObject *obj)
{
Commands->Start_Timer(obj,this,0.01,1);
}	

void Hubba_Stealth::Timer_Expired(GameObject *obj,int number)
{
 	if (number == 1){
	Commands->Enable_Stealth(obj,true);

 Commands->Start_Timer(obj,this,3,1);
	}
}
ScriptRegistrant<Hubba_Stealth> Hubba_Stealth_Registrant("Hubba_Stealth","");


gmmain.H - add this also, its for the script Hubba_Stealth

class Hubba_Stealth : public ScriptImpClass {
void  Created(GameObject *obj);
void Timer_Expired(GameObject *obj,int number);
};



And last thing is to test it out. If it works have fun, no credits needed.




Yep it works Smile. Thanks alot for helping me out and telling how the script work I will learn lots from this Smile

[Updated on: Wed, 21 October 2009 20:44]

Report message to a moderator

Re: Stealth command help [Solved] [message #407956 is a reply to message #407893] Thu, 22 October 2009 00:22 Go to previous messageGo to next message
cAmpa is currently offline  cAmpa
Messages: 597
Registered: March 2006
Karma: 0
Colonel
Wow, nice traffic abusing.

Bückstabü!
Re: Stealth command help [Solved] [message #407965 is a reply to message #407956] Thu, 22 October 2009 03:23 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
cAmpa wrote on Thu, 22 October 2009 02:22

Wow, nice traffic abusing.

If your saying something about my code then you must know that i'm not a proffecional coder.
Re: Stealth command help [Solved] [message #407971 is a reply to message #407893] Thu, 22 October 2009 06:12 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
If you decide to carry on use YazooGang's timer example, then I encourage you to take the actual timer itself down from 0.01f to say 0.5f. It's not really neccessary to have it loop like that every 0.01 seconds...

I would however like to encourage you to consider making a global array for the players...

bool IsPlayerStealth[128]; // global array


On the level_loaded event I would for loop through the array and set all the elements to false (just to make sure they are all false at the start of the map).


for (int i = 1; i < 128; i++){
IsPlayerStealth[i] = false;
}


You would need to set the players to true in this array when they become stealth, and false when they die. I would do something like this:


class StealthChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
	GameObject *obj = Get_GameObj(ID);
	float Credits = Commands->Get_Money(obj);

	if(Credits >= 1000){	
		Commands->Give_Money(obj,-1000,false);
			char message[256];
				sprintf(message,"msg %s bought a Stealthsuit", Get_Player_Name_By_ID(ID));
				Console_Input(message); 
					//Commands->Enable_Stealth(obj,true);
					Commands->Attach_Script(obj,"Hubba_Stealth","");
		}
	else {
	Console_Input(StrFormat("ppage %d You need $1000.",ID).c_str());  
	}
}
};
ChatCommandRegistrant<StealthChatCommand> StealthChatCommandReg("!ss;!StealthSuit;!SS;!stealthsuit",CHATTYPE_ALL,0,GAMEMODE_AOW);



void Hubba_Stealth::Created(GameObject *obj)
{
Commands->Enable_Stealth(obj,true);
IsStealthPlayer[Get_Player_ID(obj)] = true;
}	

void Hubba_Stealth::Killed(GameObject *obj,GameObject *shooter)
{
IsStealthPlayer[Get_Player_ID(obj)] = false;
}
ScriptRegistrant<Hubba_Stealth> Hubba_Stealth_Registrant("Hubba_Stealth","");


class Hubba_Stealth : public ScriptImpClass {
void  Created(GameObject *obj);
void Killed(GameObject *obj,GameObject *shooter);
};


Then on the player join event, you would do a similar loop to the level_loaded event, and just loop through the array, and if any of them are true, then apply the stealth tot hem again...

for (int i = 1; i < 128; i++){
if(IsPlayerStealth[i] == true){
Commands->Enable_Stealth(Get_GameObj(i),true);
}
}


Plus, this way you have a method of keeping track of who is currently stealthed, meaning you could add more functionaility.. You could add a command like !currentlystealthed, and it messages you who is stealthed...
Or you could add a conditional to your chat command, so if they are already stealthed, it pages them saying they are already stealthed.

I'm not fond of these sort of comamnds really if I am honest, but perhaps if you must do this, you could at least ensure the HON is alive, or they are at least a Nod player?



[Updated on: Thu, 22 October 2009 06:13]

Report message to a moderator

Re: Stealth command help [Solved] [message #407991 is a reply to message #407971] Thu, 22 October 2009 09:51 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3812
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
reborn wrote on Thu, 22 October 2009 07:12

If you decide to carry on use YazooGang's timer example, then I encourage you to take the actual timer itself down from 0.01f to say 0.5f. It's not really neccessary to have it loop like that every 0.01 seconds...


Timers don't time right anyways, and it won't loop at 0.01, it just doesn't get that fast, I'd assume someone put a cap on it somewhere.


Re: Stealth command help [Solved] [message #408003 is a reply to message #407991] Thu, 22 October 2009 11:49 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
To reborn, dude your code is way better than mine so dont waste time comparing mine to yours, just release yours.
Re: Stealth command help [Solved] [message #408005 is a reply to message #408003] Thu, 22 October 2009 12:33 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
YazooGang wrote on Thu, 22 October 2009 14:49

To reborn, dude your code is way better than mine so dont waste time comparing mine to yours, just release yours.



Do not put yourself down, you was willing to help and gave a solution that worked. Thumbs Up
Besides, my method isn't that much better really and truly, and I was doing it the same way you just suggested to Hubba not so long ago.



Re: Stealth command help [Solved] [message #408009 is a reply to message #407971] Thu, 22 October 2009 13:08 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
reborn wrote on Thu, 22 October 2009 14:12

(...)

Thanks reborn for your reply.
But your code doesn't seem to work? When another player joins they will see them un-stealthed.

There was also a small typo "IsStealthPlayer" should be "IsPlayerStealth".

I Hope we can find out why it doesn't work Smile I tried to look but I can't find anything wrong Huh
Re: Stealth command help [message #408010 is a reply to message #407893] Thu, 22 October 2009 13:19 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
You would need to post your code, what I posted should work.

You may have added the code in the wrong place or something :-/



Re: Stealth command help [message #408011 is a reply to message #408010] Thu, 22 October 2009 13:27 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
reborn wrote on Thu, 22 October 2009 15:19

You would need to post your code, what I posted should work.

You may have added the code in the wrong place or something :-/



I added the join code to "void Player_Join_Hook(int i,const char *Nick)"

Added the level_loaded code to "void Level_Loaded()"

"bool IsPlayerStealth[128]; // global array" is in global scope.

class Hubba_Stealth : public ScriptImpClass {
void  Created(GameObject *obj);
void Killed(GameObject *obj,GameObject *shooter);
};

added that to gmmain.h

And the rest should be fine. I'm pretty sure everyting else is right but is the join code in right place?

[Updated on: Thu, 22 October 2009 13:28]

Report message to a moderator

Re: Stealth command help [message #408012 is a reply to message #407893] Thu, 22 October 2009 13:38 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
And you changed the chat hook?

You should post the code really. To be honest, I was writing that at work from my head, it was more to give you the direction than anything else...



Re: Stealth command help [message #408013 is a reply to message #407893] Thu, 22 October 2009 13:42 Go to previous messageGo to next message
cAmpa is currently offline  cAmpa
Messages: 597
Registered: March 2006
Karma: 0
Colonel
You could also use Server Renegade Resurrection Software, it should fix this bug.




Bückstabü!
Re: Stealth command help [message #408016 is a reply to message #408012] Thu, 22 October 2009 13:44 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
reborn wrote on Thu, 22 October 2009 15:38

And you changed the chat hook?

You should post the code really. To be honest, I was writing that at work from my head, it was more to give you the direction than anything else...


Join_hook
void Player_Join_Hook(int i,const char *Nick) {
		
	for (int a = 1; a < 128; a++){
	if(IsPlayerStealth[a] == true){
	Commands->Enable_Stealth(Get_GameObj(a),true);
            }
}
	VetAddPlayer(i);			
	if (!Data->Plugins.empty()) {
		std::vector<PluginInfo*>::const_iterator it;
		for (it = Data->Plugins.begin();it != Data->Plugins.end(); ++it) {
			if ((*it)->Type == Plugin) {
				if ((*it)->PlayerJoinHookHandle) {
					(*it)->PlayerJoinHookHandle(i,Nick);	
				}
			}
		}
	}
	if (Settings->GameMode == 2) {
		CTF_Player_Join(i);
	}
}


Level_loaded
void Level_Loaded() {
	strncpy(Data->CurrMap,The_Game()->MapName,29);
	Settings->Load();

	Attach_Script_All_Buildings_Team(2,"MDB_SSGM_Building","",true);
	Attach_Script_All_Turrets_Team(2,"MDB_SSGM_Base_Defense","",true);

	for (int a = 1; a < 128; a++){
	IsPlayerStealth[a] = false;
	}
	if (Settings->EnableNewCrates) {
		Crate_Level_Loaded();
	}
	if (Settings->Gamelog) {
		Gamelog_Level_Loaded();
	}
	if (Settings->GameMode == 2) {
		CTF_Level_Loaded();
	}
	if (Settings->LogPlayerPurchase) {
		Data->PlayerPurchaseHookID = AddCharacterPurchaseMonHook(SSGM_Purchase_Hook,0);
	}
	if (Settings->LogPowerupPurchase) {
		Data->PowerupPurchaseHookID = AddPowerupPurchaseMonHook(SSGM_Purchase_Hook,0);
	}
	if (Settings->LogVehiclePurchase) {
		Data->VehiclePurchaseHookID = AddVehiclePurchaseMonHook(SSGM_Purchase_Hook,0);
	}

	if (!Data->Plugins.empty()) {
		std::vector<PluginInfo*>::const_iterator it;
		for (it = Data->Plugins.begin();it != Data->Plugins.end(); ++it) {
			if ((*it)->Type == Plugin) {
				if ((*it)->LevelLoadedHookHandle) {
					(*it)->LevelLoadedHookHandle();	
				}
			}
		}
	}
}


Gmmain.h
class Hubba_Stealth : public ScriptImpClass {
void  Created(GameObject *obj);
void Killed(GameObject *obj,GameObject *shooter);
};


The command:
class StealthChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
	GameObject *obj = Get_GameObj(ID);
	float Credits = Commands->Get_Money(obj);

	if(Credits >= 1000){	
		Commands->Give_Money(obj,-1000,false);
			char message[256];
				sprintf(message,"msg %s bought a Stealthsuit", Get_Player_Name_By_ID(ID));
				Console_Input(message); 
					//Commands->Enable_Stealth(obj,true);
					Commands->Attach_Script(obj,"Hubba_Stealth","");
		}
	else {
	Console_Input(StrFormat("ppage %d You need $1000.",ID).c_str());  
	}
}
};
ChatCommandRegistrant<StealthChatCommand> StealthChatCommandReg("!ss;!StealthSuit;!SS;!stealthsuit",CHATTYPE_ALL,0,GAMEMODE_AOW);



void Hubba_Stealth::Created(GameObject *obj)
{
Commands->Enable_Stealth(obj,true);
IsPlayerStealth[Get_Player_ID(obj)] = true;
}	

void Hubba_Stealth::Killed(GameObject *obj,GameObject *shooter)
{
IsPlayerStealth[Get_Player_ID(obj)] = false;
}
ScriptRegistrant<Hubba_Stealth> Hubba_Stealth_Registrant("Hubba_Stealth","");

[Updated on: Thu, 22 October 2009 20:48]

Report message to a moderator

Re: Stealth command help [message #408061 is a reply to message #407893] Fri, 23 October 2009 03:46 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
It looks like it should work, I don't know why it isn't.
If I have some time Sunday morning I will take a proper look.

You seem to grasp what I was saying though, you've added it to the correct places, perhaps you might like to try yourself, too?



Re: Stealth command help [message #408070 is a reply to message #407893] Fri, 23 October 2009 04:52 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Just to let everyone know, stealth has been improved in 4.0 to work better.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Stealth command help [message #408114 is a reply to message #408070] Fri, 23 October 2009 12:16 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
jonwil wrote on Fri, 23 October 2009 06:52

Just to let everyone know, stealth has been improved in 4.0 to work better.


Nice thanks!
Re: Stealth command help [message #408123 is a reply to message #407893] Fri, 23 October 2009 13:21 Go to previous messageGo to previous message
raven
Messages: 595
Registered: January 2007
Location: Toronto, Ontario
Karma: 0
Colonel
stealth mammys inc

-Jelly Administrator
-Exodus Administrator
Previous Topic: I need of a modified scripts.dll
Next Topic: Level Edit Problem
Goto Forum:
  


Current Time: Sun Dec 15 08:41:16 MST 2024

Total time taken to generate the page: 0.01568 seconds