02.06.2016, 00:35
Hi,
I shall explain what I have so far, and maybe someone can help me with my error now.
I have an include file called OnPlayerConnect.pwn:
And I also have a user.pwn, which is an include for stuff related to a user. In here I call OnPlayerConnect:
I have then included both of these files into my main gamemode. If however, I try to use OnPlayerConnect callback in a different include or in my main gamemode, I get the following error:
So yeah, clearly Im doing something wrong. Any ideas? DOnt know if any of what I said makes sense to anyone. I wont lie, I'm brand new to hooking
I shall explain what I have so far, and maybe someone can help me with my error now.
I have an include file called OnPlayerConnect.pwn:
Код:
public OnPlayerConnect(playerid){
//To create a callback, we use CallLocalFunction. For more explanation about CallLocalFunction, go to wiki.sa-mp.com/wiki/CallLocalFunction
CallLocalFunction("L_OnPlayerConnect", "i", playerid);
return 1;
}
#if defined _ALS_OnPlayerConnect //If _ALS_OnPlayerConnect is defined:
#undef OnPlayerConnect //If defined, it will undefine OnPlayerConnect.
#else //Else if not:
#define _ALS_OnPlayerConnect //If not, we'll define _ALS_OnPlayerConnect.
#endif //As we started a PAWN function '#if', it's necessary to use #endif or you'll get troubled.
//As the callback 'OnPlayerConnect' is undefined now, we can define it to whatever but here we are hooking it. So define it to our callback created, 'L_OnPlayerSConnect'.
#define OnPlayerConnect L_OnPlayerConnect
//Even though we hooked it, we must forward the callback too inorder to get it used.
forward L_OnPlayerSpawn(playerid, weaponid); //We must forward the callback which created itself.
Код:
forward OnPlayerConnect(playerid);
public OnPlayerConnect(playerid){
//On connect, check if username exists in database
TogglePlayerSpectating(playerid, true);
new query[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
mysql_format(mysql, query, sizeof(query), "SELECT `id`, `username`, `password` FROM `user` WHERE `username` = '%e' LIMIT 1;", playername);
mysql_tquery(mysql, query, "OnUserCheck", "i", playerid);
return 1;
}
Код:
error 021: symbol already defined: "L_OnPlayerConnect"

