///////1st example new Msg[128]; function1() { format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); } function2() { format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); } function3() { format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); }
///////2nd example function1() { new Msg[128]; format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); } function2() { new Msg[128]; format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); } function3() { new Msg[128]; format(Msg, 128, "Some Text"); SendClientMessageToAll(0x00FF00FF, Msg); }
In that specific example, both versions are equally horrible. Functions can have parameters. Use them.
Global variables are evil. Avoid whenever possible. |
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]...
public OnPlayerConnect(playerid)
{
SendClientMessageToAll(0x00FF00FF, "Some Text");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SendClientMessageToAll(0x00FF00FF, "Some Text");
return 1;
}
Third:
pawn Код:
|
format(Msg, 128, "Player name %s VIP %s", Name, VIPNivoName[Level]);
are you sure? Or can anyone other confirm that, because I've large gamemode I don't want to make something that will bug wil gamemode
Edit: but if I use Код:
format(Msg, 128, "Player name %s VIP %s", Name, VIPNivoName[Level]); |
public OnPlayerConnect(playerid)
{
new string[50];
format(string, sizeof(string), "Player name %s VIP %s", Name, VIPNivoName[Level]);
SendClientMessageToAll(0x00FF00FF, string);
return 1;
}