View Single Post
Author Message
hh2
AlliedModders Donor
Join Date: Sep 2010
Old 09-18-2017 , 20:36   Set pack position on end not working
Reply With Quote #1

What is wrong in this code?
PHP Code:
    // Create DataPack
    
DataPack pack CreateDataPack();
    
    
// Write data to DataPack
    
pack.WriteCell(client);
    
pack.WriteString("test");
    
pack.WriteCell(5);
    
    
// Get DataPack end position for later
    
DataPackPos pos pack.Position;
    
    
// Reset DataPack
    
pack.Reset();
    
    
// Read only client id
    
int client2 pack.ReadCell();
    
    
// Set position to end 
    
pack.Position pos;       // Error here
    
    // Write new data to the end
    
pack.WriteCell(6); 
Logs:
Code:
[SM] Exception reported: Invalid DataPack position, 28 is out of bounds
[SM] Call stack trace:
[SM] [0] DataPack.Position.set
I'm trying also something like (pos - view_as<DataPackPos>(1)), but this gave me incorrect results.

Last edited by hh2; 09-19-2017 at 16:09.
hh2 is offline