From 2973a3772fb0f14b37b51468fdbca753709741d5 Mon Sep 17 00:00:00 2001 From: Karolis Kraujelis Date: Tue, 31 Jul 2018 03:47:34 +0300 Subject: [PATCH] Added CallFor and InvokeFor templated functions --- Pools.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Pools.hpp b/Pools.hpp index ac5c631..27c2c36 100644 --- a/Pools.hpp +++ b/Pools.hpp @@ -66,6 +66,20 @@ namespace rage } } + template + void CallFor(std::vector const& players, const std::string& eventName, Args&&... args) + { + const int count = sizeof...(Args); + + if (count == 0) + this->_CallFor(players, eventName); + else + { + arg_t arguments[count] = { arg_t(std::forward(args))... }; + this->_CallFor(players, eventName, arguments, count); + } + } + template void Invoke(uint64_t hash, Args&&... args) { @@ -107,6 +121,20 @@ namespace rage this->_InvokeInDimension(dimension, hash, arguments, count); } } + + template + void InvokeFor(std::vector const& players, uint64_t hash, Args&&... args) + { + const int count = sizeof...(Args); + + if (count == 0) + this->_InvokeFor(players, hash); + else + { + arg_t arguments[count] = { arg_t(std::forward(args))... }; + this->_InvokeFor(players, hash, arguments, count); + } + } }; class IVehiclePool