Events with "player array" instead of playerid
#1

Hello, I haven't used Pawn in a very long time so unfortunately I've forgotten a lot of things.
I was wondering whether it's a bad idea to code like this:


Instead of having a playerid as a parameter, like this

PHP код:
enum e_pvars Name[MAX_PLAYER_NAME] };
new 
PlayerVars[MAX_PLAYERS][e_pvars];
public 
OnPlayerConnect(playerid// like this
{
 
    new 
name[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridnamesizeof(name));
    
SendClientMessageToAll(YELLOWname);
 
    return 
1;

I create a new event that uses a player array containing information about that player, like this



PHP код:
New_OnplayerConnect(Player[]) // like this
{
    
SendClientMessageToAll(YELLOWPlayer[Name]);
}
public 
OnPlayerConnect(playerid)
{
    
GetPlayerName(playeridPlayerVars[playerid][Name], MAX_PLAYER_NAME);
    
New_OnplayerConnect(PlayerVars[playerid]);
    return 
1;

What are the disadvantages of doing that?
Reply
#2

I think u make the script a little slower, because you call a lower function that calls the main function.
Why not using the principal function?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
And you will need to collate and pass around all that data, even if you never use it.
I thought arrays are always passed by reference? Does it really affect the performance in a scenerio where those PlayerVars are going to be used anyway?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)