Variable keeps resetting while NOT told to.
#1

Kai, now I'm confused. I'm updating my scripts if you want to know the background story.

I've got this variable which keeps resetting it, and I totally have NO clue about what might cause it.

Here's my script:

pawn Код:
if(Pos[2] - Pos[5] > 4 || CowJump[playerid] > 0) ///If the player is either in the process of 'jumping' or is above a specific ground level.
        {
            SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[2] + ((CowJump[playerid] <= 0) ? (-0.32) : (0.6))); //Sets the player's  position lower if he is not jumping or higher if he is.
            CowJump[playerid]--; //Lowers the CowJump variable.
            printf("CJ: %d", CowJump[playerid]); //Prints the value stored in "CowJump[playerid]".
        }
            else
        {
            print("AWMIGAWD"); //Gets printed if this part is called (Not jumping/ in air)
            CowJump[playerid] = 0;
            if(Keys[0] & KEY_JUMP && !CowJump[playerid]) CowJump[playerid] = 6; //Sets the "CowJump[playerid]" variable to '6', IF the jump key is pressed and the value is zero.
            SetObjectPos(Cow[playerid], Pos[3], Pos[4], Pos[5] + ((CowJump[playerid] > 0) ? (2.6) : (2.0)));
        }
Hope that was explaining enough, I suck at it ^^.

Anyways, the "CowJump" variable keeps resetting to '6' if I KEEP KEY_JUMP pressed, and so it keeps going up. However, the part that check if the player presses the jump key doesn't gets reached at all.

Here's my log:

Код:
//Just "walking"
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:11] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD
[17:28:12] AWMIGAWD

//Pressing space
[17:28:12] CJ: 5
[17:28:12] CJ: 4
[17:28:13] CJ: 3
[17:28:13] CJ: 2
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 1
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 0
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 5
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 4
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 3
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 2
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 1
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 0
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 5
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 4
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 3
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 2
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 1
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 0
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 5
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 4
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 3
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 2
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 1
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 0
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 5
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 4
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 3
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 2
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 1
[17:28:13] POS2 - POS5 > 4!
[17:28:13] CJ: 0
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 5
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 4
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 3
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 2
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 1
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 0
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 5
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 4
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 3
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 2
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 1
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 0
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 5
[17:28:14] POS2 - POS5 > 4!
[17:28:14] CJ: 4

//When 'falling down' (Not on the ground, neither pressing the jump key, so falling down gently. Mention the CJ being under zero). No problems here.

[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 1
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 0
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 5
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 4
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 3
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 2
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 1
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 0
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 5
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 4
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 3
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 2
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 1
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: 0
[17:27:45] POS2 - POS5 > 4!
[17:27:45] CJ: -1
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -2
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -3
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -4
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -5
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -6
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -7
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -8
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -9
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -10
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -11
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -12
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -13
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -14
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -15
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -16
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -17
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -18
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -19
[17:27:46] POS2 - POS5 > 4!
[17:27:46] CJ: -20
[17:27:47] POS2 - POS5 > 4!
[17:27:47] CJ: -21
I hope I could've explained my problem correctly, and I also hope that somebody knows the answer . I haven't tried any workarounds yet, or at least not much, as I'm always eager to find out what I'm doing wrong.

Thanks in advance,
Hiddos
Reply
#2

So the variable CowJump is resetting for that player?
Reply
#3

Quote:
Originally Posted by Badger(new)
Посмотреть сообщение
So the variable CowJump is resetting for that player?
Simply said, it works fine UNTIL I keep pressing the jump key from the moment I 'jump'. If I release it, it doesn't happens anymore for the time in the air though, but it's kinda pissing me off
Reply
#4

Bumping this, I could really use some help with this

Also trying to do some workarounds atm, but I can't figure out WHY it is resetting .
Reply
#5

You haven't given out enough code for us, atleast I have no idea what's going on in that your code.

What does Pos contain?

What if one of the values here is negative, does this code below check what it should?
pawn Код:
Pos[2] - Pos[5] > 4
Also:
pawn Код:
CowJump[playerid] = 0;
if(Keys[0] & KEY_JUMP && !CowJump[playerid]) CowJump[playerid] = 6;
Ain't the !CowJump[playerid] part kind of useless here?

Same as:
pawn Код:
this_is = true;
if(this_is == true) dothis();
Reply
#6

Edit: I'm a retard. For my problem, check line 16 of the script.

This can be closed and ignored, I'm gonna bash my head with a hammer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)