SA-MP Forums Archive
y_hooks problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: y_hooks problem (/showthread.php?tid=656739)



y_hooks problem - ShoortyFl - 22.07.2018

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?


Re: y_hooks problem - Calisthenics - 22.07.2018

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


Re: y_hooks problem - ShoortyFl - 22.07.2018

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"


Re: y_hooks problem - JasonRiggs - 22.07.2018

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

PHP код:
hook public OnGameModeInit 



Re: y_hooks problem - Calisthenics - 22.07.2018

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.


Re: y_hooks problem - J0sh... - 22.07.2018

y_hooks should be included last.


Re: y_hooks problem - DBZdabIt3Bro7 - 22.07.2018

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. :)


Re: y_hooks problem - JasonRiggs - 23.07.2018

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.


Re: y_hooks problem - ShoortyFl - 23.07.2018

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.


Re: y_hooks problem - ShoortyFl - 23.07.2018

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.