Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Сode
nightsxp Offline
Member

Posts: 53
Threads: 8
Joined: Sep 2011
Reputation: 0
#14
RE: Сode

(02-23-2013, 06:12 PM)NaxEla Wrote: I made a code for this a while ago... let me see if I still have it.

EDIT: Ok found it. This code will work if the script areas are called PressButton_1, PressButton_2, PressButton_3, etc... If you want to change the password, just change the number at the very top of the script.

PHP Code: (Select All)
const string correctCode "6274";
string playersGuessedCode "";

void OnStart(){}

void OnEnter()
{
    
SetLocalVarInt("ButtonsPressed"0);
    
    for(
int i=1i<=9i++) {
        
SetEntityPlayerInteractCallback("PressButton_"+i"PressedButton"false);
    }
}

void PressedButton(string &in entity)
{
    
int buttonsPressed;
    
    
AddLocalVarInt("ButtonsPressed"1);
    
    
playersGuessedCode += GetButtonPressed(entity);
    
buttonsPressed GetLocalVarInt("ButtonsPressed");
    
    
AddDebugMessage("Buttons Pressed: "+buttonsPressed+"  Guessed Code: "+playersGuessedCodefalse);
    
    if(
playersGuessedCode == correctCode) {
        
// unlock door or whatever here
        
for(int i=1i<=9i++) {
            
SetEntityActive("PressButton_"+ifalse);
        }
        
ResetCode();
        
AddDebugMessage("Correct code!"false);
        
        return;
    }
    
    if(
buttonsPressed == 4) {
        
ResetCode();
        
AddDebugMessage("Wrong code!"false);
    }
}

void ResetCode()
{
    
SetLocalVarInt("ButtonsPressed"0);
    
playersGuessedCode "";
}

string GetButtonPressed(string entity)
{
    if(
entity == "PressButton_1") {
        return 
"1";
    }
    else if(
entity == "PressButton_2") {
        return 
"2";
    }
    else if(
entity == "PressButton_3") {
        return 
"3";
    }
    else if(
entity == "PressButton_4") {
        return 
"4";
    }
    else if(
entity == "PressButton_5") {
        return 
"5";
    }
    else if(
entity == "PressButton_6") {
        return 
"6";
    }
    else if(
entity == "PressButton_7") {
        return 
"7";
    }
    else if(
entity == "PressButton_8") {
        return 
"8";
    }
    else if(
entity == "PressButton_9") {
        return 
"9";
    }
    else {
        return 
"";
    }
}

void OnLeave(){} 

._. diiificult =.= but thankss
02-24-2013, 02:22 PM
Find


Messages In This Thread
Сode - by nightsxp - 02-23-2013, 11:40 AM
RE: Сode - by MulleDK19 - 02-23-2013, 11:42 AM
RE: Сode - by PutraenusAlivius - 02-23-2013, 11:46 AM
RE: Сode - by MulleDK19 - 02-23-2013, 11:47 AM
RE: Сode - by FlawlessHappiness - 02-23-2013, 11:48 AM
RE: Сode - by nightsxp - 02-23-2013, 12:03 PM
RE: Сode - by The chaser - 02-23-2013, 12:51 PM
RE: Сode - by MulleDK19 - 02-23-2013, 12:55 PM
RE: Сode - by Tiger - 02-23-2013, 12:52 PM
RE: Сode - by NaxEla - 02-23-2013, 06:12 PM
RE: Сode - by nightsxp - 02-24-2013, 02:22 PM
RE: Сode - by darksky - 02-23-2013, 11:04 PM
RE: Сode - by NaxEla - 02-24-2013, 02:05 AM
RE: Сode - by tonitoni1998 - 02-24-2013, 04:05 AM



Users browsing this thread: 1 Guest(s)