Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → C/S Cogs
C/S Cogs
2002-03-03, 7:36 AM #1
OK, here's a Client/Server cog i've written, I haven't had much experiance with C/S, I made this cog by looking at other cogs. Now the problem is that nothing happens when I activate the switch, could someone point out what i'm doing wrong?

Server cog:
Code:
# Jedi Knight Cog Script
#
# gravserver.cog
#
# This will send a trigger to the client grav cog
# 
#
# [E3 - 15/8/2001]
#
# 
---------------

symbols

thing switch

message  activated

end

# ========================================================================================

code

activated:


   SendTrigger(-1, 386753, 0, 0, 0, 0);


   Return;


end


Client cog:
Code:
# Jedi Knight Cog Script
#
# gravclient.cog
#
# Adapted from Zero's cog, this clients/server cog should work in
# multiplayer and effect everyone in the game (unlike the original 
# which only effected the host).
#
# [E3 - 15/08/2001]

symbols

message     trigger

flex		number1	local

sound		gravalarm

end

# ========================================================================================

code

trigger:

   
if(GetSenderID != 386753) Return;


	number1 = GetGravity();

	PlaySoundGlobal(gravalarm, 1.0, 0.0, 0x10000);

	if(number1 == 0)
	{
		print("Gravity Level: NORMAL");
		SetGravity(4.0);
		number1 == 4;
		return;
	}
	if(number1 == 4)
	{
		print("Gravity Level: HIGH");
		SetGravity(7.0);
		number1 == 7;
		return;
	}
	if(number1 == 7)
	{
		print("Gravity Level: LOW");
		SetGravity(1.0);
		number1 == 1;
		return;
	}
	if(number1 == 1)
	{
		print("WARNING GRAVITY LEVEL 0: If You Jump... You Will Not Come Down!");
		SetGravity(0.0);
		number1 == 0;
		return;
	}
	return;
end

        
Code:
[Edit]hahahaha - the post has been here for over 3 hours and i've only just noticed that i forgot to add the code hehehe[/edit]

[This message has been edited by Electro (edited March 03, 2002).]
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
<EL3CTRO> EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
2002-03-03, 9:46 AM #2
Without really looking into it, I see two mistakes:

1) Verbs must have a set of parentheses after them even if the have no parameters. Use GetSenderID(). And anyway, you need to use GetSourceRef() to find the ID of a trigger.

2) The '==' is a relational operator which tests two numbers for equality. The '=' is an assignment operator which assigns a variable to a value.

You should download CogWriter to check your syntax. It should have caught both of those mistakes.

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited March 03, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-03, 7:08 PM #3
Interesting ..... I haven't had much experince with C/S cogs either.... I was just curious ... if a client sent a trigger (or vise versa) to another computer... how long will it actually take to get there ?? would it depend on there ping or would it get there instantly ?
2002-03-03, 10:31 PM #4
It takes about the time of a players ping to the other player for the trigger to be recieved.

Electro. I would change the code to:

if( (GetSourceRef() == 386753) )
{
dadada
}
Team Battle.
2002-03-04, 5:12 AM #5
No, Hellcat, it's neater to have one return then a huge code block and there's no reason for an extra set of parentheses.

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-04, 7:33 AM #6
In other words,

 

If(Getsourceref() != 386753) Stop;


Dadada

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-03-04, 5:26 PM #7
Sorry, I was just giving him it so it would be easy to understand. (Thats for the { then }... I didnt notice I put an extra set of (), sorry.)
Team Battle.
2002-03-04, 5:41 PM #8
Quote:
<font face="Verdana, Arial" size="2">It takes about the time of a players ping to the other player for the trigger to be recieved.</font>


So if someone had a ping of 2000 to someone else.. would it take the trigger 2 seconds to get there ???

What about if you sent multipul triggers.... would that make it lag and take more time ?
2002-03-04, 6:23 PM #9
Quote:
<font face="Verdana, Arial" size="2">Originally posted by *_Seifer_*:
So if someone had a ping of 2000 to someone else.. would it take the trigger 2 seconds to get there ???

What about if you sent multipul triggers.... would that make it lag and take more time ?
</font>


That's right. A comp can't know what's been done on a comp at the other side of the world. If the ping is THAT horrible, it takes that amount of time for the trigger to get there.

If you send 10 triggers in a message, it won't cause a lag. Sending lots of packets make lag(like in a pulse), but just 10 of 4 parameter messages won't send lots of packets, so won't lag.

But if that 10 triggers get sent often(like in a pulse), that will lag, because the important(key presses etc) packets can't be sent so smoothly.

------------------
http://millennium.massassi.net - Millennium
Sniper Arena! - Enhancement Pack!

[This message has been edited by Hideki (edited March 04, 2002).]
2002-03-05, 11:46 AM #10
(since we're on the subject of triggers and lag)

Would sending one trigger in a pulse(0.01); cause lots of lag?
-Hell Raiser
2002-03-05, 5:30 PM #11
Hell - yes. I wrote a vechile code once that used sendtrigger on a pulse of 0.01 and it lagged the game...
Team Battle.
2002-03-05, 6:21 PM #12
Hmmmmmmm would a loop of a message with maybe sleeps inbetween it lag the game ?

loop:

SendTrigger()
Sleep(bla)
SendTrigger()
Sleep(bla)
SendTrigger()
Sleep(bla)

call loop;

return;
2002-03-05, 6:38 PM #13
Umm, Seifer, loops like that dont work.

Maybe this:

 

While(1) { Sendtrigger(Blah, blah, blah); Sleep(Blah); }

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-03-05, 9:37 PM #14
It really depends how often your sending packages.
Team Battle.
2002-03-06, 2:29 AM #15
don't use sleep in a pulse/maybe even a loop..
2002-03-06, 12:27 PM #16
Why wouldn't you? Sleep() works corrrectly in both cases.

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited March 06, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-06, 5:28 PM #17
HOLY CRAP, I must be seeing things! Did I just read that *_Seifer_*, the GOD OF COGS hasn't had much experiance with C/S? The man who made bots that understand and speak english, who made 5D models and real time sector warping? Oh wait, this just probably means your beyong C/S. I'll bet you'ved invented a way to instantly sync data by using electromagnetic pulses that your body naturally creates somehow. Yeah, that's it.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2002-03-07, 9:16 PM #18
Shut up you dick.
2002-03-07, 9:39 PM #19
Emon, you have serious issues... your contribution is unhelpful and you are acting like a 3 year old baby. Grow up.
Team Battle.
2002-03-08, 7:14 PM #20
I agree HellCat ....... btw can we define excatly what we mean by lag ??? as in what sort .... joltyness of the screen ??? .... clients teleporting ?? things stuffing up ???
2002-03-08, 7:31 PM #21
In this case, lag refers to the EXTREME AMOUNT OF TIME IT TAKES FOR A PACKET OF DATA TO CROSS THE NETWORK.

</anger>

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-03-08, 8:00 PM #22
Yup. Jerkyness may cause a certian person to lag (if they get like 1 frame a second, then they only recieve packages once every second.), but generally the net speed will determine the players ping. If a player has a lower framerate than others they can still have a better ping because of their connection.

Things like clients teleporting and things stuffing because of missed packages up can be a result of lag.
Team Battle.
2002-03-09, 6:06 AM #23
wait Hellcat...are you saying JK isn't a realtime timer game but a frame timer game? Are you sure?
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-03-09, 11:57 AM #24
No, what I'm saying is that if you get like frame per second then you miss or drop lots of network packages...
Team Battle.

↑ Up to the top!