How comes this gives random numbers in scriptfiles -
Scripter12345 - 01.05.2012
Hello i tried making this but when i looked in my in the file that it was meant to save and it showed this
[data]
HousePrice = 78
HouseOwned = 111
HouseOwner = 78
HouseEnter = 1
HouseXPos = 0.000000
HouseYPos = 0.000000
HouseZPos = 0.000000
VirtualWorld = 70
This is the code
pawn Код:
CMD:createhouse(playerid, params[])
{
new HousePrice;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be a admin to use that command");
if(sscanf(params,"i", HousePrice)) return SendClientMessage(playerid, COLOR_GREEN, "/createhouse [houseprice]");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
HouseInfo[playerid][hPrice] = HousePrice;
HouseInfo[playerid][hOwned] = 0;
HouseInfo[playerid][XPos] = x;
HouseInfo[playerid][YPos] = y;
HouseInfo[playerid][ZPos] = z;
HouseInfo[playerid][VirtualWorld] = GetPlayerVirtualWorld(playerid);
format(HouseInfo[playerid][hOwner],24,"NoNameForThisHouse");
SendClientMessage(playerid, COLOR_GREEN, "House created");
HouseInfo[playerid][hEnter] = AddStaticPickup(1273, -1, x, y, z, 0);
GetPlayerName(playerid,pname,sizeof(pname));
new INI:File = INI_Open(HousePath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"HousePrice", HouseInfo[playerid][hPrice]);
INI_WriteInt(File,"HouseOwned", HouseInfo[playerid][hOwned]);
INI_WriteInt(File,"HouseOwner", HouseInfo[playerid][hOwner]);
INI_WriteInt(File,"HouseEnter", HouseInfo[playerid][hEnter]);
INI_WriteFloat(File,"HouseXPos", HouseInfo[playerid][XPos]);
INI_WriteFloat(File,"HouseYPos", HouseInfo[playerid][YPos]);
INI_WriteFloat(File,"HouseZPos", HouseInfo[playerid][ZPos]);
INI_WriteInt(File,"VirtualWorld", HouseInfo[playerid][VirtualWorld]);
INI_Close(File);
return 1;
}
Why does it not work
Thank You
Please Help Me Please
Re: How comes this gives random numbers in scriptfiles -
mamorunl - 01.05.2012
playerid does not belong here. HouseInfo is, as I read it, only to store information about a playerOWNED house. Not about a global house!
Re: How comes this gives random numbers in scriptfiles -
Scripter12345 - 01.05.2012
Quote:
Originally Posted by mamorunl
playerid does not belong here. HouseInfo is, as I read it, only to store information about a playerOWNED house. Not about a global house!
|
So how would i fix
Thank You
Please Help Me Please
Re: How comes this gives random numbers in scriptfiles -
iRemix - 01.05.2012
You can add a id parametre into your command, so it sets those houses to that id.
Take a look:
pawn Код:
CMD:createhouse(playerid, params[])
{
new HousePrice, houseid;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be a admin to use that command");
if(sscanf(params,"ii", houseid, HousePrice)) return SendClientMessage(playerid, COLOR_GREEN, "/createhouse [id] [houseprice]");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
HouseInfo[houseid][hPrice] = HousePrice;
HouseInfo[houseid][hOwned] = 0;
HouseInfo[houseid][XPos] = x;
HouseInfo[houseid][YPos] = y;
HouseInfo[houseid][ZPos] = z;
HouseInfo[houseid][VirtualWorld] = GetPlayerVirtualWorld(playerid);
format(HouseInfo[houseid][hOwner],24,"NoNameForThisHouse");
SendClientMessage(playerid, COLOR_GREEN, "House created");
HouseInfo[houseid][hEnter] = AddStaticPickup(1273, -1, x, y, z, 0);
GetPlayerName(playerid,pname,sizeof(pname));
new INI:File = INI_Open(HousePath(houseid));
INI_SetTag(File,"data");
INI_WriteInt(File,"HousePrice", HouseInfo[houseid][hPrice]);
INI_WriteInt(File,"HouseOwned", HouseInfo[houseid][hOwned]);
INI_WriteInt(File,"HouseOwner", HouseInfo[houseid][hOwner]);
INI_WriteInt(File,"HouseEnter", HouseInfo[houseid][hEnter]);
INI_WriteFloat(File,"HouseXPos", HouseInfo[houseid][XPos]);
INI_WriteFloat(File,"HouseYPos", HouseInfo[houseid][YPos]);
INI_WriteFloat(File,"HouseZPos", HouseInfo[houseid][ZPos]);
INI_WriteInt(File,"VirtualWorld", HouseInfo[houseid][VirtualWorld]);
INI_Close(File);
return 1;
}
Please give me reputation if I helped.
Re: How comes this gives random numbers in scriptfiles -
Scripter12345 - 01.05.2012
Quote:
Originally Posted by iRemix
You can add a id parametre into your command, so it sets those houses to that id.
Take a look:
pawn Код:
CMD:createhouse(playerid, params[]) { new HousePrice, houseid; if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be a admin to use that command"); if(sscanf(params,"ii", houseid, HousePrice)) return SendClientMessage(playerid, COLOR_GREEN, "/createhouse [id] [houseprice]"); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); HouseInfo[houseid][hPrice] = HousePrice; HouseInfo[houseid][hOwned] = 0; HouseInfo[houseid][XPos] = x; HouseInfo[houseid][YPos] = y; HouseInfo[houseid][ZPos] = z; HouseInfo[houseid][VirtualWorld] = GetPlayerVirtualWorld(playerid); format(HouseInfo[houseid][hOwner],24,"NoNameForThisHouse"); SendClientMessage(playerid, COLOR_GREEN, "House created"); HouseInfo[houseid][hEnter] = AddStaticPickup(1273, -1, x, y, z, 0); GetPlayerName(playerid,pname,sizeof(pname)); new INI:File = INI_Open(HousePath(houseid)); INI_SetTag(File,"data"); INI_WriteInt(File,"HousePrice", HouseInfo[houseid][hPrice]); INI_WriteInt(File,"HouseOwned", HouseInfo[houseid][hOwned]); INI_WriteInt(File,"HouseOwner", HouseInfo[houseid][hOwner]); INI_WriteInt(File,"HouseEnter", HouseInfo[houseid][hEnter]); INI_WriteFloat(File,"HouseXPos", HouseInfo[houseid][XPos]); INI_WriteFloat(File,"HouseYPos", HouseInfo[houseid][YPos]); INI_WriteFloat(File,"HouseZPos", HouseInfo[houseid][ZPos]); INI_WriteInt(File,"VirtualWorld", HouseInfo[houseid][VirtualWorld]); INI_Close(File); return 1; }
Please give me reputation if I helped.
|
Did not work
Thank You
Please Help Me Please
Re: How comes this gives random numbers in scriptfiles -
iRemix - 01.05.2012
Its proberbly something to do with your stock (HousePath()
Re: How comes this gives random numbers in scriptfiles -
Scripter12345 - 01.05.2012
Quote:
Originally Posted by iRemix
Its proberbly something to do with your stock (HousePath()
|
pawn Код:
#define HPATH "/Houses/Houses/%s.ini"
pawn Код:
stock HousePath(playerid)
{
new string[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),HPATH,playername);
return string;
}
Thank You
Please Help Me Please
Re: How comes this gives random numbers in scriptfiles -
mamorunl - 02.05.2012
it has nothing to do with your HPATH. How are your houses saved (not the assignment to a house owned by a player, but really where are the HOUSES saved)?
Re: How comes this gives random numbers in scriptfiles -
Scripter12345 - 02.05.2012
Thank You
Please Help Me Please
Re: How comes this gives random numbers in scriptfiles -
Scripter12345 - 03.05.2012
Thank You
Please Help Me Please