Raised This Month: $ Target: $400
 0% 

"Can i read next position in DataPack?" or "Pack have next position?"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-05-2015 , 15:35   "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #1

How to get info: "Can i read next position in DataPack?"
I tried this:
PHP Code:
if (Pack.IsReadable(Pack.Position+1)) {
    
// Do some actions

But it dosen't work.
Kailo is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-05-2015 , 15:55   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #2

No. You know what you've written and read from the DataPack.
__________________
asherkin is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-05-2015 , 16:11   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #3

I have optional write. I will try this:
PHP Code:
//something in code
if (/* some statement */) {
    
Pack.WriteCell(true);
    
Pack.WriteCell(data);
} else
    
Pack.WriteCell(false);

//something else in code
if (Pack.ReadCell())
    
Pack.ReadCell(); 
It needed for option pass DataPack through another DataPack
Don't think what i'm crazy. I already do it and this work!

Last edited by Kailo; 06-05-2015 at 16:22.
Kailo is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 06-05-2015 , 16:54   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #4

Why not simply do that optional write check again when you read it?
__________________

Last edited by Impact123; 06-05-2015 at 16:55.
Impact123 is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-05-2015 , 17:08   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #5

Quote:
Originally Posted by Impact123 View Post
Why not simply do that optional write check again when you read it?
How? This topic about this, i asked: "how do this"?
Kailo is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 06-05-2015 , 17:09   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #6

you should probably just redesign what you are sending into the datapack (i.e. make data = -1)
Mitchell is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 06-05-2015 , 17:17   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #7

Quote:
Originally Posted by Impact123 View Post
Why not simply do that optional write check again when you read it?
Quote:
Originally Posted by Kailo View Post
How? This topic about this, i asked: "how do this"?
Code:
if ( IsPackReadable( yourDatapackHandle, 4 ) )
{
new blabla = ReadPackCell( yourDatapackHandle );
//Do stuff
}
alternatively, probably
Code:
if ( yourDatapackHandle.IsPackReadable(4) )
{
new blabla = yourDatapackHandle.ReadPackCell();
//Do stuff
}
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 06-05-2015 at 23:17. Reason: oops
RedSword is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-05-2015 , 17:31   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #8

RedSword, do you see IsPackReadable function prototype?
Quote:
native bool IsPackReadable(Handle pack, int bytes);
It not be even compile if i wrote like you say.

Mitchell, i don't understand that you tried to say.

Last edited by Kailo; 06-05-2015 at 17:45.
Kailo is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-05-2015 , 22:39   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #9

Figure out how many cells you are going to write before you write them, write the count, and then write the cells.

When you read, you then know exactly how many to read back.

Expect IsPackReadable to be reworked in a future release. It should not be exposing byte count, since item size in a pack is an implementation detail.

Last edited by psychonic; 06-05-2015 at 22:45.
psychonic is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 06-05-2015 , 23:18   Re: "Can i read next position in DataPack?" or "Pack have next position?"
Reply With Quote #10

Quote:
Originally Posted by Kailo View Post
RedSword, do you see IsPackReadable function prototype?

It not be even compile if i wrote like you say.

Mitchell, i don't understand that you tried to say.
I believe it should work now.

Quote:
Originally Posted by psychonic View Post
Expect IsPackReadable to be reworked in a future release. It should not be exposing byte count, since item size in a pack is an implementation detail.
I suggest a CanReadCell/String(). Though that's probably what you had in mind.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 06-05-2015 at 23:20.
RedSword is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode