integer limit
#1

pawn Code:
new exp=gettime()+(60*60*24*days);
when i try to save this with y_ini the script does not save this stops working. and if i try with day 1 it does not do the the last step
pawn Code:
new exp=gettime()+(60*60*24*days);
    new INI:File = INI_Open(UserBanPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banexp",exp);  // this line and any line next to it won't be executed if i use any day other than 1
    INI_WriteInt(File,"BanPerm",0);
    INI_WriteString(File,"BanAdmin","Anti-Cheat");
    INI_WriteString(File,"Reason",reason);
    INI_WriteString(File,"IP",PlayerInfo[playerid][pIP]);
    INI_Close(File);  // this line and any line next to it won't be executed if i use day as 1
p.s i am talking as day about the variable days
Reply
#2

Quote:
Originally Posted by AroseKhanNaizi
View Post
pawn Code:
new exp=gettime()+(60*60*24*days);
pawn has it's own int-limitations, it's 0x7F800000 which is 2139095040 in decimal.
note, the actual limit for integer numbers is -> min: –2147483648 / max: 2147483647
you're exceeding pawn's int-limit by doing
1409925987(current timestamp)*60*60*24*2(2 days for example)
resulting in: 2,43635211 * 10^14 (243635211000000)
its too much for pawn.

so ya, you can't really insert anything else besides 1 for days here.
Reply
#3

save and load as a string like this --
pawn Code:
new exp[30];
format(exp, 30, "%i",gettime()+(60*60*24*days));
new INI:File = INI_Open(UserBanPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Banexp",exp);

//for loading in parse file callback -
new temp[30];
INI_String("Banexp",temp,30);
Varaible_of_ban_exp = strval(temp);
This shouldnt happen though it works well in my pc
Reply
#4

ok brozesus btw its your script... AND +rep for all
btw i was sure some problem with the limit of integer i was just gonna do printf("%d",exp); but i got the reply so thanks and i was not sure that string will work so thanks for it once more.

edit it won't work idk but its always an unban that way and i see the ini file and its
Code:
[data]
Banexp = 1411659986
BanPerm = 0
BanPlayer = Sasuke_Uchiha
BanAdmin = Anti-Cheat
Reason = Weapon Hack
ok so i did some more testing and got to know that the part of converting string into integer in not working
Code:
[21:33:21] banned loading account 0 time loded after converting to string 
[21:33:21] banned loading account 0 time loaded after converting to string 
[21:33:21] banned loading account 0 time loaded after converting to string 
[21:33:21] banned loading account 0 time loaded after converting to string
pawn Code:
forward LoadBanUser_data(playerid,name[],value[]);
public LoadBanUser_data(playerid,name[],value[])
{
    new temp[30];
    INI_String("Banexp",temp,30);
    PlayerInfo[playerid][pBanexp] = strval(temp);
    printf("banned loading account %d time loaded after converting to string ",PlayerInfo[playerid][pBanexp]);
    INI_Int("BanPerm",PlayerInfo[playerid][pBanPerm]);
    INI_String("BanAdmin", PlayerInfo[playerid][pBanAdmin], 20);
    INI_String("Reason",PlayerInfo[playerid][pBanres],100);
    return 1;
}
edit my english makes no sense in this print but it was just for testing and i understand it like i accidentally write string in place of integer
edit 2: i tried some more tests problem in loading the string its loading empty script
pawn Code:
INI_String("Banexp",temp,30);
    printf("%s loaded string",temp);
result
Code:
[00:23:09]  loaded string
so the string loaded was empty but the saved string was fine
Code:
Banexp = 1409945031
Fixed All the problem was its not loading it as an string but loading it as an integer will work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)