House system problem.
#1

Hello there, I have a following problem. I am using Antironix House System. Problem is, when I buy a house, the cash returns to the account when the player returns to the server and logs back in.

This is the code:

Код:
dcmd_buy(playerid,params[])
{
  #pragma unused params
	new str[255],str1[255],pname[24], housenumber;
	housenumber = GetHouseID(playerid);
	if(housenumber == -1) return SendClientMessage(playerid, COLOR_ADMIN, "*** Nie jestes w ikonce domu!");

	GetPlayerName(playerid, pname, 24);
	format(str1, sizeof(str1), "Houses/Users/%s", udb_encode(pname));
	if(dini_Exists(str1))
	{
		if (dini_Int(str1, "Houseid")!=-255) return SendClientMessage(playerid, COLOR_YELLOW, "*** Możesz kupić tylko jeden dom!");
	}
	format(str1, sizeof(str1), "Houses/houseid%d", housenumber);
	if (strcmp(hInfo[housenumber][Name],"ForSale",true)) return SendClientMessage(playerid, COLOR_YELLOW, "*** Ten dom nie jest na sprzedaż!");
	if(GetPlayerMoney(playerid)<hInfo[housenumber][Cost]) return SendClientMessage(playerid, COLOR_ADMIN, "*** Nie masz wystarczająco pieniędzy przy sobie!");
	SendClientMessage(playerid, COLOR_GREEN, "*** Gratulacje, własnie stałes się włascicielem tej parceli! Wpisz /househelp aby zobaczyć komendy własciciela domu!");
	format(str, sizeof(str), "%s has bought houseid 0",pname);
	print(str);
  GivePlayerMoney(playerid, -hInfo[housenumber][Cost]);
  dini_Set(str1, "Name", pname);
  dini_IntSet(str1, "Cash", GetPlayerMoney(playerid));
  hInfo[housenumber][Name]=pname;
  hInfo[housenumber][Locked] = dini_IntSet(str1,"Locked",0);

	format(str1, sizeof(str1), "Houses/Users/%s", udb_encode(pname));
	if (!dini_Exists(str1)) dini_Create(str1);
	new Float:sy, Float:sx, Float:sz;
	dini_IntSet(str1, "Houseid", housenumber);
	if(!dini_Isset(str1,"Rentid"))
	{
		dini_IntSet(str1, "Rentid", -255);
	}
	GetPlayerPos(playerid, sx,sy,sz);
	dini_FloatSet(str1, "SpawnX", sx);
	dini_FloatSet(str1, "SpawnY", sy);
	dini_FloatSet(str1, "SpawnZ", sz);
	dini_IntSet(str1, "SpawnInt", GetPlayerInterior(playerid));
	DestroyPickup(HousePickup[housenumber]);
	HousePickup[housenumber] = CreatePickup(1272, 23, hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz]);
	return 1;
}
I wonder whether it's the /buy code problem or the login code problem. I will include /login code too..

Код:
	if(strcmp(cmd, "/login", true) == 0)
	{
	  new PlayerName[24];
	  tmp = strtok(cmdtext, idx);
	  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "UŻYCIE: /login [hasło]");
		new name[MAX_PLAYER_NAME];
		if(IsLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_GREEN, "Jestes już zalogowany!");
			return 1;
		}
		else
		{
			GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"%s.ini",name);
			if(fexist(file))
			{
		  	tmp2 = dini_Get(file, "Password");
			 	if(udb_hash(tmp) != strval(tmp2))
				{
				  SendClientMessage(playerid, COLOR_ADMIN, "Login się nie powiуdł!");
	 			  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	 			  printf("%s nie zalogował się poprawnie.", name);
				}
				else
				{
				 	IsLogged[playerid] = 1;
				 	SetPlayerSkin(playerid, dini_Int(file, "Skin"));
				 	SetPlayerMoney(playerid, dini_Int(file, "Cash"));
					SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]: Zalogowałes się na konto!");
				}
			}
		}
		return 1;
	}
I would be glad if anyone could help me.

Thanks and Regards,
Puzi
Reply


Messages In This Thread
House system problem. - by Puzi - 19.02.2010, 20:32

Forum Jump:


Users browsing this thread: 1 Guest(s)