Passing any type of variable.
#1

Hello. I am making a saving system, and I want to use 1 function for all types of data (float, integer, string). I don't really have any ideas how to do it, except I saw this stuff in 'setproperty' page on wiki:
Код:
setproperty(.value = 123984334, .string = ":)");
Therefore I could do this:
Код:
stock ini_write(file, wfloat = NAN, wint = NAN, wstring[] = ";;[[;;[[")
{
     if(wfloat == wfloat){ write a float }
     else if(wint == wint){ write an integer }
     else if(strcmp(wstring, ";;[[;;[[") > 0){ write a string }
     return 1;
}

//somewhere
     new Float:posX = 1.2, vehicleid = 245, name[MAX_PLAYER_NAME] = "Bob";
     ini_write(file, .posX);
     ini_write(file, .vehicleid );
     ini_write(file, .name);
But would it work? I can't it test myself right now as I'm not home.

Thanks.
Reply


Messages In This Thread
Passing any type of variable. - by CaHbKo - 12.06.2011, 16:49
Re: Passing any type of variable. - by Cyanide - 12.06.2011, 18:14
Re: Passing any type of variable. - by CaHbKo - 12.06.2011, 19:22
Re: Passing any type of variable. - by 0x5A656578 - 12.06.2011, 20:40
Re: Passing any type of variable. - by CaHbKo - 13.06.2011, 07:42
Re: Passing any type of variable. - by CaHbKo - 13.06.2011, 08:33
Re: Passing any type of variable. - by 0x5A656578 - 21.06.2011, 18:50

Forum Jump:


Users browsing this thread: 5 Guest(s)