Diferencias: static - new.
#6

En mi caso suelo usar variables static para string como en el ejemplo que ha dejado LatinZ, pero hay que tener mucho cuidado porque podrнa dar lugar a errores.

Ejemplo:
Код:
stock PlayerName(playerid)
{
    static playername[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, playername, sizeof(MAX_PLAYER_NAME));
    return playername;
}

stock Test()
{
    printf("%s %s", PlayerName(0), PlayerName(1));
}

// playerid 0 = Pepito
// playerid 1 = Jaimito
El resultado serнa:
Код:
Jaimito Jaimito
En variables globales sуlo tiene sentido usarlo en includes para que las variables y funciones no entren en conflicto con otras variables con el mismo nombre (como comente arriba).
Reply


Messages In This Thread
Diferencias: static - new. - by Unrea1 - 15.09.2015, 09:42
Respuesta: Diferencias: static - new. - by oOFotherOo - 15.09.2015, 14:50
Re: Diferencias: static - new. - by admantis - 15.09.2015, 15:08
Respuesta: Diferencias: static - new. - by bm0z - 15.09.2015, 17:31
Re: Diferencias: static - new. - by MaRcOsWeB - 15.09.2015, 19:54
Respuesta: Diferencias: static - new. - by bm0z - 15.09.2015, 21:42
Re: Diferencias: static - new. - by Unrea1 - 15.09.2015, 22:53
Respuesta: Diferencias: static - new. - by bm0z - 15.09.2015, 23:03
Re: Diferencias: static - new. - by Unrea1 - 15.09.2015, 23:14
Re: Diferencias: static - new. - by MaRcOsWeB - 15.09.2015, 23:26

Forum Jump:


Users browsing this thread: 2 Guest(s)