OnPlayerUpdate Already defined
#1

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?
Reply
#2

remove it from either of them.

I recommend to remove it from include
Reply
#3

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.
Reply
#4

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

?
Reply
#5

Only once in the include file, not in the gamemode too.
Reply
#6

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

Reply
#7

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

Could you write me correct my code please ?
Reply
#9

Resolved !

Thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)