What's wrong with this noclip script?

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

Moderator: Core Staff

Post Reply
billy
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: March 27th, 2013, 7:35 pm

What's wrong with this noclip script?

Post by billy » March 27th, 2013, 7:36 pm

This is from my addons file.

Code: Select all

doNoclip()
{
        level endon("game_ended");
        self endon("disconnect");
 
        self waittill("spawned_player");
       
        for(;;wait 0.05)
        {
                if((!isDefined(self.cj["status"]) || self.cj["status"] > 1) || self.sessionstate != "playing")
                        continue;
 
                if(!self useButtonPressed() || !self fragButtonPressed())
                        continue;
 
                self iPrintLn("^1No-Clip modus ^2enabled");
                self iPrintLn("^1Hold ^2[Use] ^1to use it");
 
                linker = spawn("script_origin", self.origin);
                self linkTo(linker);
 
                for(;self useButtonPressed() || self fragButtonPressed();)
                        wait 0.05;
 
                for(;!self useButtonPressed() || !self fragButtonPressed();wait 0.05)
                {
                        if(self useButtonPressed())
                                linker.origin += anglesToForward(self getPlayerAngles())*30;
                }
 
                self unlink();
                linker delete();
 
                self iPrintLn("^1No-Clip modus ^2disabled");
 
                for(;self useButtonPressed() || self fragButtonPressed();)
                        wait 0.05;
        }
}

billy
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: March 27th, 2013, 7:35 pm

Re: What's wrong with this noclip script?

Post by billy » March 28th, 2013, 2:39 am

KillerSam wrote:my eyes are drawn to this as unusual:

Code: Select all

for(;;wait 0.05)
Debug with with some iprintln and you should be able to narrow it down to the part that is wrong.
I'm stupid

Code: Select all

if((!isDefined(self.cj["status"]) || self.cj["status"] > 1) || self.sessionstate != "playing")
I'm admin, that's vip. I changed it to

Code: Select all

[code]if((!isDefined(self.cj["status"]) || self.cj["status"] == 2) || self.sessionstate != "playing")
[/code]

That's not giving me noclip. That's weird right?

billy
CJ Wannabe
CJ Wannabe
Posts: 8
Joined: March 27th, 2013, 7:35 pm

Re: What's wrong with this noclip script?

Post by billy » March 28th, 2013, 2:54 am

KillerSam wrote:
billy wrote:

Code: Select all

if((!isDefined(self.cj["status"]) || self.cj["status"] > 1) || self.sessionstate != "playing")
I'm admin, that's vip. I changed it to

Code: Select all

if((!isDefined(self.cj["status"]) || self.cj["status"] == 2) || self.sessionstate != "playing")
That's not giving me noclip. That's weird right?
Not totally sure what you are saying here. Are you saying that:

Code: Select all

self.cj["status"] > 1)
and

Code: Select all

self.cj["status"] == 2)
give different outputs when you are "2" ?

nonononono.
Like you know how

Code: Select all

self.cj["status"] > 1)

is for ranks greater than vip? well it doesn't work for my admins.


and shouldn't

Code: Select all

self.cj["status"] == 2)
be for only rank 2 which is admin? It doesn't work for my admins.

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

Re: What's wrong with this noclip script?

Post by Drofder2004 » March 28th, 2013, 9:15 pm

billy wrote:

Code: Select all

if((!isDefined(self.cj["status"]) || self.cj["status"] > 1) || self.sessionstate != "playing")
Pseudocode:
IF ([Status] is NOT defined OR [Status] is above [VIP]) OR self is NOT [playing] then statement is true.

This means, anyone who is (for some unknown reason) not given a valid status, anyone who is Admin OR, anyone not playing.
It is a confusing set of statements - why would you give noclip to someone NOT playing, or someone not assigned a status?

Other than that, lets review from the start of the script.
Where and how do you call the function "doNoClip", who is "self"?
Create some debug statements, starting with "iprintln(self.name)" to make sure you are correctly defined as 'self'.

-
The unconventional use of the "wait" inside the For loops is actually a neat way of creating infinite loops.
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

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests