Jump to content
Rosso777

(SOLVED) Random Event: "Drop Radio" script

Recommended Posts

SOLVED!

 

Every 60 seconds, there is a chance for player to drop their radio (and lose it):

 

Place this script inside the initPlayerLocal.sqf file: (tested on dedicated server)

 

[] spawn {
  while {"ItemRadio" in assignedItems player} do {

        dropRadioChance = random 1;
        if (dropRadioChance > 0.01) then {

            player unlinkItem "ItemRadio";
        };
    };
    sleep 60;
};

 

 

// ORIGINAL POST //

 

In my quest for scripting greatness, I am trying to setup a very simple script that creates a random occurrence-- the player drops their radio (for testing purposes, it's a 25% chance every 60 seconds). This is the most sensical way I could put it together, but it won't activate for some reason (No hint, no radio removal). Can anyone see why this won't go?

 

(This script is in initPlayerLocal.sqf on a dedi server)

 


[] spawn {
  while {"ItemRadio" in assignedItems player} do {

        dropRadioChance = random 1;
        if (dropRadioChance > 0.75) then {

            _unit removeItem "ItemRadio";
            hint "You just realized you dropped your radio somewhere..."
        }

      waitUntil {
            sleep 60;
        };
    }
};

 

 

Share this post


Link to post
Share on other sites

Update: Some slight progress:

 

Using the command "unassignItem" I have been able to remove the item from the toolbelt, but it goes straight into the player's inventory. Now I just need to figure out how to remove the item completely.

 

[] spawn {
  while {"ItemRadio" in assignedItems player} do {

        dropRadioChance = random 1;
        if (dropRadioChance > 0.75) then {

            _unit unassignItem "ItemRadio";
            hint "You just realized you dropped your radio somewhere..."
        }

      waitUntil {
            sleep 60;
        };
    }
};

Share this post


Link to post
Share on other sites
15 minutes ago, Rosso777 said:

Using the command "unassignItem" I have been able to remove the item from the toolbelt, but it goes straight into the player's inventory. Now I just need to figure out how to remove the item completely.

 

I think https://community.bistudio.com/wiki/unlinkItem destroys the item 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×