number % 65521;
// below defines new gString[128];
// in function new String[128];
new gString[128]; MyFunction(playerid) { format(gString, sizeof gString, "ID: %d", playerid); // It can be used here SendClientMessage(playerid, -1, gString); return 1; } // But also here MyFunction2(playerid) { gString[0] = EOS; return 1; }
MyFunction(playerid) { new gString[128]; format(gString, sizeof gString, "ID: %d", playerid); SendClientMessage(playerid, -1, gString); // It can be used here return 1; } // But not here - error: undefined symbol gString MyFunction2(playerid) { gString[0] = EOS; // Undefined symbol gString return 1; }
MyFunction(playerid) { // I must get it here return 1; } MyFunction2(playerid) { // And here! return 1; }
MyFunction(playerid) { new gString[128]; // Using my variable return 1; } MyFunction2(playerid) { new gString[128]; // New variable! OMG! // Using my variable again return 1; }
Variable before function is global variable. It's mean that it can be used everywhere.
Variable in function is local variable. It's mean that it can be used only in this function. |
Variable before function is global variable. It's mean that it can be used everywhere.
Variable in function is local variable. It's mean that it can be used only in this function. Example for global: Код:
new gString[128]; MyFunction(playerid) { format(gString, sizeof gString, "ID: %d", playerid); // It can be used here SendClientMessage(playerid, -1, gString); return 1; } // But also here MyFunction2(playerid) { gString[0] = EOS; return 1; } Код:
MyFunction(playerid) { new gString[128]; format(gString, sizeof gString, "ID: %d", playerid); SendClientMessage(playerid, -1, gString); // It can be used here return 1; } // But not here - error: undefined symbol gString MyFunction2(playerid) { gString[0] = EOS; // Undefined symbol gString return 1; } Код:
MyFunction(playerid) { // I must get it here return 1; } MyFunction2(playerid) { // And here! return 1; } Код:
MyFunction(playerid) { new gString[128]; // Using my variable return 1; } MyFunction2(playerid) { new gString[128]; // New variable! OMG! // Using my variable again return 1; } |
number % 65521;
if(number == 65521 && number == 65521 * 2 /* and go one, and go one */)