Strange format bug
#1

I have a very strange bug with showing reports. it actually doesn't show the first letter.
See the image. and instead of showing thre reportedby name, it shows the reported player name.

ReportedName=Magic
ReportedBy=Tarvo
ReportedReason=testreport 1
ReportID=1


what is causing this?

code:
PHP код:
CMD:pendingreports(playerid,params[])
{
    if(
AdminLevel[playerid] >=2)
    {
        new 
str[1024], string2[1024], string[1024], file[25];
        for(new 
1MAX_REPORTSi++)
        {
            
format(filesizeof(file), "Data/Reports/r%d.ini"i);
            
format(ReportInfo[i][ReportedBy], 256"%s"dini_Get(file"ReportedBy"));
            
format(ReportInfo[i][ReportedReason], 256"%s"dini_Get(file"ReportedReason"));
            
format(ReportInfo[i][ReportedName], 256"%s"dini_Get(file"ReportedName"));
            
ReportInfo[i][ReportID]=INI_Int(file,"ReportID");
            if(
ReportInfo[i][ReportID] == 0) break;
            
format(str,sizeof(str),"%s\t%s\t%s\t%d\n",ReportInfo[i][ReportedName],ReportInfo[i][ReportedBy],dini_Get(file"ReportedReason"),ReportInfo[i][ReportID]);
            
strcat(string2,str);
        }
        
format(str,sizeof(str),"Reported\tReported By\tReason\tReport ID\n%s"string2);
           
strcat(string,str);
        
ShowPlayerDialog(playeridDIALOG_NONEDIALOG_STYLE_TABLIST_HEADERS"Pending Reports"string"Ok""");
    }
    return 
1;

Reply
#2

Please show us the enum used by ReportInfo
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Please show us the enum used by ReportInfo
PHP код:
enum ReportData
{
    
ReportedName,
    
ReportedBy,
    
ReportedReason[50],
    
ReportID,
}; 
Reply
#4

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
PHP код:
enum ReportData
{
    
ReportedName,
    
ReportedBy,
    
ReportedReason[50],
    
ReportID,
}; 
Shouldn't ReportedName and ReportedBy be strings? You have them as ints in there.
Reply
#5

Yes, they should.

OP, first of all make them strings. Second of all, you will still encounter bugs, due to using 256 as constant for length parameter, and you will overwrite not only "ReportedBy" and "ReportedReason", but random memory (well, starting with next slots of ReportInfo) after the ReportInfo array, up to 205 cells after it. That will cause a lot of mayhem. If you are using Zeex's compiler, just use sizeof, if standard compiler shipped with server, then you have to manually make sure the "len" parameter passed to format is exactly the same as your string dimensions.
Reply
#6

Thank you all i now did:
PHP код:
enum ReportData 

    
ReportedName[20], 
    
ReportedBy[20], 
    
ReportedReason[50], 
    
ReportID
}; 

format(ReportInfo[i][ReportedBy], 20"%s"dini_Get(file"ReportedBy")); 
            
format(ReportInfo[i][ReportedReason], 50"%s"dini_Get(file"ReportedReason")); 
            
format(ReportInfo[i][ReportedName], 20"%s"dini_Get(file"ReportedName")); 
And it works perfect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)