AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Enum scoping (https://forums.alliedmods.net/showthread.php?t=305915)

popey456963 03-09-2018 16:08

Enum scoping
 
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.

Fyren 03-10-2018 01:05

Re: Enum scoping
 
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.

popey456963 03-14-2018 18:50

Re: Enum scoping
 
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 03-14-2018 19:08

Re: Enum scoping
 
Turns out I had a file called "helpers" in my include directory which was messing around with things.

WildCard65 03-15-2018 10:26

Re: Enum scoping
 
Quote:

Originally Posted by popey456963 (Post 2583053)
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)

popey456963 03-20-2018 18:56

Re: Enum scoping
 
Quote:

Originally Posted by WildCard65 (Post 2583118)
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.


All times are GMT -4. The time now is 21:52.

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