Thread: Enum scoping
View Single Post
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