Include filterscript 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: Include filterscript problem (
/showthread.php?tid=593476)
Include filterscript problem -
Sh4d0w2 - 06.11.2015
Is there any way to fix this problem? Its like I used to include another filterscript in filterscript like this :
PHP код:
#include "../filterscripts/map.pwn""
In that Include I already defined the Public OnPlayerConnect.But in the filterscript,I want to define Public OnPlayerConnect again so If I put the codes under it the both filterscript code will added together under Public OnPlayerConnect.Is there any way to do this? BTW I got this error :
PHP код:
error 021: symbol already defined: "OnPlayerConnect"
Yeah I know why this error occured.
Re: Include filterscript problem -
Gammix - 06.11.2015
You cannot use publics twice, i meant you need to hook the other one in order to use it twice.
https://sampforum.blast.hk/showthread.php?tid=570910
Re: Include filterscript problem -
Sh4d0w2 - 06.11.2015
Quote:
Originally Posted by Gammix
|
Which do you prefer? y_hook or ALS?
Re: Include filterscript problem -
Sh4d0w2 - 06.11.2015
Im sorry but is this what you mean?
LINK
Sorry because Im new with hook method
Re: Include filterscript problem -
Gammix - 06.11.2015
No, the link i gave is what i meant. Read it and you will understand.
You need to hook the callback (OnPlayerConnect), like this:
pawn Код:
public OnPlayerConnect(playerid)
{
#if defined MyLib_OnPlayerConnect
MyLib_OnPlayerConnect(playerid);
#endif
return 1;
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect MyLib_OnPlayerConnect
#if defined MyLib_OnPlayerConnect
forward MyLib_OnPlayerConnect(playerid);
#endif
Note, MyLib should not coincide with other hooked callbacks. You can name your hook to anything (e.g.: MyLib_OPC)
Also, You can leave one callback without hooking it. Because thats the original purpose of hooking.
Here is what you have to do:
In your file
#include "../filterscripts/map.pwn"
Check where OnPlayerConnect is and hook it like this:
pawn Код:
public OnPlayerConnect(playerid)
{
//your code here
#if defined MyLib_OnPlayerConnect
MyLib_OnPlayerConnect(playerid);
#endif
return 1;
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect MyLib_OnPlayerConnect
#if defined MyLib_OnPlayerConnect
forward MyLib_OnPlayerConnect(playerid);
#endif