Raised This Month: $12 Target: $400
 3% 

1.7 transition syntax, datapack issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 11-29-2014 , 13:43   1.7 transition syntax, datapack issue
Reply With Quote #1

http://gyazo.com/1c9cb60a72dde6dc843a0c6af7aea841
http://gyazo.com/493f5a5638c13a9339031a66e9330213
http://gyazo.com/cae4d4498613dda0e4aea53484238a90

I'm trying to pass a datapack thru a RequestFrame but it dosnt seem like the Reset function actually reset the datapack and it is NOT a invalid handle.

I am able to read the pack inside the same scope where I initialized it but when ever I try to read it to a function I have pass it over it give me that out of bound error. Note also that it does not allow me to put the any tag so I decided to put the var type in the callback.

PS: I also tried with multiple snapshot releases, same result, even before the methodmaps with handles it give the same error so it really have to do with the passing thru the function problem (the cast of any to DataPack|Handle?)

Last edited by Mathias.; 11-29-2014 at 13:44.
Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 11-29-2014 , 13:59   Re: 1.7 transition syntax, datapack issue
Reply With Quote #2

Your code looks fine. If it works inside the scope but not outside, that's pretty mysterious. Is it possible to attach a .sp file as a test case?
__________________
egg
BAILOPAN is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 11-29-2014 , 16:03   Re: 1.7 transition syntax, datapack issue
Reply With Quote #3

hum sure, I was just making test with file size to know if I can actually use this method to detect when demo stop being writing. by the way if you have a better idea for it tell me but datapack are still the main issue here:

PHP Code:
public int Native_TVStopRecord(Handle pluginint param_amount)
{
    
char file_name[32], file_path[PLATFORM_MAX_PATH], buffer[128];

    
ServerCommandEx(buffersizeof(buffer), "tv_stoprecord");
    
    if (!
StrContains(buffer"Completed"))
    {
        
int pos FindCharInString(buffer'\\'true)+1;
        
        for (
int i possizeof(buffer); i++)
        {
            if (
buffer[i] == '"')
            {
                
file_name[i-pos] = '\0';
                break;
            }
        
            
file_name[i-pos] = buffer[i];
        }
        
        
Format(file_pathPLATFORM_MAX_PATH"%s%s", global[m_sPathDemos], file_name);
        if (!
FileExists(file_path))
        {
            
MM_Log(LTError"File <%s> does not exist!\nFull path <%s>"file_namefile_path);
            return 
false;
        }
    
        
        
//char test[32];
    
        
        //ReadPackString(data, test, 32);
        
        //PrintToServer("-----> %s", test);
    
        
DataPack data CreateDataPack();
        
data.WriteString(file_name);
        
data.WriteCell(0);
        
data.WriteCell(Handle:plugin);
        
data.WriteFunction(GetNativeFunction(1));
        
data.Position 0;
        
        
RequestFrame(Frame_TVRecordFileWrotedata);
        
        return 
true;
    }
    
    
MM_Log(LTError"Failed to stop recording match on file <%s>\nResponse <%s>"file_namebuffer);
    
    return 
false;
}

public 
void Frame_TVRecordFileWrote(DataPack data)
{
    
char file_name[32], file_path[PLATFORM_MAX_PATH];
    
data.ReadString(file_name32);
    
Format(file_pathPLATFORM_MAX_PATH"%s%s", global[m_sPathDemos], file_name);
    
    
int file_size FileSize(file_path);
    
    if (
file_size == -1)
    {
        
MM_Log(LTError"File <%s> does not exist!\nFull path <%s>"file_namefile_path);
        return;
    }
    
    
int file_old_size data.ReadCell();
    
    static 
int temp;
    if (
file_size 0)
    {
        
MM_Log(LTCustomSingle"File <%s> size <%d> old size <%s> temp <%d>"file_namefile_sizefile_old_sizetemp);
        
        if (
file_old_size == file_size)
            ++
temp;

        if (
temp == 5)
        {
            
temp 0;
            
MM_Log(LTCustomSingle"File <%s> is done?"file_name);
            return;
        }
    }
    
    
data.Position 1;
    
data.WriteCell(file_size);
    
data.Reset();
    
RequestFrame(Frame_TVRecordFileWrotedata);

Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 11-29-2014 , 19:53   Re: 1.7 transition syntax, datapack issue
Reply With Quote #4

Setting the value of |Position| to any value not previously returned by Position is undefined behavior. If you want to skip to a certain position you have to save where you wrote it in a variable somewhere.
__________________
egg

Last edited by BAILOPAN; 11-29-2014 at 19:54.
BAILOPAN is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 11-29-2014 , 23:57   Re: 1.7 transition syntax, datapack issue
Reply With Quote #5

I am confuse right now, what do you mean by the position? data.Position ?

Last edited by Mathias.; 11-29-2014 at 23:58.
Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 11-30-2014 , 01:36   Re: 1.7 transition syntax, datapack issue
Reply With Quote #6

Yes. I.e.,

PHP Code:
dp.Write(10);
new 
savedPos dp.Position
dp
.Write(20)
...
dp.Position savedPos 
Otherwise the position you're setting is basically random.
__________________
egg

Last edited by BAILOPAN; 11-30-2014 at 01:36.
BAILOPAN is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 11-30-2014 , 06:13   Re: 1.7 transition syntax, datapack issue
Reply With Quote #7

oh okay I though position was an index that start from 0 and increment by one every time you write to it. Thank you I will try this.
Mathias. 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 07:38.


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