Variable not working?
#1

Heey all,
I made a lock house variable:
//createhouse command
Код:
hInfo[h][Locked] = 1;
INI_WriteInt(file, "Locked", 1);
//enterhousecommand
Код:
if(hInfo[houseid][Locked] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"This house is locked!");
	}
	if(hInfo[houseid][Locked] == 0)
	{
	    new _int = hInfo[houseid][HouseInterior];
		SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
		SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
		SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
	}
Its not working because if i use the enter command and house is locked i am in house.
And if i switch the variables to:
Код:
if(hInfo[houseid][Locked] == 0)
	{
	    SendClientMessage(playerid,COLOR_RED,"This house is locked!");
	}
	if(hInfo[houseid][Locked] == 1)
	{
	    new _int = hInfo[houseid][HouseInterior];
		SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
		SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
		SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
	}
Its working.
How can i fix it?
Reply
#2

Mabye this work

Код:
if(hInfo[houseid][Locked] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"This house is locked!");
	}
	if(hInfo[houseid][Locked] == 0)
	{
	    new _int = hInfo[houseid][HouseInterior];
		SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
		SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
		SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
	}
Reply
#3

pawn Код:
if(hInfo[houseid][Locked] == 1)
        return SendClientMessage(playerid,COLOR_RED,"This house is locked!");

else
{
    new _int = hInfo[houseid][HouseInterior];
    SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
    SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
    SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
        return 1;
}
Try this way ...
Reply
#4

@N0Fear: Omg,Can you read? I already tried that.
@antonio112 Sorry dude its not working.
My script thinks that the variable is 0 but i dont know why.(hInfo[houseid][Locked] == 0)
I only have variable 1 in the script at the moment.
Can someone pls help me fix it?
I give rep because i need to fix this.
Reply
#5

pawn Код:
if(hInfo[houseid][Locked] == 1) return  SendClientMessage(playerid,COLOR_RED,"This house is locked!");

new _int = hInfo[houseid][HouseInterior];
SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
Reply
#6

Quote:
Originally Posted by aRoach
Посмотреть сообщение
pawn Код:
if(hInfo[houseid][Locked] == 1) return  SendClientMessage(playerid,COLOR_RED,"This house is locked!");

new _int = hInfo[houseid][HouseInterior];
SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
Dont work.
This is working:
Код:
if(hInfo[houseid][Locked] == 0) return  SendClientMessage(playerid,COLOR_RED,"This house is locked!");
But i need variable 1.
In scriptfiles i search at house i see Locked =1
So i dont know what the problem is.
Reply
#7

Are you sure that you load the variable from 'scriptfiles' and Set it in yout FS/GM ?

Post the Code....
Reply
#8

Yeah i really sure,the other things what is gonna saving works good.
Code:
Код:
enum Data
{
   HousePassword,
   HouseOwner[MAX_PLAYER_NAME],
   HouseName[MAX_HOUSE_NAME],
   HouseLocation[MAX_ZONE_NAME],
   Float:SpawnOutAngle,
   SpawnInterior,
   SpawnWorld,
   Float:CPOutX,
   Float:CPOutY,
   Float:CPOutZ,
   Float:SpawnOutX,
   Float:SpawnOutY,
   Float:SpawnOutZ,
   HouseValue,
   HouseStorage,
   HouseInterior,
   HouseCar,
   HouseCarModel,
   HouseCarWorld,
   HouseCarInterior,
   Float:HouseCarPosX,
   Float:HouseCarPosY,
   Float:HouseCarPosZ,
   Float:HouseCarAngle,
   QuitInHouse,
   Locked,
   Weapon[14],
   Ammo[14],
   ForSale,
   ForSalePrice,
   HousePrivacy,
   HouseAlarm,
   HouseCamera,
   HouseDog,
   UpgradedLock
}
//createhouse
        fcreate(HouseFile(h));
		GetPlayerPos(playerid, X, Y, Z);
		GetPlayerFacingAngle(playerid, Angle);
		new world = GetPlayerVirtualWorld(playerid), interior = GetPlayerInterior(playerid);
		hInfo[h][CPOutX] = X, hInfo[h][CPOutY] = Y, hInfo[h][CPOutZ] = Z;
		format(hInfo[h][HouseName], MAX_HOUSE_NAME, "%s", DEFAULT_HOUSE_NAME);
		format(hInfo[h][HouseOwner], MAX_PLAYER_NAME, "%s", INVALID_HOWNER_NAME);
		format(hInfo[h][HouseLocation], MAX_ZONE_NAME, "%s", GetHouseLocation(h));
		hInfo[h][HousePassword] = udb_hash("INVALID_HOUSE_PASSWORD");
		hInfo[h][HouseValue] = cost, hInfo[h][HouseStorage] = 0,hInfo[h][Locked] = 1;
		new INI:file = INI_Open(HouseFile(h));
		INI_WriteFloat(file, "CPOutX", X);
		INI_WriteFloat(file, "CPOutY", Y);
		INI_WriteFloat(file, "CPOutZ", Z);
		INI_WriteString(file, "HouseName", DEFAULT_HOUSE_NAME);
		INI_WriteString(file, "HouseOwner", INVALID_HOWNER_NAME);
		INI_WriteString(file, "HouseLocation", hInfo[h][HouseLocation]);
		INI_WriteInt(file, "HousePassword", hInfo[h][HousePassword]);
		INI_WriteString(file, "HouseCreator", pNick(playerid));
		INI_WriteInt(file, "HouseValue", cost);
		INI_WriteInt(file, "HouseStorage", 0);//this variable works great.
		INI_WriteInt(file, "Locked", 1);
//enterhouse command
stock SetPlayerHouseInterior(playerid, houseid)
{
	if(hInfo[houseid][Locked] == 1) return  SendClientMessage(playerid,COLOR_RED,"This house is locked!");//change this to 0 and its working .Wtf.

	new _int = hInfo[houseid][HouseInterior];
	SetPVarInt(playerid, "IsInHouse", 1), IsInHouse{playerid} = 1;
	SetPlayerPosEx(playerid, hIntInfo[_int][IntSpawnX], hIntInfo[_int][IntSpawnY], hIntInfo[_int][IntSpawnZ], hIntInfo[_int][IntInterior], (houseid + 1000));
	SetPlayerFacingAngle(playerid, hIntInfo[_int][IntSpawnAngle]);
	return 1;
}
//Scriptfiles house file:
CPOutX = -1978.378295
CPOutY = 1120.322387
CPOutZ = 53.012535
HouseName = House For Sale!
HouseOwner = INVALID_PLAYER_ID
HouseLocation = Downtown San Fierro
HousePassword = 1289815741
HouseCreator = [E.N.D.]Admigo
HouseValue = 100000
HouseStorage = 0
Locked = 1
SpawnOutX = -1980.870727
SpawnOutY = 1120.128295
SpawnOutZ = 53.012535
SpawnOutAngle = 454.453063
SpawnWorld = 0
SpawnInterior = 0
HouseInterior = 0
Reply
#9

WTF... You've posted only the thing that saves the Variables in the Files... But there isn't the Load Function
Reply
#10

Quote:
Originally Posted by aRoach
Посмотреть сообщение
WTF... You've posted only the thing that saves the Variables in the Files... But there isn't the Load Function
For test the locking system i just make house ingame and i enter house.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)