Closed Vasily-X closed 6 years ago
Hello!
So, you are declaring an array with one extra empty slot to be a blueprint for each freshly connected user. So, first, to get rid of the index mismatch:
memcpy(PlayerCore[playerid][E_PLAYER_CORE:0], PlayerCore[MAX_PLAYERS][E_PLAYER_CORE:0], 0, MAX_PLAYERS * 4, MAX_PLAYERS);
I'm a litle rusty here, but basically the function expects one dimensional array, and the enumerated array is a bit of a different beast. So that's what I usually do to make it work.
Now, with that dealt with, I think you've made a mistake. You want to copy one "slot" of the PlayerCore. However, you are copying "MAX_PLAYER" bytes - that's not what you want in this case. This will override next slots and will cause mayhem. You need to copy "size of the enum" * 4 bytes. Luckily, the enum identifier provides its size! Just remember to override the tag to "tagless", or there'll be more compiler warnings. So:
memcpy(PlayerCore[playerid][E_PLAYER_CORE:0], PlayerCore[MAX_PLAYERS][E_PLAYER_CORE:0], 0, _:E_PLAYER_CORE * 4, _:E_PLAYER_CORE);
@Misiur you're totally right. I'll go your way now, looks much cleaner.
It compiles fine, thanks for checking this out.
Seems this code generates warnings:
I get two warnings from the
memcpy
function:If I'm not wrong the macros add tags to the arrays but I don't understand them at all. If I user
Player.Core[playerid]
instead it generates an error:error 017: undefined symbol "Player@Core"
Any idea about how to avoid this? Thank you.