View Full Version : A problem...
Edward
03-20-2005, 06:48 PM
Hi!
A problem, or 2, or thousand...
I have made this COG where a door is locked unless you can type in the right code. Problem is that, the code that is displayed in the other room does not seem to match what I type in! Yet, in the print test it is 100% matching.
Problem 2 is that I want this code to be secretive until the release of my level. So... Who can I trust to look, help, then remove and forget?
/Edward
zagibu
03-21-2005, 04:22 AM
Have you tried another code?
Edward
03-21-2005, 06:04 AM
Have tried lots of different codes.
Thing is that the code isn't really preset. At startup: I give a random 8 digit number. Random numbers so people can't cheat and not go to "this" room.
Post your display code...
Edward
03-21-2005, 08:16 AM
My display code?
You mean the random numbers? Or where they are displayed? Or what is being displayed on the code machine?
I'll display something:
startup:
sleep(rand());
for(i=0; i<8; i=i+1)
{
SetWallCel(type0[i],10);
num0[i]=rand()*9;
SetWallCel(find0[i],num0[i]);
sleep(rand());
}
return;
OK... That is as much as I can display without giving away stuff... If it ain't enough, then I'll have to trust someone.
/Edward
Edward
03-22-2005, 06:52 AM
OK... I can give one other piece of code...
player=GetSourceRef();
if(GetWallCel(type0)==num0 && GetWallCel(type1)==num1 && GetWallCel(type2)==num2 && GetWallCel(type3)==num3 && GetWallCel(type4)==num4 && GetWallCel(type5)==num5 && GetWallCel(type6)==num6 && GetWallCel(type7)==num7)
{
PlaySoundPos(correct, GetSurfaceCenter(type7), 1, -1, -1, 0x0);
MoveToFrame(door, 1, 4);
}
call offline;
G-Man
03-22-2005, 10:55 AM
rip the cog out from the new empire by chris swan wich makes the same
Edward
03-22-2005, 02:03 PM
Originally posted by G-Man
rip the cog out from the new empire by chris swan wich makes the same
=§ Eeehh.... I can't believe what the HELL I'm seeing!!! THREE COGS! FOR ONE SECURE DOOR!!! I think I'm gonna pass out...
Anyway, I found the resulting COG, and I see it has brackets around each number, so I did so and nothing changed.
Oh, and also, I can't really use this COG even if I merge the 3 together. I'm using a completely different technik.
Can you keep a secret? If you can, post your Email... I'm afraid I might have lost it...
/Edward
Edward
03-25-2005, 05:09 AM
So, who can keep a big secret? The one who can, post your Email and say YES!
/Edward
zagibu
03-25-2005, 06:30 AM
What's printed when you add this code in your second cog section just above the if clause:
for(i=0;i<8;i=i+1)
{
PrintInt(GetWallCell(type0[i]));
PrintInt(num0[i]);
Sleep(3);
}
It should print a matching pair of numbers all 3 seconds...
Edward
03-25-2005, 07:09 AM
EXACT MATCH! Yet, door won't open...
And you spelled the celllllls wrong.
SG-fan
03-26-2005, 03:16 AM
I can keep a secret, but it may take a while for me to get back to you. lumpshare@yahoo.com
zagibu
03-26-2005, 08:56 AM
Strange...try enclosing each comparison with brackets, like this:
if((GetWallCel(type0) == num0) && (GetWallCel(type1) == num1) ...etc.)
Might be an operator hierarchy problem...
Edward
03-26-2005, 10:39 AM
I did that five posts ago!
Anyway, I have entrusted SG-fan with the holy secret code, and he will be working on it. Anyone who DARES bug him will be automaticly banned until I submit a level to Massassi. Thank you.
/Edward
zagibu
03-27-2005, 05:22 AM
Now that can't be. The if clause must become true, if you really have an exact match on the numbers...
Have you tried negating the if clause and seeing if it opens when the code is wrong?
Edward
03-27-2005, 06:16 AM
Still no change... Even if I added a completely different number.
SG-fan
03-27-2005, 03:57 PM
Bingo, the problem was that the "integer" num0[i] wasn't actually truncating the rand()*9 value. It was leaving it as a decimal. Thus the if statement was testing if(1==1.797ect.)
I fixed it by adding a single line in the startup after the setwallcel
num0[i]=GetWallCel(find0[i]);
That forced the proper truncation without worries of integers rounding up instead of down.
Edward
03-27-2005, 04:15 PM
Thank you very much! Now you must delete and forget! I've sent you a little prise. Hope you like!
/Edward
zagibu
03-27-2005, 06:23 PM
Oh well. Then it's the PrintInt that made the conversion from decimal to integer, or else it would have displayed the difference...
SG-fan
03-27-2005, 06:37 PM
Actually that's it exactly. I wasn't 100% sure on the problem till I did a printflex(). In all my cogs I use printflex, I never use printint anymore since they both do the same thing, just one would show the decimals.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.