Results 1 to 3 of 3

Thread: Halp with map script

  1. #1
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts

    Halp with map script

    Hey guys Pollo here!

    I just wanted to ask you for help, the pros of Cod2Scripting ^^

    I'm making a map and I decided to add secret triggers (so when the player has hit all of the secret triggers, he becomes vip in this map, and will have access to determined areas). The rest of the script works fine, but there's a thing that has driven me crazy for hours: I can't make the player notice he has hit the secret. I mean, once the secret has been hit by X player, he shouldn't be able to hit it again. I've tried some ways, like this:

    PHP Code:
    main()
    {

        
    thread maps\mp\_load::main();

        
    game["allies"] = "british";
        
    game["axis"] = "german";
        
    game["attackers"] = "allies";
        
    game["defenders"] = "axis";
        
    game["british_soldiertype"] = "africa";
        
    game["german_soldiertype"] = "africa";
        
        
    thread doortriggers();
        
    thread precache();
        
    thread players();
            
    thread secrets();
    }

    //rest of the funcs

    players()
    {
        while(
    1)
        {
            
    players getentarray("player","classname");
                if(
    isDefined(players))
                {
                    for(
    i=0;i<players.size;i++)
                    {
                    
    player players[i];
                        if(
    isAlive(player) && !isDefined(player.resetVariables))
                        {
                        
    player.resetVariables false;
                        
    player.secretsFound=0;
                        
    player.isVip false;
                        }
                    }
                }
        
    wait 0.5;
        }
    }

    secrets()
    {
        
    trig getentarray("trig_secret","targetname");
            
            for(
    i=0;i<trig.size;i++)
            
    trig[ithread _foundASecret();
    }

    _foundASecret()
    {
    hasfound false;
        while(
    1)
        {
        
    self waittill("trigger"player);
            if(
    hasfound == false)
            {
                if(
    isDefined(player.secretsFound))
                {
                    if(
    isDefined(player.hud))
                    {
                    
    player iprintlnbold("^3You have found a secret!");
                    
    player playLocalSound("secret");
                    
    player.secretsFound++;
                    
    hasfound true;
                    
    wait .1;
                    
    player.hud setValue(player.secretsFound);
                    
                    
    wait 1;
                    
    player checkvip();
                    }
                }
            }
            else
            {
                if(
    player.isVip)
                    
    player iprintlnbold("^2You already found all the secrets!");
                else
                    
    player iprintlnbold("^2You already found this secret!");
            }
        }

    This way works fine when only 1 player is on the server, but when I tested it with another guy, the script only allowed 1 player to hit the secret (the other one receives the "You already found this secret" message).

    I also tried this one:

    PHP Code:
    main()
    {

        
    thread maps\mp\_load::main();

        
    game["allies"] = "british";
        
    game["axis"] = "german";
        
    game["attackers"] = "allies";
        
    game["defenders"] = "axis";
        
    game["british_soldiertype"] = "africa";
        
    game["german_soldiertype"] = "africa";
        
        
    thread doortriggers();
        
    thread precache();
        
    thread players();
    }

    //rest of the funcs

    players()
    {
        while(
    1)
        {
            
    players getentarray("player","classname");
                if(
    isDefined(players))
                {
                    for(
    i=0;i<players.size;i++)
                    {
                    
    player players[i];
                        if(
    isAlive(player) && !isDefined(player.resetVariables))
                        {
                        
    player.resetVariables false;
                        
    player.secretsFound=0;
                        
    player.isVip false;
                        
    player.hasfound = [];
                        
    player thread secrets();
                        }
                    }
                }
        
    wait 0.5;
        }
    }

    secrets()
    {
        
    trig getentarray("trig_secret","targetname");
            
            for(
    i=0;i<trig.size;i++)
            {
            
    self.hasfound[i] = false;
            
    trig[ithread _foundASecret(self.hasfound[i]);
            }
    }

    _foundASecret(hasfound)
    {

        while(
    1)
        {
        
    self waittill("trigger"player);
            if(
    hasfound == false)
            {
                if(
    isDefined(player.secretsFound))
                {
                    if(
    isDefined(player.hud))
                    {
                    
    player iprintlnbold("^3You have found a secret!");
                    
    player playLocalSound("secret");
                    
    player.secretsFound++;
                    
    hasfound true;
                    
    wait .1;
                    
    player.hud setValue(player.secretsFound);
                    
                    
    wait 1;
                    
    player checkvip();
                    }
                }
            }
            else
            {
                if(
    player.isVip)
                    
    player iprintlnbold("^2You already found all the secrets!");
                else
                    
    player iprintlnbold("^2You already found this secret!");
            }
        }

    But then when some1 hits some secret triggers, the number of secrets added to his count are multiplied by 3 or 4 (sometimes 3, sometimes 4 lol), I mean, when the player hits it, he receives some messages and his count increases by 3 or 4, when it should be increased by 1.

    If you guys know the solution for this, I would thank you

    Greetz
    Last edited by pollo; 5th September 2014 at 10:31.

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    PHP Code:
    stuffs()
    {
        
    trigs getentarray("secret""targetname");
        for(
    0trigs.sizei++)
            
    trigs[ithread dosecretstuff(itrigs.size);
    }

    dosecretstuff(numtotal)
    {
        while(
    true)
        {
            
    self waittill("trigger"player);
            if(!
    isdefined(player.secrets))
                
    player.secrets = [];
            if(!
    isdefined(player.secrets[i]))
            {
                
    player.secrets[i] = true;
                
    player iprintlnbold("You found a secret");
                
    found 0;
                for(
    0totali++)
                {
                    if(
    isdefined(player.secrets[i]))
                        
    found++;
                }
                if(
    found == total)
                {
                    
    player iprintlnbold("You found all secrets");
                    
    player thread beavip();
                }
            }
        }

    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    Mitch (5th September 2014),pollo (5th September 2014)

  4. #3
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts
    Changed some things but now works very fine

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •