Strcmp
#9

Quote:
Originally Posted by Cowboy
Посмотреть сообщение
Silly me! It does work with existing names, but not the new created gangs. How would I be able to store the new gang name into that enum in gangcreate command?

Edit: Tried something like this but it does not work:

pawn Код:
GangInfo[GetGangID + 1][gName] = GangName;
You could do something like this:
pawn Код:
for(new i; i < sizeof(GangInfo); i++)
{
     if(!strlen(GangInfo[i][gName])) //If it's empty (not used)
     {
          format(GangInfo[i][gName], MAX_GANG_NAME, TheVariableToStore); //Put the name in the variable that is empty.
          break; //Exit the loop, it's no longer needed
     }
}
It would be more efficient to create a variable and store in it the last used array slot, that way everytime a gang is created, you can just put the gane name in the slot contained in the variable, and then increment the variable containing the last array slot pointer.

Edit: Just taken a look at your loop in your original post. You should use 'sizeof(GangInfo)' (or a size definition) rather than the actual GangInfo[i][gName] identifier in your loop header. (Take a look at my example above)
Reply


Messages In This Thread
Strcmp - by Cowboy - 24.12.2011, 12:02
Re: Strcmp - by Calgon - 24.12.2011, 12:04
Re: Strcmp - by Cowboy - 24.12.2011, 12:10
Re: Strcmp - by Thresholdold - 24.12.2011, 12:13
Re: Strcmp - by Cowboy - 24.12.2011, 12:17
Re: Strcmp - by Ash. - 24.12.2011, 12:20
Re: Strcmp - by Ballu Miaa - 24.12.2011, 12:22
Re: Strcmp - by Cowboy - 24.12.2011, 12:27
Re: Strcmp - by Ash. - 24.12.2011, 12:34
Re: Strcmp - by Cowboy - 24.12.2011, 12:38

Forum Jump:


Users browsing this thread: 1 Guest(s)