22.05.2015, 12:53
Quote:
In that specific example, both versions are equally horrible. Functions can have parameters. Use them.
Global variables are evil. Avoid whenever possible. |
Код:
///////1st example new Msg[128]; public OnPlayerConnect(playerid) { format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); return 1; } public OnPlayerDisconnect(playerid, reason) { format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); return 1; } and some other callbacks
Код:
///////2nd example public OnPlayerConnect(playerid) { new Msg[128]; format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); return 1; } public OnPlayerDisconnect(playerid, reason) { new Msg[128]; format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); return 1; } and some other callbacks with same variables inside: new Msg[128]...