Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Stealth command help
Re: Stealth command help [message #408625 is a reply to message #407893] Wed, 28 October 2009 01:37 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)
I still think it would be better to do this on the players Created event, no need for the timers then... It's a bit better in my opinion.



bool firstspawn[128]; //global array
bool IsPlayerStealth[128]; // global array


void Player_Join_Hook(int i,const char *Nick) {
firstspawn[i] = true;
IsPlayerStealth[i] = false; 
// etc etc etc


Then in the object hook, where it attaches the SSGM player script, also attach Hubba_Player (or whatever)...


void Hubba_Player::Created(GameObject *obj){
if(firstspawn[Get_Player_ID(obj)] == true){
for (int i = 1; i < 128; i++){
if(IsPlayerStealth[i] == true && Get_GameObj(i)){
Commands->Enable_Stealth(Get_GameObj(i),true);
}
}
firstspawn[Get_Player_ID(obj)] = false;
}



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);
};






Also, who are you? It is not often that someone new comes to these forums who starts picking up the API.



[Updated on: Wed, 28 October 2009 01:39]

Report message to a moderator

Re: Stealth command help [message #408651 is a reply to message #408625] Wed, 28 October 2009 07:58 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
Hmm... I tried what you posted above. But it didn't work. So i putted a 2 secound delay on the script and then it worked. I dont see way how to fix this other than with timers? And it doesnt really matters if there is a dealy.

And who am I? I'm just a random player that thought it would be intresting to try to script Very Happy
Re: Stealth command help [message #408653 is a reply to message #407893] Wed, 28 October 2009 08: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)
Perhaps there is an issue with the actual stealth comamnd then. I haven't really looked at it.

The important thing with timers is that you should try to not have them looping all the time and keep re-attaching scripts. It's not ideal.

I'm glad you got it working though! We got there in the end buddy! Smile

Why don't you try making the command only work for Nod players, and only work if the Hand of Nod is not dead..?



Re: Stealth command help [message #408655 is a reply to message #408653] Wed, 28 October 2009 08:59 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
reborn wrote on Wed, 28 October 2009 09:19

Perhaps there is an issue with the actual stealth comamnd then. I haven't really looked at it.

The important thing with timers is that you should try to not have them looping all the time and keep re-attaching scripts. It's not ideal.

I'm glad you got it working though! We got there in the end buddy! Smile

Why don't you try making the command only work for Nod players, and only work if the Hand of Nod is not dead..?



There is only a few issues left Big Grin
When the charachter buys another char using PT or kill himself will make the IsplayerStealth still to be true. (if the player bought a stealth suit earlier in the game.)

Is there a way to see if the char has been changed?

[Updated on: Wed, 28 October 2009 09:01]

Report message to a moderator

Re: Stealth command help [message #408668 is a reply to message #407893] Wed, 28 October 2009 10:31 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)
Chage Hubba_Player to this:


void Hubba_Player::Created(GameObject *obj){
IsPlayerStealth[Get_Player_ID(obj)] = false; //This line ensures that when a player is spawned (including new purchases) the array is updated to not include them as a stealth player, which is why you was getting that glitch.
if(firstspawn[Get_Player_ID(obj)] == true){
for (int i = 1; i < 128; i++){
if(IsPlayerStealth[i] == true && Get_GameObj(i)){
Commands->Enable_Stealth(Get_GameObj(i),true);
}
}
firstspawn[Get_Player_ID(obj)] = false;
}


Please consider adding conditions for making sure the player is team Nod and they Hand Of Nod must be alive for the command to work. I am not keen on these commands really, I hope you at least consider this...

Now come on... Who are you?



Re: Stealth command help [message #408669 is a reply to message #408668] Wed, 28 October 2009 11:09 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
reborn wrote on Wed, 28 October 2009 11:31

Chage Hubba_Player to this:


void Hubba_Player::Created(GameObject *obj){
IsPlayerStealth[Get_Player_ID(obj)] = false; //This line ensures that when a player is spawned (including new purchases) the array is updated to not include them as a stealth player, which is why you was getting that glitch.
if(firstspawn[Get_Player_ID(obj)] == true){
for (int i = 1; i < 128; i++){
if(IsPlayerStealth[i] == true && Get_GameObj(i)){
Commands->Enable_Stealth(Get_GameObj(i),true);
}
}
firstspawn[Get_Player_ID(obj)] = false;
}


Please consider adding conditions for making sure the player is team Nod and they Hand Of Nod must be alive for the command to work. I am not keen on these commands really, I hope you at least consider this...

Now come on... Who are you?


I just want to say this that I really appreciate that you took time for helping me out. I have learned lots from you. Thanks reborn! Smile And Thanks to everyone else that tried to help Smile

And who i am? Sorry but what answer do you want on this lol? I'm just a renegade player. I wanted to try how hard scripting could be. I got inspired while playing on all this modded servers Smile

I still got millons of other questions lol. But maybe I will ask them another day. Razz

[Updated on: Wed, 28 October 2009 11:10]

Report message to a moderator

Re: Stealth command help [message #408672 is a reply to message #407893] Wed, 28 October 2009 11:17 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's just rare to see someone join randomly, and start diving into the renegade API. In fact, it's rare to see someone new period now.
I'm always pleased to see a new person come along, especially when they take to modding in this way.

I did not mind helping, you picked it all up pretty quickly really.



Re: Stealth command help [message #408774 is a reply to message #408672] Thu, 29 October 2009 11:47 Go to previous message
Jerad2142 is currently offline  Jerad2142
Messages: 3812
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
reborn wrote on Wed, 28 October 2009 12:17

It's just rare to see someone join randomly, and start diving into the renegade API. In fact, it's rare to see someone new period now.
I'm always pleased to see a new person come along, especially when they take to modding in this way.

I did not mind helping, you picked it all up pretty quickly really.

There is bound to be the random occurrence of ren players that want to start their own servers, Ren isn't dead YET. From what I've seen most ren players are excellent at asking questions when they need help, and from my experience, if they are shy, they usually bounce someone an IM.

Now the real question should be whether or not any of these new people will stick around? lol


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


Current Time: Sun Dec 15 07:57:06 MST 2024

Total time taken to generate the page: 0.00990 seconds