Include filterscript problem
#1

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 021symbol already defined"OnPlayerConnect" 
Yeah I know why this error occured.
Reply
#2

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
Reply
#3

Quote:
Originally Posted by Gammix
Посмотреть сообщение
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
Which do you prefer? y_hook or ALS?
Reply
#4

Im sorry but is this what you mean? LINK
Sorry because Im new with hook method
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)