Raised This Month: $32 Target: $400
 8% 

Solved Copy/paste a code snippet with different results.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-14-2016 , 12:13   Copy/paste a code snippet with different results.
Reply With Quote #1

solved https://forums.alliedmods.net/showpo...6&postcount=13

[HELP][$$$] I got plugin Problem!!! Need HELP MUCH!! pls!1!! will paid much key$! //topic


Hi all,
I getting crazy. This is the x-time i try to solve this issue without success. I have this problem for a long time, as I wrote MyJailbreak/Drunk event day plugin and used this code from [ANY] Curse v1.2.1 the world was shiny.

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weapon) {
    if(
g_cursed[client]) {
        if(
g_cvar_x.BoolValue) {
            
vel[1] = -vel[1]; // Will always equal to the opposite value, according to rules of arithmetic.
            
            
if(buttons IN_MOVELEFT) { // Fixes walking animations for CS:GO.
                
buttons &= ~IN_MOVELEFT;
                
buttons |= IN_MOVERIGHT;
            } else if(
buttons IN_MOVERIGHT) {
                
buttons &= ~IN_MOVERIGHT;
                
buttons |= IN_MOVELEFT;
            }
        }
        if(
g_cvar_y.BoolValue) {
            
vel[0] = -vel[0];
            if(
buttons IN_FORWARD) {
                
buttons &= ~IN_FORWARD;
                
buttons |= IN_BACK;
            } else if(
buttons IN_BACK) {
                
buttons &= ~IN_BACK;
                
buttons |= IN_FORWARD;
            }
        }
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

This snippet invert the player movement ('W'=back,'S'=foward,'A'=right,'D'=left).

In the beginning it works like charm, but later stopped it working without changes on plugin and my world getting dark.
The mysterious - the code snippet still works in original Curse plugin but not in my drunk plugin.

If the code is inside my drunk plugins it's like the plugin push a button permanently. So I walk move back/forwards.

tl;dr I copy/pasted 1:1 the code, but get different result in two plugin surroundings.

I just changed the client bool g_cursed[client] to a no client bool IsDrunk & renamed the Cvars g_cvar_y/x.

I even removed all checks (cvar&bool) in original curse & my drunk plugin. Again two different results. It's bewitched
Spoiler


Full code to MyJailbreak/drunk:
Spoiler



Full code to [ANY] Curse v1.2.1:
Spoiler



Where is the conflict? What I haven't seen/considered? I getting depressive.
I'm tiered of this bug
__________________
coding & free software

Last edited by shanapu; 11-19-2016 at 23:03.
shanapu is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 11-14-2016 , 12:33   Re: Copy/paste a code snippet with different results.
Reply With Quote #2

Isn't vel[0] = -vel[0] good enough?

I don't see the need to block the buttons etc.
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-14-2016 , 13:33   Re: Copy/paste a code snippet with different results.
Reply With Quote #3

maybe conflict with your other plugins?
__________________
8guawong is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-17-2016 , 21:58   Re: Copy/paste a code snippet with different results.
Reply With Quote #4

Quote:
Originally Posted by OSWO View Post
Isn't vel[0] = -vel[0] good enough?

I don't see the need to block the buttons etc.
Like you see in the code comment, this block fixes walking animations for CS:GO.

But even without these block I don't get the desired effect on my plugin


Quote:
Originally Posted by 8guawong View Post
maybe conflict with your other plugins?
of cause I disabled all other myjb plugins and only used drunk and/or curse on a blank server.
different results.
Must be a part of my drunk.sp but I can see it. May I'm just code blind for my own work. To lazy now to strip all function step by step to find the problem.
__________________
coding & free software

Last edited by shanapu; 11-17-2016 at 22:00.
shanapu is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 11-18-2016 , 07:38   Re: Copy/paste a code snippet with different results.
Reply With Quote #5

The code works for me. So something is conflicting with it.
blaacky is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 11-18-2016 , 12:59   Re: Copy/paste a code snippet with different results.
Reply With Quote #6

Full black screen seems like a broken some overlay. Look your overlays on plugins. Try off all overlays
__________________


Max-Play.pl - the best polish servers

Last edited by CamerDisco; 11-18-2016 at 13:01.
CamerDisco is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-18-2016 , 13:34   Re: Copy/paste a code snippet with different results.
Reply With Quote #7

Quote:
Originally Posted by CamerDisco View Post
Full black screen seems like a broken some overlay. Look your overlays on plugins. Try off all overlays
whut? this question has nothing to do with overlays!? It's about invert player movement here. overlays are fine.
__________________
coding & free software
shanapu is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 11-18-2016 , 13:54   Re: Copy/paste a code snippet with different results.
Reply With Quote #8

Ok, but I think player movement can't do a black screen, I've this issue if my overlay doesn't work. Like a I see you're using overlays.
Quote:
my world getting dark.
Do you hear sounds from game and do you hear your footsteps?
__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-18-2016 , 14:00   Re: Copy/paste a code snippet with different results.
Reply With Quote #9

I assume you don't have the overlays of MyJailbreak when you test this.
Overlays works fine. no black screen if installed everything right. this is not the problem

This thread is about a problem with player movement modification. not about overlays


Quote:
my world getting dark.

This is just a mirror of my feelings about this problem.

Quote:
Do you hear sounds from game and do you hear your footsteps?
the game and plugin works fine. Its just about this one function at "OnPlayerRunCmd"
__________________
coding & free software
shanapu is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 11-18-2016 , 23:16   Re: Copy/paste a code snippet with different results.
Reply With Quote #10

You should start by disabling every other custom plugin and seeing it it still happens. It might be the case that you have two plugins doing this at the same time and they are inverting each other. Like one does vel[1] = -vel[1] and then the other one does it again making it the same value it originally was.
blaacky is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode