Passing multiple data with RequestFrame
Hi,
I need to pass multiple data with RequestFrame. Like this: PHP Code:
|
Re: Passing multiple data with RequestFrame
use a DataPack
the reason this works is because the prototype calls for function, and an argument of type "any" i liken this down to a typeless, welfare style of delegates Example for your situation: PHP Code:
|
Re: Passing multiple data with RequestFrame
Quote:
How can I write an int into a specific cell in a datapack and then retreive that one? Not sure if my question is understandable, I'm kind of bad at explaining stuff.. Your updated post is explaining this pretty well! So if I understand this correctly, using ReadCell(), it retreives the cells in the same order as they were written? |
Re: Passing multiple data with RequestFrame
@EasSidezz post #2
Now in your example, it create everytime new Datapack and not close old ones. There would be open Handles (sm_dump_handles myfile.txt) *edit But I learn also something new :D |
Re: Passing multiple data with RequestFrame
The DataPack has a position property (https://sm.alliedmods.net/new-api/da...aPack/Position) that decides where it is exactly. When you read/write something to it, the position advances.
Usually it's used by writing what you need in one function, passing it into the callback and then doing DataPack.Reset() which sets that position back to 0. The info is then read back in the order it was written. As Bacardi said, since a DataPack is a handle you need to close it once you're done using it. i.e. after you've read the data out of it. Can be done by doing 'delete datapack;' Another thing I'd do differently is tag the callback function parameter as a DataPack so you don't have to do that view_as<DataPack> thing. So 'MyFunction(DataPack thing)' instead of 'MyFunction(any thing)' |
Re: Passing multiple data with RequestFrame
Quote:
PHP Code:
|
Re: Passing multiple data with RequestFrame
Rule of thumb with handling anything considered "async" like RequestFrame (not enforced, but HIGHLY RECOMMENDED)
Never pass RAW entity/client indexes (except 0 or -1) as callback data, instead use either UserID/Client Serial (for client indexes) and entity references for entity indexes (0 or greater then MaxClients value) |
Re: Passing multiple data with RequestFrame
If I want to use an ArrayList it would be the same? Worst performace or it's even?
|
Re: Passing multiple data with RequestFrame
A datapack is the normal. You can parse any Handle you want at the end of the day.
|
Re: Passing multiple data with RequestFrame
Quote:
|
All times are GMT -4. The time now is 20:38. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.