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 → Cog check *snippet only*
Cog check *snippet only*
2001-10-13, 7:11 PM #1
Ok, here's the deal. I'm coding a King of the Hill MP game much like Perfect Dark's. The following snippet checks for anyone in the hill. If an enemy team has it, the countdown clock stops, if your team has it, nothing changes, and if nobody has it, your team claims the hill. It is on a .5 second pulse. All I need to know is if the syntax is right, and whether this will work. Give feedback plz.

Code:
////////////////SECTOR CHECK\\\\\\\\\\\\\\\\\\\\\\\

  x = GetSenderID();
  tester = FirstThingInSector(x);
  while(tester != -1)
     {
        if(GetThingType(tester) == 10) || (GetPlayerTeam(tester) == 1) playerCountgold0[x] = playerCountgold0[x]+1;
        if(GetThingType(tester) == 10) || (GetPlayerTeam(tester) == 2) playerCountred0[x] = playerCountred0[x]+1;
        if(GetThingType(tester) == 10) || (GetPlayerTeam(tester) == 3) playerCountgreen0[x] = playerCountgreen0[x]+1;
        if(GetThingType(tester) == 10) || (GetPlayerTeam(tester) == 4) playerCountblue0[x] = playerCountblue0[x]+1;

	//Check to see if hill is taken
	If(lock_capture > 0) || (GetPlayerTeam(tester) != capturing_team)
	//Hill is taken, Stop the countdown
        //becuase enemy team has entered	
	    {
		call stop_countdown;
		Return;
	    }
	Else
	//Hill is NOT taken, give it to the 
	//player, and his team
	    {
		//REPLACE WITH SENDTRIGGER EVENTUALLY
		//set_tint, get team info, etc...
		capturing_team = GetPlayerTeam(GetSourceRef());
		lock_capture = 1;
		SetTimerEx(20, 6001, 0, 0);
		SetTimerEx(1, 6002, 0, 0);
		Return;
	    }
        tester = NextThingInSector(tester);
     }


Thanks so much, as always!

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2001-10-15, 5:39 AM #2
Didn't look through it carefully, but:

I think you should be using && (And) instead of || (Or) in your if statements. And your parentheses aren't right either. You need to check this cog with CogWriter.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-10-15, 6:15 AM #3
I haven't run it through CogWriter. That's usually my last step. I just needed someone to see if my sector checking code will work. I wasn't looking so much for syntax errors, but more on whether the verbs will work together doing what I want. Thanks for your input though, because I almost forgot to run it through CogWriter. [http://forums.massassi.net/html/biggrin.gif]


------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz

↑ Up to the top!