Question about variables

Started by SA:MP, May 05, 2023, 08:51 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

SA:MP

Question about variables

Do I have to check if variable's value is different before setting it?



Example




Code:

new bool:IsSpawned[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
IsSpawned[playerid] = true;
return 1;
}

or




Code:

new bool:IsSpawned[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
if(IsSpawned[playerid] != true)
{
IsSpawned[playerid] = true;
}
return 1;
}

Which way is better? Or is there no difference?

Source: Question about variables