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 → Help me on this cog
Help me on this cog
2002-09-23, 10:08 AM #1
I made this cog for a map i was making. It was supposed to be for a wepon dispenser. It works when i try the level by myself, but with others, it boots everyone out of the game. couls someone tell me what's wrong with it?

Code:
# Jedi Knight Cog Script
#
# Made for a gun dispenser
#

symbols

thing		console			desc=console    

thing		player			local


flex		delay=8.0	        desc=delay

int		firing=0		local

int		dummy			local
int		amount=1
int		bin=6			
int		ammo=30
int		ammobin=12

sound		on_snd=Activate04.wav	local
sound       pickupsnd=powerpu1.wav	local


message		activated

end

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

code

activated:
	player = GetSourceRef();
	if(firing == 1) Return;
     	firing = 1;
	dummy = playsoundthing(on_snd,console,1.0,-1,3.0,0x0);
	


PlaySoundThing(pickupsnd, console, 1.0, -1, -1, 0);
   AddDynamicTint(player, 0.0, 0.0, 0.2);
jkPrintUNIString(player, bin);
	ChangeInv(player,bin,amount); 
	ChangeInv(player, ammobin, ammo);

        
	
	

	Sleep(delay);
		
	firing = 0;
	Return;

end

============================================


If you can help, thanks

[This message has been edited by SaberMaster (edited September 23, 2002).]
2002-09-23, 11:40 AM #2
I don't see anything there that would crash another player's computer, but there are some inhibiting mistakes.

Since this is a level cog and it uses no Cog Flags, event messages such as activated will run only on the server. And activated messages received by the client computers' cogs will be forwarded to the server.

That's fine, but when the server receives and handles the message, it cannot set bin values on the clients computers. So it would only work for the server. You'll need to use the 0x40 Cog Flag to make the cog locally on each computer.

Code:
dummy = playsoundthing(on_snd,console,1.0,-1,3.0,0x0);

If you use -1 for the minrad distance, JK will use its default minrad of about 5 (units in .1 JKUs). So using a maxrad of 3 is pointless.

Try this cog:
Code:
# give_weap.cog
#
# A weapon dispenser cog.
#
# [STG + SM]
#==============================================================#
flags=0x40
#==============================================================#
symbols

thing     console                  mask=0x400
thing     player                   local

flex      delay=8.0

int       locked=0                 local
int       amount=1
int       bin=6
int       ammo=30
int       ammobin=12

sound     on_snd=Activate04.wav
sound     pickupsnd=powerpu1.wav

message   activated

end
#==============================================================#
code
#------------------------------------------------------
activated:
	if(locked) Return;
	locked = 1;
	player = GetSourceRef();
	PlaySoundThing(on_snd, console, 1, -1, -1, 0);
	PlaySoundThing(pickupsnd, console, 1, -1, -1, 0);
	AddDynamicTint(player, 0, 0, 0.2);
	jkPrintUNIString(player, bin);
	ChangeInv(player, bin, amount);
	ChangeInv(player, ammobin, ammo);
	Sleep(delay);
	locked = 0;

Return;
#------------------------------------------------------
end


It should work. [http://forums.massassi.net/html/wink.gif]

BTW, when posting code, always use the UBB
Code:
 tags. And welcome to Massassi.  [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-09-24, 10:30 AM #3
thanks for the help. I'll try that cog and see if it works. thanks again.

↑ Up to the top!