PDA

View Full Version : House system help


Nabster
29/03/2015, 04:19 PM
Loadhouse not working it is crashing my complier

CMD:createhouse(playerid,params[])
{
if(PInfo[playerid][Level] < 5)
return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 5 to use this command.");
new HousePrice,id = HouseCount;
if(sscanf(params,"i",HousePrice))
return SendClientMessage(playerid,0x59BF85FF,"USAGE: /createhouse <price>");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
HInfo[id][Price] = HousePrice;
HInfo[id][Owned] = 0;
HInfo[id][XPos] = x;
HInfo[id][YPos] = y;
HInfo[id][ZPos] = z;
HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
format(HInfo[id][Owner],24,"None");
SendClientMessage(playerid,0x59BF85FF,"House created");
HouseEnter[id] = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(pl ayerid));
HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,Ge tPlayerVirtualWorld(playerid));
new labelstring[100];
new INI:file = INI_Open(HousePath(id));
INI_WriteInt(file,"Price",HousePrice);
INI_WriteInt(file,"Owned",0);
INI_WriteInt(file,"VirtualWorld",GetPlayerVirtualWorld( playerid));
INI_WriteFloat(file,"XPos",x);
INI_WriteFloat(file,"YPos",y);
INI_WriteFloat(file,"ZPos",z);
INI_WriteString(file,"Owner","None");
INI_Close(file);
format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i \nOwner: The State",HousePrice);
HInfo[id][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25. 0,GetPlayerVirtualWorld(playerid));
HouseCount++;
return 1;
}



stock LoadHouses(id)
{
new houseowner[24];
for(new i = 0; i < MAX_HOUSES;i++)
{
new INI:file = INI_Open(HousePath(id));
INI_Int(file,"Price");
INI_Int(file,"Owned");
INI_Int(file,"XPos");
INI_Int(file,"YPos");
INI_Int(file,"ZPos");
INI_Int(file,"VirtualWorld");
INI_String(file,houseowner,"Owner");
format(HInfo[i][Owner],24,"%s",houseowner);
HouseEnter[i] = CreateDynamicCP(HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos],1.5,HInfo[i][VirtualWorld]);
HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HI nfo[i][VirtualWorld]);
new labelstring[100];
switch(HInfo[i][Owned])
{
case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[i][Price]);}
case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Price],HInfo[i][Owner]);}
}
HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos],25.0,HInfo[i][VirtualWorld]);
HouseCount++;
INI_Close(file);
}
return 1;
}

Nabster
30/03/2015, 02:14 AM
bump

Nabster
30/03/2015, 11:43 AM
anyone?

Wassimo
30/03/2015, 12:08 PM
This is mine -- PPC_Trucking French version --

// Lets the player add new houses
COMMAND:creermaison(playerid, params[])
{
// Setup local variables
new HPrice, MaxLevel, HouseID;

// Send the command to all admins so they can see it
SendAdminText(playerid, "/creermaison", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
// Check if the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
if (sscanf(params, "ii", HPrice, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/creermaison <prix> <Niveau (1-10)>\"");
else
{
// Check if the player entered a proper maxlevel
if ((MaxLevel >= 1) && (MaxLevel <= 10))
{
// Find the first free HouseID
for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
if (AHouseData[HouseID][PickupID] == 0) // Check if an empty house-index has been found (PickupID is 0)
break; // Stop searching, the first free HouseID has been found now

// Check if the house-limit hasn't been reached yet
if (HouseID < MAX_HOUSES)
{
// Setup some local variables
new Float:x, Float:y, Float:z, Msg[128];
// Get the player's position
GetPlayerPos(playerid, x, y, z);
// Set some default data
AHouseData[HouseID][HouseX] = x;
AHouseData[HouseID][HouseY] = y;
AHouseData[HouseID][HouseZ] = z;
AHouseData[HouseID][HouseLevel] = 1;
AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
AHouseData[HouseID][HousePrice] = HPrice;
AHouseData[HouseID][Owned] = false;

// Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
House_CreateEntrance(HouseID);

// Save the house
HouseFile_Save(HouseID);

// Inform the player that he created a new house
format(Msg, 128, "{00FF00}Vous avez crée la maison {FF00FF}%i{00FF00}", HouseID);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
else
SendClientMessage(playerid, 0xFF0000FF, "Le nombre de maison maximum a été atteint");
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vous devez écrire un niveau entre 1 et 10");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Vous ne pouvez pas utiliser cette commande dans un véhicule");
}
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}

Nabster
30/03/2015, 01:55 PM
I don't need a command,i want to know what i am doing wrong in my code and how do i make it work.