SA-MP Forums Archive
YSI\y_hooks doesn`t work. - 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: YSI\y_hooks doesn`t work. (/showthread.php?tid=659072)



YSI\y_hooks doesn`t work. - Weline - 22.09.2018

Hi, everyone, I've got a simple pawno file with this code:
Код:
hook OnPlayerConnect(playerid) {
	GetPlayerName(playerid, names[playerid], MAX_PLAYER_NAME);
	if(!_HasPlayedBefore(playerid)) {
		// registration
	} else {
		// login
	}
	return SUCCESS;
}
The compiler says everything is correct, unless the y_hooks unique name:
Quote:

player.pwn:150 (error) symbol already defined: "@yH_OnPlayerConnect@005"

And it is weird that there isn't public's with name "OnPlayerConnect", there isn't even any hook, with the same type.
I've also got an #if !defined check. Though it still doesn't work.
And I don't know how to fix it. Any ideas?


Re: YSI\y_hooks doesn`t work. - VVWVV - 22.09.2018

Did you write this function in the same file?


Re: YSI\y_hooks doesn`t work. - Weline - 22.09.2018

Quote:
Originally Posted by VVWVV
Посмотреть сообщение
Did you write this function in the same file?
Not even sure, what do you mean. But I've got two main files, gamemode.pwn (contains OnGameModeInit hook that just disables stunt bonuses, default pickups etc) and players.pwn file. I've got only one OnPlayerConnect hook in player.pwn. So there is no reason for two functions have same name.


Re: YSI\y_hooks doesn`t work. - VVWVV - 22.09.2018

Hm... Try to include the library before the function definition.

pawn Код:
#include <YSI\y_hooks>
hook OnPlayerConnect(playerid)
{
    // code..
}



Re: YSI\y_hooks doesn`t work. - Weline - 22.09.2018

Quote:
Originally Posted by VVWVV
Посмотреть сообщение
Hm... Try to include the library before the function definition.

pawn Код:
#include <YSI\y_hooks>
hook OnPlayerConnect(playerid)
{
    // code..
}
I don't know how, but it works now, thanks a lot!


Re: YSI\y_hooks doesn`t work. - VVWVV - 22.09.2018

Quote:
Originally Posted by Weline
Посмотреть сообщение
I don't know how, but it works now, thanks a lot!
The library updates the unique number for all functions when you include it again.