Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Spawning Item Randomly
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: Spawning Item Randomly

Within your OnStart function, add the AddUseItemCallback, which will trigger an event when you use a certain item on a certain object.

PHP Code: (Select All)
AddUseItemCallback("internal_name""item_name""entity_to_use_item_on""YourCustomFunction"true); 

Here the arguments mean:
1. Internal name for this callback.
2. The name of the inventory item you want to link.
3. The name of the entity in your level you want to link.
4. The custom function name (which must match the name below).
5. Whether this event can trigger only once.

Then you need the callback function with your custom function name (outside the OnStart function), like so:

PHP Code: (Select All)
void YourCustomFunction(string &in asItemstring &in asEntity)
{
    
//Code in here will trigger when you use the item on the entity.
    
SetEntityActive("enemy_name"true); 
    
//This will enable the entity with the given name, for example an enemy. 
    //Make sure the enemy is set to "Inactive" in the level.


(This post was last modified: 04-08-2018, 04:58 PM by Mudbill.)
04-08-2018, 04:57 PM
Find


Messages In This Thread
Spawning Item Randomly - by Organic Shelter - 04-01-2018, 08:22 AM
RE: Item Spawns Randomly - by Romulator - 04-01-2018, 04:04 PM
RE: Item Spawns Randomly - by Organic Shelter - 04-05-2018, 12:33 PM
RE: Item Spawns Randomly - by Romulator - 04-05-2018, 01:00 PM
RE: Item Spawns Randomly - by Mudbill - 04-05-2018, 09:18 PM
RE: Item Spawns Randomly - by Organic Shelter - 04-06-2018, 12:50 PM
RE: Spawning Item Randomly - by Mudbill - 04-06-2018, 10:12 PM
RE: Spawning Item Randomly - by Organic Shelter - 04-08-2018, 05:03 AM
RE: Spawning Item Randomly - by Mudbill - 04-08-2018, 04:57 PM



Users browsing this thread: 4 Guest(s)