SA-MP Forums Archive
OnPlayerUpdate Already defined - 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: OnPlayerUpdate Already defined (/showthread.php?tid=577410)



OnPlayerUpdate Already defined - KillerDVX - 11.06.2015

Hello guys,

I have a problem,

So, the fact is I use OnPLayerUpdate in an include,

So when i define it in the Gamemode as well,

It shows : "OnPlayerUpdate Already defined"

So what should i do ? I can't delete the include..

Can i have an other name of OnPlayerUpdate with same abilities?


Re: OnPlayerUpdate Already defined - shourya12 - 11.06.2015

remove it from either of them.

I recommend to remove it from include


Re: OnPlayerUpdate Already defined - Konstantinos - 11.06.2015

Callbacks and functions need to be hooked in includes.

An example:
pawn Код:
public OnPlayerUpdate(playerid)
{
    // code..

    #if defined HC_OnPlayerUpdate
        return HC_OnPlayerUpdate(playerid);
    #else
        return 1;
    #endif
}

#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
 
#define OnPlayerUpdate HC_OnPlayerUpdate
#if defined HC_OnPlayerUpdate
    forward HC_OnPlayerUpdate(playerid);
#endif
Quote:
Originally Posted by shourya12
Посмотреть сообщение
remove it from either of them.

I recommend to remove it from include
No reason to do that.


Re : OnPlayerUpdate Already defined - KillerDVX - 11.06.2015

C:\Users\acer\Desktop\MAJ CRTFC2 - Copie\gamemodes\GMRPGV1.0.pwn(1606) : error 021: symbol already defined: "HC_OnPlayerUpdate"

?


Re: OnPlayerUpdate Already defined - Konstantinos - 11.06.2015

Only once in the include file, not in the gamemode too.


Re : OnPlayerUpdate Already defined - KillerDVX - 11.06.2015

This what i did in the include :

PHP код:
/*    =============================
    Limex's Swimming Include
    
    Made by Limex / A
    
    New function:
    IsPlayerSwimming(playerid)
    
    New callbacks:
    OnPlayerStartSwimming(playerid)
    OnPlayerStopSwimming(playerid)
    
    Enjoy!
    
    ============================= */
#include <a_samp>
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
 
#define OnPlayerUpdate HC_OnPlayerUpdate
#if defined HC_OnPlayerUpdate
    
forward HC_OnPlayerUpdate(playerid);
#endif
new bool:swimming[MAX_PLAYERS];
forward OnPlayerStartSwimming(playerid);
forward OnPlayerStopSwimming(playerid);
forward IsPlayerSwimming(playerid);
#define PUBLIC:%0(%1)                          forward %0(%1); \
                                            
public %0(%1)
public 
IsPlayerSwimming(playerid)
{
    if(
swimming[playerid]) return 1;
    return 
0;
}
PUBLIC:
OnPlayerUpdate(playerid)
{
    if(
GetPlayerAnimationIndex(playerid))
    {
        new 
animlib[32];
        new 
animname[32];
        
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        if(
strcmp(animlib"SWIM"true) == && !swimming[playerid])
        {
            
swimming[playerid] = true;
            
OnPlayerStartSwimming(playerid);
        }
        else if(
strcmp(animlib"SWIM"true) != && swimming[playerid] && strfind(animname"jump"true) == -1)
        {
            
swimming[playerid] = false;
            
OnPlayerStopSwimming(playerid);
        }
    }
    else if(
swimming[playerid])
    {
        
swimming[playerid] = false;
        
OnPlayerStopSwimming(playerid);
    }
    
#if defined HC_OnPlayerUpdate
        
return HC_OnPlayerUpdate(playerid);
    
#else
        
return 1;
    
#endif




Re: OnPlayerUpdate Already defined - Konstantinos - 11.06.2015

Use it exactly as I showed you. ALS must be AFTER the callback not before.


Re : OnPlayerUpdate Already defined - KillerDVX - 11.06.2015

Could you write me correct my code please ?


Re : OnPlayerUpdate Already defined - KillerDVX - 11.06.2015

Resolved !

Thanks anyway.