a script for cj map

Have a question you need to ask? Need help? Ask here!

Moderator: Core Staff

Post Reply
pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

a script for cj map

Post by pcbouncer » November 27th, 2012, 10:57 pm

I need a script that will absolutely not let you save unless you are COMPLETELY stopped. I have a few problems though. I am not new to coding, but i am new to scripting. Where should i store the text file? how would i make a script that does this? I have no idea where to start, please help.

-pcbouncer

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: a script for cj map

Post by Drofder2004 » November 28th, 2012, 12:17 am

How would you describe completely stopped?

You could create a script that tracks the players origin every 2 seconds, if the origin does not change, you assign a value of "player.notmoving = true" and use that in the save loop, making sure to reset it when they move.

What exactly is the purpose of the script?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 28th, 2012, 1:59 am

There are surface types that are ice. They allow you to slide and unfortunately i don't want them to be able to save until they've stopped (to make it harder) otherwise they can save right as they get to the platform, even if they are moving. When they load, they load completely still.

So, i am confused at the stuff you mentioned, although it does make sense. Could you explain how someone would go about this?
Could you just make an if statement that stated if they are moving, saving = false, else, save = true?

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 28th, 2012, 2:01 am

Also i might want a 1 second wait time before they can save, after they've stopped.

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 28th, 2012, 2:05 am

I just realized what you were saying. I am new to scripting for cod4, maybe show a little of the script you were thinking of. I don't have any idea where to store the .gsc file and i don't understand how it will stay inside the map.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: a script for cj map

Post by Rezil » November 28th, 2012, 2:42 am

Code: Select all

check_movement()
{
        THRESH = 20;
        WAIT_TIME = 0.5;
        
        diff = [];
        old_origin = [];
        for(i=0;i<3;i++)
        {
                diff[i] = 0;
                old_origin[i] = self.origin[i];
        }
        
        while(1)
        {
                has_moved = false;
                
                for(i=0;i<3;i++) //if you only need X and Y movement, use i<2
                {
                        diff[i] = old_origin[i] - self.origin[i];
                        if(abs(diff[i])>THRESH)
                                has_moved = true;
                        old_origin[i] = self.origin[i];
                }
                
                if(has_moved)
                        iprintlnbold("player moved by more than "+THRESH+" units.");
                
                wait WAIT_TIME;
        }
}
abs(n)
{
        if(n<0)
                return n*-1;
        return n;
}
Untested. Call check_movement() on a player, self.moving = true(not self.notmoving, why use negatives in variable names? It just makes things more confusing) would be set either after the if(has_moved) check or just directly asigning it the value of has_moved. Lower values of THRESH = less units moved to trigger self.moving = true, lower values of WAIT_TIME checks for movement more frequently.

Google the other stuff.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 28th, 2012, 3:23 am

Alot of it is confusing, but where would i put the .gsc file??

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 28th, 2012, 4:04 am

also im not sure if it worked, i tried testing it

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: a script for cj map

Post by Drofder2004 » November 28th, 2012, 8:41 pm

This is only a detection code, Rezil has not provided you with all of the working mechanics.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: a script for cj map

Post by pcbouncer » November 30th, 2012, 10:49 pm

so confused about map scripting

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: a script for cj map

Post by Rezil » December 1st, 2012, 12:59 am

pcbouncer wrote:so confused about map scripting
What exactly do you want us to do for you? I've provided you with an example, there are loads of beginner scripting tutorials for codscript, there's lots of code in your stock CoD files you can go through, there's a shitload of websites that help users with their mapping/scripting problems(this being one of the better ones in my opinion :) ).

If you're not willing to invest your time to figure some basic stuff for yourself, I'm not willing to invest my time to do it for you.

http://lmgtfy.com/?q=cod+scripting+tutorial

viewtopic.php?f=19&t=4011
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests