Quote:
Originally Posted by Maxximou5
It would depend on the use case, you could be using a repeat timer. Though for the instance you are probably mentioning, it would be a one time with an immediate response. That would be a great use of RequestFrame as it's that's what it should be used for. Though, I would say it would better to have a complete example, along with the newest method of usage. Such as -
PHP Code:
#include <cstrike>
public void OnPluginStart() { HookEvent("player_connect_full", Event_PlayerConnectFull); }
public void Event_PlayerConnectFull(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(event.GetInt("userid")); RequestFrame(Frame_ChangeTeam, client); }
public void Frame_ChangeTeam(any client) { ChangeClientTeam(client, CS_TEAM_NONE) }
It should be mentioned that there are scenarios were RequestFrame and using a timer delay are different enough that something such as when a player is spawning and not creating a delay will cause a function to not work. Case scenarios I believe exist, like equipping a weapon, dropping a weapon, or cycling and stripping certain weapons, are such examples.
Of course, correct me if I am wrong, but this was such issues I had awhile ago.
|
Yes, you're right, that would be a correct case, as you said, sometimes you have to "let things happen" before calling a func to that, like the case when the player equips a weapon or while working with networked entities and you need them to exist first.
There are two ways of using this logic, one is firing a timer for example on a "Pre" event (Time) and the other is to request a frame in the "post" event (requestFrame), both should work similarly on most cases.
The difference is that on the "post" event, you can read/know all the data you need to work with the entity (because you are sure it already exists)
__________________