Raised This Month: $203 Target: $400
 50% 

Enum scoping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
popey456963
Member
Join Date: Mar 2016
Old 03-09-2018 , 16:08   Enum scoping
Reply With Quote #1

Hello,

At the moment I'm getting this fairly strange issue with enum scoping, I'm wondering whether anyone can point out where I'm going wrong? I'm currently playing around with methodmaps a lot, OOP is often said to be over-rated but it works really well for some things. Namely, I have an "invisibility" skill I'm developing:

PHP Code:
/*
 * Base CS:GO plugin requirements.
 */
#include <sourcemod>
#include <sdktools>
#include <cstrike>

/*
 * Custom methodmap includes.
 */
#include <player_methodmap>

public Action OnPlayerHurt(Event event, const char[] namebool dontBroadcast) {
    
char weapon[64];
    
event.GetString("weapon"weaponsizeof(weapon))

    if (
StrEqual(weapon"weapon_taser")) {
        
Player player Player(event.GetInt("userid"))
        if (
level) {
            
player.Invisible(true);
        }
    }

And the player methodmap file:

PHP Code:
#if defined _player_methodmap_included
    #endinput
#endif
#define _player_methodmap_included
/*
 * Base CS:GO plugin requirements.
 */
#include <clientprefs>
#include <sourcemod>
#include <sdktools>
#include <cstrike>
methodmap Player {
    public 
Player(int client) {
        return 
view_as<Player>(client);
    }
    public 
void Invisible(bool invisible) {
        if (
invisible) {
            
SetEntityRenderMode(thatRENDER_NONE);
        } else {
            
SetEntityRenderMode(thatRENDER_NORMAL);
        }
    }

For brevity, a lot of code has been omitted. However, when compiled this code errors out with:

Code:
error 017: undefined symbol "RENDER_NONE"
error 017: undefined symbol "RENDER_NORMAL"
Other alternatives I've tried lead to differing issues. If I move "SetEntityRenderMode" to the main file, it works as expected. If I try to pass the value of "RENDER_NONE" and "RENDER_NORMAL" to the function as so:

PHP Code:
player.Invisible(trueRENDER_NONE);
...
public 
void Invisible(bool invisibleRenderMode render) { 
Then it complains that:

Code:
error 181: function argument named 'render' differs from prototype
And also that I'm passing the wrong arguments in the main code:

Code:
warning 213: tag mismatch
warning 213: tag mismatch
Any ideas on whats going so wrong? As far as I can see I'm including the same stuff in both files.
popey456963 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 03-10-2018 , 01:05   Re: Enum scoping
Reply With Quote #2

Your problem is somewhere else in your code. If you create two files with only the two snippets you gave (except defining that and level so it compiles), there's no error.

Last edited by Fyren; 03-10-2018 at 01:05.
Fyren is offline
popey456963
Member
Join Date: Mar 2016
Old 03-14-2018 , 18:50   Re: Enum scoping
Reply With Quote #3

Thanks for the response Fyren:

PHP Code:
#if !defined _player_methodmap_include
#define _player_methodmap_include

/*
 * Base CS:GO plugin requirements.
 */
#include <clientprefs>
#include <sourcemod>
#include <sdktools>
#include <cstrike>

methodmap Player {
    public 
Player(int client) {
        return 
view_as<Player>(client);
    }

    public 
void Invisible(bool invisible) {
        if (
invisible) {
            
SetEntityRenderMode(view_as<int>(this), RENDER_NONE); // RENDER_NONE
        
} else {
            
SetEntityRenderMode(view_as<int>(this), RENDER_NORMAL); // RENDER_NORMAL
        
}
    }
}

#endif 
I've tried to strip down the error to its base components, here we only include base SM plugins and I still get the error. How did you get it to compile? I'm currently using SM 1.8, 6041, if that makes any difference.
popey456963 is offline
popey456963
Member
Join Date: Mar 2016
Old 03-14-2018 , 19:08   Re: Enum scoping
Reply With Quote #4

Turns out I had a file called "helpers" in my include directory which was messing around with things.
popey456963 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 03-15-2018 , 10:26   Re: Enum scoping
Reply With Quote #5

Quote:
Originally Posted by popey456963 View Post
Turns out I had a file called "helpers" in my include directory which was messing around with things.
you mean something like this file: helpers.inc (though most likely for an older SM version)
__________________
WildCard65 is offline
popey456963
Member
Join Date: Mar 2016
Old 03-20-2018 , 18:56   Re: Enum scoping
Reply With Quote #6

Quote:
Originally Posted by WildCard65 View Post
you mean something like this file: helpers.inc (though most likely for an older SM version)
I mean a file that is named "helpers.inc" that is, unfortunately, not that file.
popey456963 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 10:09.


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