[Dini] INI-files easy! (1.6, 16th Sep 2008)
#1

Lots of guys can't use file write/read-functions, so I give you a ini-file-engine, which just works!

DINI 1.6:
o Download (25000++ Downloads - thanks!)
o HowTo (New HowTo) Dini Login/Register-System
o Blogpost
Hope it will be useful.

Regards,
Jan (DracoBlue)

( Download for previous Version: 1.5.1 )
Reply
#2

Workaholic?
Reply
#3

Quote:
Originally Posted by caytchen
Workaholic?
No, just insane .
Reply
#4

thanks
Reply
#5

where can i find a list of functions and their usage?
And the dini.dtest script only does the does the first test (Create & Exists) then the server crashes am i doing something wrong?
Reply
#6

Thx jan
Reply
#7

Quote:
Originally Posted by ******
The functions are in the .inc and their use can be derived from looking at the code. Do you have DUtils?
Yes i have DUtils and the Dtest thing for that works alright
Reply
#8

Do you have a folder called scriptfiles ?
Reply
#9

Quote:
Originally Posted by DracoBlue
Do you have a folder called scriptfiles ?
No i didn't, thanks that fixed it
Reply
#10

i found some scary shit here, dini_Set wasn't writing numbers in "value", so i replaced:
Code:
   strcat(tmpres,key);
   strcat(tmpres,"=");
   strcat(tmpres,value);
with:
Code:
format(tmpres, 256, "%s=%d", key, value);
now it works well
Reply
#11

damn, now it isn't writing letters (
i guess i needed to use hash uh?

at least you can make alternative function for numbers only
like dini_Set2
Reply
#12

now i done it completely! it's 100% works!

at the top of "dini_Set"

Code:
new sep[256];
format(sep,sizeof(sep),"=");
and replacing

Code:
strcat(tmpres,"=");
with

Code:
strcat(tmpres,sep);
i see strcat don't like any strings without variable

2DracoBlue if I'm right, you should make a new version with this fix
Reply
#13

Awesome work yet again Draco!!! Sometimes you do freak me out though :P

Regards,
Scarface
Reply
#14

Updated to 1.2.

Speed improvements, and new commands, like dini_Bool, dini_Int and dini_IntSet - read and write integer and boolean values!

Thanks to everyone who uses this!

Regards,
Jan (DracoBlue)
Reply
#15

No, Thanks to YOU!

What a really useful program!!!!!!!!!

You really do amaze me Draco

tosscops
Reply
#16

ok what i want to happen is when a player types /buy. it checks for the propertys name and if it exists it finds the owners name (inside the folder) and prints "This Property is owned buy %s". is this posible??, thanx

Code:
C:\DOCUME~1\Patrick\Desktop\Server\GAMEMO~1\src\RPG.pwn(664) : warning 202: number of arguments does not match definition
Pawn compiler 3.0.3367			Copyright © 1997-2005, ITB CompuPhase


1 Warning.
i know that i havent matched the definistion but it was one of my attemts
Code:
	if(strcmp(cmd, "/buy", true) == 0) {
		new property=999;
    GetPlayerName(playerid, pname, sizeof(pname));
		if(IsPlayerInCheckpoint(playerid)) {
			switch (playerCheckpoint[playerid]) {
				case CP_XENDOT:{
				  property = P_XENDOT;
				}
			}

			if(property==999) {
				SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
				return 1;
			}

//			property--;

			if(GetPlayerMoney(playerid) < propertyValues[property]) {
				SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this property.");
				return 1;
			}

			if(propertyOwner[property]==playerid) {
				SendClientMessage(playerid, COLOR_RED, "You already own this property.");
				return 1;
			}

			if(dini_Exists(udb_encode(propertyNames[property]))) {
			tmp = dini_Get(propertyNames[property]);
			format(string, sizeof(string), "This Property belongs to %s", tmp);
			SendClientMessage(playerid, COLOR_RED, string);
			return 1;
			}

			GivePlayerMoney(playerid, 0-propertyValues[property]);

			propertyOwner[property]=playerid;
			
			format(string, sizeof(string), "You have purchased the %s!", propertyNames[property]);
			SendClientMessage(playerid, COLOR_GREEN, string);
			dini_Create(udb_encode(propertyNames[property]));
      dini_IntSet(udb_encode(propertyNames[property]), pname, 1);

			}
  		return 1;
	}
Reply
#17

dini_Get(propertyNames[property]);

does NOT work.

You need to specify the filename, too.

dini_Get("properties.ini",propertyNames[property]);
Reply
#18

Thanx, but how is it how is save the players name after the property because every time i try i get the tag mismatch symbol

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256];
	new playermoney;
	new sendername[MAX_PLAYER_NAME];
	new giveplayer[MAX_PLAYER_NAME];
	new pname[256];
	new cmd[256];
	new giveplayerid, moneys, idx;
	new tmp[256], tmp2[256];
	new playername[MAX_PLAYER_NAME];

	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/buy", true) == 0) {
		new property=999;
    GetPlayerName(playerid, pname, sizeof(pname));
		if(IsPlayerInCheckpoint(playerid)) {
			switch (playerCheckpoint[playerid]) {
				case CP_AMMU:{
				  property = P_AMMU;
				}

			}

			if(property==999) {
				SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
				return 1;
			}

//			property--;

			if(dini_Exists(udb_encode("Propertys.ini"))) {
			tmp = dini_Get("Propertys.ini", propertyNames[property]);
			format(string, sizeof(string), "This Property belongs to %s", tmp);
			SendClientMessage(playerid, COLOR_RED, string);
			return 1;
			}


			if(GetPlayerMoney(playerid) < propertyValues[property]) {
				SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this property.");
				return 1;
			}

			if(propertyOwner[property]==playerid) {
				SendClientMessage(playerid, COLOR_RED, "You already own this property.");
				return 1;
			}

			GivePlayerMoney(playerid, 0-propertyValues[property]);

			propertyOwner[property]=playerid;
			
			format(string, sizeof(string), "You have purchased the %s!", propertyNames[property]);
			SendClientMessage(playerid, COLOR_GREEN, string);
                    dini_IntSet("Propertys.ini", propertyNames[property], pname);
			}
  		return 1;
	}
Reply
#19

dini_IntSet("Propertys.ini", propertyNames[property], pname);

DOES NOT work. Because pname is no INT.

dini_Set("Propertys.ini", propertyNames[property], pname);
Reply
#20

good work draco i like it
I can see this being used alot
Reply


Forum Jump:


Users browsing this thread: