View Single Post
psychonic

BAFFLED
Join Date: May 2008
Old 04-20-2015 , 06:52   Re: SourceMod 1.7.1 Released
#11

Quote:
Originally Posted by Electr000999 View Post
i am put line "#pragma newdecls required" after include's and after experiments get error..
  • why we cannot create custom native with type not a int type, may be beacuse by this in .inc files
    Code:
    native CreateNative(const String:name[], NativeCall:func); 
    typedef NativeCall = function int (Handle plugin, int numParams)
    for example how get error
    Code:
    error 100: function prototypes do not match
    example code:
    Code:
    #include <sourcemod>
    
    #pragma    semicolon 1
    #pragma newdecls required
    
    public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
    {
         CreateNative("TestNative", _TestNative);
         return APLRes_Success;
    }
    
    public bool _TestNative(Handle plugin, int numParams)
    {
        return GetSpawnAccess();  
    }
    
    bool GetSpawnAccess()
    {
       return true;
    }
For now, you must just retag the return value. return view_as<int>(true);

Note that this is nothing new, other than the transitional syntax for retagging. Before, it would have been return _:true; (which is still valid now).

Quote:
Originally Posted by Electr000999 View Post
  • line public void OnEntityCreated(int entity, const char[] classname) get error:
    Code:
    error 180: function return type differs from prototype. expected 'int', but got 'void'
    example code:
    Code:
    #include <sourcemod>
    #include <sdkhooks>
    
    #pragma    semicolon 1
    #pragma newdecls required
    
    public void OnEntityCreated(int entity, const char[] classname)
    {
        if (IsServerProcessing())
        {                
            
        }
    }
    in sdkhooks.inc
    Code:
    /**
     * @brief When an entity is created
     *
     * @param        entity        Entity index
     * @param        classname    Class name
     */
    forward void OnEntityCreated(int entity, const char[] classname);
I think that you are compiling against old include files.

Last edited by psychonic; 04-20-2015 at 07:30.
psychonic is offline