07.08.2012, 20:24
(
Последний раз редактировалось mrsamp; 08.08.2012 в 12:18.
)
This happends:
pawn Код:
public OnPlayerPickUpPickup(playerid,pickupid)
{
for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
{
if(pickupid == HouseEnter[i])//Checking if the checkpoint id corresponds to one of the house interiors
{
new pName[24];//Creating the new var for the players name
GetPlayerName(playerid,pName,24);//Storing the players name
if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
{
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));//Storing, so later we can reset it back
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
SetPlayerInterior(playerid,12);//Setting the players interior.
SetPlayerPos(playerid,446.7281,507.0475,1001.4195);//Setting the players position.
SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);//Preventing players from different houses, finding each other.
PlayerInHouseID[playerid] = i;
}
if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)//Checking if the house is owned but the house owner and the players name don't match.
{
SendClientMessage(playerid,-1,"You don't own this house");
}
if(HInfo[i][Owned] == 0)//Simply checking if the house isn't owned.
{
SendClientMessage(playerid,-1,"/buy to buy this lovely house");
}
}
if(pickupid == HouseExit[i])//Checking if the checkpointid is an House exit
{
SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayersInteriorHouse"));//Setting the players interior to the one we stored
SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldHouse"));//Setting the players virtual world to the one we stored.
}
}
return 1;
}
//THAT WAS THE PICKUPPICKUP ERROR MIGHT BE THERE
enum HouseInfo//Naming the enum
{
Owner[24],//This will be where it will store the house owner name, in a 24 bit size array.
Owned,//To store if the house is owned or not.
Price,//How much the house will cost.
Float:XPos,//Float X position of the checkpoint
Float:YPos,//Self explanatory.
Float:ZPos,//Self explanatory.
VirtualWorld,//The checkpoints virtual world.
Text3D:HouseLabel//That label where it says "Owned Price..."
}
new HInfo[MAX_HOUSES][HouseInfo];//This is the var where we will read the house info.
new HouseCount;//To check how many houses have we created.
new HouseEnter[MAX_HOUSES];//This will be where we will store the house entrance checkpoint
new HouseExit[MAX_HOUSES];//This will be where we will store the house exit checkpoint.
new PlayerInHouseID[MAX_PLAYERS];//To check what house id is the player in.
CMD:createhouse(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You aren't an admin!");//Check if the player is currently rcon logged in.
new HousePrice,id = HouseCount;//Creating the house price for the selected value in the command, and the last house id created.
if(sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse <price>");//Checking if the player uses the correct syntax. The parameter "i" in sscanf means integer, also could be used as "d".
new Float:x,Float:y,Float:z;//Creating the floats, to store the player's position.
GetPlayerPos(playerid,x,y,z);//Getting the player's position and storing it
HInfo[id][Price] = HousePrice;//Setting the house price to the selected one.
HInfo[id][Owned] = 0;//Setting the house id owned = 0
HInfo[id][XPos] = x;//Storing the XPos value to the player's x.
HInfo[id][YPos] = y;//Storing the YPos value to the player's y.
HInfo[id][ZPos] = z;//Storing the ZPos value to the player's z.
HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
format(HInfo[id][Owner],24,"Nonusablenameforthishouse");//Formating the "Owner" house id value to "Nonusablenameforthishouse".
HouseEnter[id] = CreateDynamicPickup(1273, 2, x,y,z,-1,-1,-1, 50.0);
HouseExit[id] = CreateDynamicPickup(1272, 2,443.9237,509.4609,1001.4195,-1,-1,-1,10.0);//Creating the house exit checkpoint and storing it in the HouseExit value.
new file[40],labelstring[100];//Creating the "file", and the labelstring var.
format(file,sizeof(file),"FHouse/Houses/%i.ini",id);//Formating the var to the selected house directory.
INI_Open(file);//Opening the file with SII.
INI_WriteInt("Price",HousePrice);//Writing in the place "Price" the inputted "Price" value.
INI_WriteInt("Owned",0);//Setting to "Owned" = 0 in the ini file.
INI_WriteInt("VirtualWorld",GetPlayerVirtualWorld(playerid));//Writing "VirtualWorld" = GetPlayerVirtualWorld(..);
INI_WriteFloat("XPos",x);//Writing the players pos for the check point position.
INI_WriteFloat("YPos",y);//Self explanatory.
INI_WriteFloat("ZPos",z);//Self explanatory.
INI_WriteString("Owner","Nonusablenameforthishouse");//Writing a string in "Owned" to "Nonusablenameforthishouse"
INI_Save();//Saving file with SII.
INI_Close();//Closing the file with SII.
format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HousePrice);
HInfo[id][HouseLabel] = Create3DTextLabel(labelstring,0x0000FFFF,x,y,z,25.0,GetPlayerVirtualWorld(playerid));
HouseCount++;
return 1;
}