Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Xindage

ACS - How to give item to everyone except the activator

Question

Like the title says i want to when someone activate a certain script make everyone in game whit him to gain a certain item, except who activated the script, how i can do it, i never tried do this kind of acs, so i have no idea.

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

By "everyone in the game", you mean every player, right? Not the random imps or chandeliers or whatever other non-player actors are out there.

 

A possibility would be to use PlayerNumber to find out which player activated the script, and then loop through the players, skipping over the activator, and giving them the item.

 

// Kind of a kludge
int PlayerArray[8] = { AAPTR_PLAYER1, AAPTR_PLAYER2, AAPTR_PLAYER3, AAPTR_PLAYER4, AAPTR_PLAYER5, AAPTR_PLAYER6, AAPTR_PLAYER7, AAPTR_PLAYER8 };

script "Example" (void)
{
    // Find the activating player; and make sure it's a valid player -- if not, then abort right now
    int activr = PlayerNumber();
    if (activr < 0 || activr > 8) terminate;
    
    // Loop through all possible players
    for (int i = 0; i < 8; ++i)
    {
        // Skip the original activator
        if (i != activr)
        {
            // We need to set the activator to the various players, because GiveInventory works on the activator
            SetActivator (0, PlayerArray[i]);
            GiveInventory("my_item", 1);
        }
    }
    // Optional, reset the activator to the original player, if desired or needed for other things this script should do
    SetActivator(0, PlayerArray[activr]);
}

Something kinda like that might work. You may want to check the return value of SetActivator, too. Perhaps something like this instead:

       // Skip the original activator and non-existing players
        if (i != activr && SetActivator (0, PlayerArray[i]))
        {
            GiveInventory("my_item", 1);
        }

 

Share this post


Link to post
  • 1
Posted (edited)

Maybe A_RadiusGive would be the thing to use. Quoted from that page:

Quote

Note that for very large distances, attempting to give to specific things map-wide may fail. A good range for the entirety of the map would be 16383. A dummy actor can warp to (0,0,0) coordinates to ensure the radius does not overflow from being too close to the map boundaries. Experimentation may be required.

You would want to include RGF_PLAYERS in the flags, and not RGF_GIVESELF.

Share this post


Link to post
  • 0

You might give the item to everybody and then immediately take it away from the activator.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×