SA-MP Forums Archive
dini_Get problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: dini_Get problem. (/showthread.php?tid=385550)



[fixed] dini_Get problem. - justinnater - 16.10.2012

Hey, i'm having a problem with reading a string from a file.
The code looks like this:
Код:
	        new ownh[MAX_STRING];
		ownh=dini_Get("Factions/Team-CIV.txt","factioncolor");
	        SetPlayerColor(playerid,ownh);//[1337]
When compiling I get this error:
(1337) : error 035: argument type mismatch (argument 2)

Can someone help me with this, please?


AW: dini_Get problem. - Nero_3D - 16.10.2012

dini_Get returns a string, use dini_GetInt


Re: dini_Get problem. - justinnater - 16.10.2012

The thing is, i want it to return a string.
And if i'm right, you intended to say dini_Int instead of dini_GetInt.
(The string from "factioncolor" = COLOR_WHITE


AW: Re: dini_Get problem. - Nero_3D - 16.10.2012

Quote:
Originally Posted by justinnater
Посмотреть сообщение
The thing is, i want it to return a string.
And if i'm right, you intended to say dini_Int instead of dini_GetInt.
(The string from "factioncolor" = COLOR_WHITE
Oh yeah, its been ages since nearly noone uses dini nowadays

So you saved the string "COLOR_WHITE" ?
Although this looks like a define (#define COLOR_WHITE 0xFFFFFFFF)
If thats the cause than, just save it as an int and load it as an int, problem solved
pawn Код:
// saving
dini_SetInt("Factions/Team-CIV.txt","factioncolor", COLOR_WHITE); // if its a define
// loading
new color = dini_Int("Factions/Team-CIV.txt","factioncolor");
Saving the string is just inefficient


Re: dini_Get problem. - justinnater - 16.10.2012

dini_Int reads only integers, so it won't work due the x from 0xFFFFFF


AW: Re: dini_Get problem. - Nero_3D - 16.10.2012

Quote:
Originally Posted by justinnater
Посмотреть сообщение
dini_Int reads only integers, so it won't work due the x from 0xFFFFFF
Than you didnt understood what an integer is, an integer can be any number in any decimal format
Pawno supports hex (0x), deci (nothing) and binar (0b) formations, test that
pawn Код:
printf("They are all the same -> %d - %d - %d", 1234, 0x4D2, 0b10011010010);



Re: dini_Get problem. - justinnater - 16.10.2012

Oh, thats weird. I am currently using the following code:
Код:
		new color = dini_Int("Factions/Team-CIV.txt","factioncolor");
		SetPlayerColor(playerid,color);
And my color is black, while it should be white(0xFFFFFFFF). Did i missed something?


I implented SendClientMessage for a second to show the integer and as I mentioned already, it stops at the x from 0xFFFFFFFF
Код:
    	format(message,sizeof(message),"Current Integer: %d",color);
        SendClientMessage(playerid,COLOR_RED,message);



AW: dini_Get problem. - Nero_3D - 16.10.2012

You also need to save it as int not as string, check reply #4, there is the saving and the loading part


Re: dini_Get problem. - justinnater - 16.10.2012

Yes i saved it as a int now.
Код:
factioncolor=0xFFFFFFFF
Yet i still have the same problem.


AW: dini_Get problem. - Nero_3D - 16.10.2012

strval (which gets executed within dini_Int) only accecpts plain numbers, no hex

Also if you do
pawn Код:
dini_IntSet("Factions/Team-CIV.txt","factioncolor", COLOR_WHITE);
you get
Код:
factioncolor=-1
Which is correct since -1 = 0xFFFFFFFF