• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

See anything wrong with this?

Status
Not open for further replies.
That's quite a lot of maxSendLimits you have there. You could actually (drastically) shorten the code into something like this:

JASS:
if (maxSendLimit[GetPlayerId(p)]+r_amount <= 2 && GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) > 0)    {
    maxSendLimit[GetPlayerId(p)] = maxSendLimit[GetPlayerId(p)] + r_amount;
    sender = ResourceSender.create(r_amount, p, r_player, PLAYER_STATE_RESOURCE_GOLD);
    sender.send();
    sender.destroy();
}

Using the index of the player directly as opposed to running a lot of conditions that would only achieve the same thing would be preferred.
For even more optimization, you can save it to a variable and reference that variable instead of manually getting the index of the player each time.
 
Last edited:
That's quite a lot of maxSendLimits you have there. You could actually (drastically) shorten the code into something like this:

JASS:
if (maxSendLimit[GetPlayerIndex(p)]+r_amount <= 2 && GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) > 0)    {
    maxSendLimit[GetPlayerIndex(p)] = maxSendLimit[GetPlayerIndex(p)] + r_amount;
    sender = ResourceSender.create(r_amount, p, r_player, PLAYER_STATE_RESOURCE_GOLD);
    sender.send();
    sender.destroy();
}

Using the index of the player directly as opposed to running a lot of conditions that would only achieve the same thing would be preferred.
For even more optimization, you can save it to a variable and reference that variable instead of manually getting the index of the player each time.
Ok thanks, I found the issue it was that when I was adding the maxSendLimit + r_amount I didn't index it properly for the other colors so they were werent adding it. I'll do what you said though.
 
Status
Not open for further replies.
Back
Top