y_hooks problem
#1

Hello!
I have a problem with y_hooks, it says that

pawn Код:
(error) symbol already defined: "@yH_OnGameModeInit@003"
This is how my gamemode is now, basically blank

main

pawn Код:
#include "a_samp.inc"
#include "YSI_Coding\y_hooks.inc"
#include "a_mysql.inc"
#include "YSI_Coding\y_timers.inc"

#include "modules/core/connect.pwn"
#include "modules/core/init.pwn"

main()
{
}

public OnGameModeInit()
{
    return true;
}
connect.pwn

pawn Код:
#include "YSI_Coding\y_hooks.inc"
#define SQL_HOST                "localhost"
#define SQL_USERNAME            "root"
#define SQL_PASSWORD            ""
#define SQL_DATABASE            "test"

new MySQL:handle;

hook OnGameModeInit()
{
    mysql_log(ALL);
    handle = mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD, SQL_DATABASE); // connect and check for cnnectiviti ->
    if(mysql_errno(handle) != 0 || handle == MYSQL_INVALID_HANDLE) // shutdown server if conn not established ->
    {
        print("[CONNECTION] Mysql connection not established; Shuting down the server!");
        SendRconCommand("exit");
        return true;
    }
    return true;
}
init.pwn

pawn Код:
#include "YSI_Coding\y_hooks.inc"

hook OnGameModeInit()
{
    SetGameModeText("Test");
    return true;
}
What could be causing this problem? What did I do wrong?
Reply
#2

If you don't use OnGameModeInit in main, remove it. If you really need to use it there, try including y_hooks last.
Reply
#3

It doesn't matter. If i remove it from main and compile it i still get the same error

\gamemodes\modules\core\init.pwn:4 (error) symbol already defined: "@yH_OnGameModeInit@003"
Reply
#4

As far as I'm concerned that Y_hooks are used like that..

PHP код:
hook public OnGameModeInit 
Reply
#5

I just tried to compile it and it didn't give any warnings/errors. Try updating YSI to latest version and see if the problem persists.
Reply
#6

y_hooks should be included last.
Reply
#7

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
As far as I'm concerned that Y_hooks are used like that..

PHP код:
hook public OnGameModeInit 
and as far as i am cOnCeRnEd, you don''t know what ur talking about. :)
Reply
#8

Quote:
Originally Posted by DBZdabIt3Bro7
Посмотреть сообщение
and as far as i am cOnCeRnEd, you don''t know what ur talking about.
uh what? and u do ye? What a cute bump.
Reply
#9

So basically like this:

main

pawn Код:
#include "a_samp.inc"
#include "a_mysql.inc"
#include "YSI_Coding\y_timers.inc"

#include "modules/core/connect.pwn"
#include "modules/core/init.pwn"

#include "YSI_Coding\y_hooks.inc"
and in connect

pawn Код:
#define SQL_HOST                "localhost"
#define SQL_USERNAME            "root"
#define SQL_PASSWORD            ""
#define SQL_DATABASE            "test"

new MySQL:handle;

hook OnGameModeInit()
{
    mysql_log(ALL);
    handle = mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD, SQL_DATABASE); // connect and check for cnnectiviti ->
    if(mysql_errno(handle) != 0 || handle == MYSQL_INVALID_HANDLE) // shutdown server if conn not established ->
    {
        print("[CONNECTION] Mysql connection not established; Shuting down the server!");
        SendRconCommand("exit");
        return true;
    }
    return true;
}

#include "YSI_Coding\y_hooks.inc"
But why does it have to be last included in main and connection but in init it can be first? I don't understand.
Reply
#10

I understand, but correct me if I'm wrong, thats what i did here, this is the complete gamemode:

main:

pawn Код:
#include "a_samp.inc"
#include "a_mysql.inc"
#include "YSI_Coding\y_timers.inc"

#include "modules/core/connect.pwn"
#include "modules/core/init.pwn"

#include "YSI_Coding\y_hooks.inc"

main()
{

}

public OnGameModeInit()
{
    return true;
}
modules/core/connect.pwn

pawn Код:
#include "YSI_Coding\y_hooks.inc"

#define SQL_HOST                "localhost"
#define SQL_USERNAME            "root"
#define SQL_PASSWORD            ""
#define SQL_DATABASE            "test"

new MySQL:handle;

hook OnGameModeInit()
{
    mysql_log(ALL);
    handle = mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD, SQL_DATABASE); // connect and check for cnnectiviti ->
    if(mysql_errno(handle) != 0 || handle == MYSQL_INVALID_HANDLE) // shutdown server if conn not established ->
    {
        print("[CONNECTION] Mysql connection not established; Shuting down the server!");
        SendRconCommand("exit");
        return true;
    }
    return true;
}
modules/core/init.pwn

pawn Код:
#include "YSI_Coding\y_hooks.inc"

hook OnGameModeInit()
{
    SetGameModeText("Test");
    return true;
}
Still getting this error:

\gamemodes\modules\core\init.pwn:4 (error) symbol already defined: "@yH_OnGameModeInit@003"

I'm using sampctl but I guess that has nothing to do with the issue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)