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 → A Cog prob
A Cog prob
2001-05-30, 10:29 AM #1
ok here's my cog. and the problem with it is that NOTHING happens ingame can someone help me with it?
# Jedi Knight Cog Script
# trade.cog
#
# This cog will play one unistring then play a sound at the activator pos, check if the player has enough credits if he does then it will
# create an object at a ghost posistion
# Activator is thing that has to be activated for cog to work
# GhostPos is the place where the bought item will be placed
# Purchase is the template of the bought item
# SpeakSound is the voice that will be played at the Activator
# SndFlags are the sound flags (don't know what this is)
# Cost is the cost of the item being purchased
# Unistring1 is the string that tells you what the activators offering and for what price
# Unistring2 is the string that is printed after you have done buisness with the activator
# Unistring3 is the string that tells you you don't have enough credits
# VolFlex is the Volume Flex (don't know what this is either)
# MinSndDist is the minimum sound range of the SpeakSound
# MaxSndDist is the maximum sound range of the SpeakSound
#
# By: JK2k_Avenger
# This Cog is Not supported by LucasArts Entertainment Co
symbols
Thing Activator
Thing GhostPos

Template Purchase

Sound SpeakSound

Int Player Local
Int Inuse Local
Int HeardOnce Local
Int CheckCash Local
Int SndFlags

Flex Cost
Flex Unistring1
Flex Unistring2
Flex Unistring3
Flex VolFlex
Flex MinSndDist
Flex MaxSndDist

Message Activated
end


# ========================================================================================
code
# ========================================================================================
Activated
If(Inuse == 1) Return; //checks if someone is speaking to the Activator

Inuse=1;
PlaySoundThing(SpeakSound, Activator, VolFlex, MinSndDist, MaxSndDist, SndFlags); //plays Activator's voice
If(HeardOnce == 0) JKPrintUnistring(player, Unistring1); //if the player has not heard the deal then it will print it out
HeardOnce = 1;
CheckCash=GetInv(player, 40);
If(CheckCash => Cost) JKPrintUnistring(player, Unistring3); //if the cash is less than the cost then print unistring 3
If(CheckCash => Cost) Return;
ChangeInv(Player, 40, -Cost);
JKPrintUnistring(player, Unistring2)
CreateThing(Purchase, GhostPos);
Inuse=0;
return;
# ........................................................................................

end
Join JK2k on the zone! go to http://www.jk2k.8k.com
2001-05-30, 11:03 AM #2
It had some syntax errors in it. Try it now.
Code:
# By: JK2k_Avenger
# This Cog is Not supported by LucasArts Entertainment Co
symbols
Thing        Activator                                                        
Thing        GhostPos                                                         
Template     Purchase                                                         
Sound        SpeakSound                                                       
Int          Player                             Local                         
Int          Inuse                              Local                         
Int          HeardOnce                          Local                         
Int          CheckCash                          Local                         
Int          SndFlags                                                         
Flex         Cost                                                             
Flex         Unistring1                                                       
Flex         Unistring2                                                       
Flex         Unistring3                                                       
Flex         VolFlex                                                          
Flex         MinSndDist                                                       
Flex         MaxSndDist                                                       
Message      Activated                                                        
end                                                                           
# ========================================================================================
code
# ========================================================================================
Activated:
If(Inuse == 1) 
 {
Return;
 } 
Inuse=1; 
PlaySoundThing(SpeakSound, Activator, VolFlex, MinSndDist, MaxSndDist, SndFlags); //plays Activator's voice
If(HeardOnce == 0) JKPrintUnistring(player, Unistring1); //if the player has not heard the deal then it will print it out 
HeardOnce = 1;
CheckCash = GetInv(player, 40);
If(CheckCash >= Cost) 
 {
JKPrintUnistring(player, Unistring3);
} 

If(CheckCash >= Cost) 
{
Return;
}
ChangeInv(Player, 40, -Cost);
JKPrintUnistring(player, Unistring2);
CreateThing(Purchase, GhostPos);
Inuse=0;
return;
# ........................................................................................ 
end
Gravity isn't MY fault--I voted for velcro.
2001-05-31, 10:02 AM #3
I wish i could say it worked. It worked a lot better but now its just givin me the "you don't got enough cash" message
Join JK2k on the zone! go to http://www.jk2k.8k.com
2001-05-31, 12:38 PM #4
Quote code:
Code:
If(CheckCash >= Cost)  
{
JKPrintUnistring(player, Unistring3);
} 
If(CheckCash >= Cost) 
{
Return;
}

I think this is the problem (also you can combine the two IF statements). You want to print unistring3 if the checkcash is LESS than the cost not more. So substitute the following:
Code:
If(CheckCash < Cost)  
{
JKPrintUnistring(player, Unistring3);
Return;
}



------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton

↑ Up to the top!