Originally Posted by Emmet_
No shit! I can't search threads though, and I already knew that the GetVehicleSpeed function existed, I just wanted to share my version??
More functions that will get me yelled at:
pawn Код:
new bool:FALSE = false;
#define INI: File: #define INI_Open(%0) fopen(%0, io_readwrite) #define INI_WriteInt(%0,%1,%2) INI_WriteString(%0, %1, #%2) #define INI_WriteFloat(%0,%1,%2) INI_WriteString(%0, %1, #%2) #define INI_WriteString(%0,%1,%2) fwrite(%0, %1), fputchar(%0, '='), fwrite(%0, %2), fwrite(%0, "\r\n") #define INI_Int(%0,%1,%2) do{new _string[128];while(fread(%0,_string)){if(strcmp(_string,%1,false,strlen(%1))==0&&_string[strlen(%1)]=='='){strmid(_string,_string,strlen(%1)+1,strlen(_string)-2,128);%2=strval(_string);fseek(%0,0,seek_start);break;}}}while(FALSE) #define INI_Float(%0,%1,%2) do{new _string[128];while(fread(%0,_string)){if(strcmp(_string,%1,false,strlen(%1))==0&&_string[strlen(%1)]=='='){strmid(_string,_string,strlen(%1)+1,strlen(_string)-2,128);%2=floatstr(_string);fseek(%0,0,seek_start);break;}}}while(FALSE) #define INI_String(%0,%1,%2,%3) do{new _string[128];while(fread(%0,_string)){if(strcmp(_string,%1,false,strlen(%1))==0&&_string[strlen(%1)]=='='){strmid(%2,_string,strlen(%1)+1,strlen(_string)-2,%3);fseek(%0,0,seek_start);break;}}}while(FALSE) #define INI_Close(%0) fclose(%0)
pawn Код:
public OnFilterScriptInit() { new INI:test, money, Float:health, string[24]; test = INI_Open("file.txt"); INI_WriteInt(test, "Money", 100); INI_WriteFloat(test, "Health", 75.0); INI_WriteString(test, "String", "Sup."); INI_Close(test); test = INI_Open("file.txt"); INI_Int(test, "Money", money); INI_String(test, "String", string, 24); INI_Float(test, "Health", health);
print(string); printf("You have $%d.", money); printf("%f", health); INI_Close(test); return 1; }
|