Skip to content

Commit

Permalink
Added stock for requesting more frames ahead.
Browse files Browse the repository at this point in the history
  • Loading branch information
PremyslTalich committed Jul 7, 2016
1 parent 7cda2c3 commit 770fded
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions addons/sourcemod/scripting/include/teamgames-stocks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,34 @@ stock CreateDirectoryPath(const String:dirPath[], mode, bool:containsFile = fals
}
}

stock RequestFrame2(RequestFrameCallback:function, framesAhead = 1, any:data = 0)
{
if (framesAhead < 1)
return;

if (framesAhead == 1) {
RequestFrame(function, data);
} else {
new Handle:pack = CreateDataPack();
WritePackCell(pack, function);
WritePackCell(pack, framesAhead);
WritePackCell(pack, data);

RequestFrame(RequestFrame2_CallBack, pack);
}
}

public RequestFrame2_CallBack(any:pack)
{
ResetPack(Handle:pack);
new RequestFrameCallback:function = RequestFrameCallback:ReadPackCell(Handle:pack);
new framesAhead = ReadPackCell(Handle:pack) - 1;
new data = ReadPackCell(Handle:pack);
CloseHandle(Handle:pack);

RequestFrame2(function, framesAhead, data);
}

//------------------------------------------------------------------------------------------------
// Weapons (safe to use in both CS:S and CS:GO)

Expand Down

0 comments on commit 770fded

Please sign in to comment.