Creating House Problem.... Writing A File With SII
#10

pawn Код:
CMD:buy(playerid,params[])
{
    for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
    {
        if(!IsPlayerInRangeOfPoint(playerid,8.0,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos])) continue;//Check if the player is near a house checkpoint
        if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");//Checking the players money, to see if he has enough to buy the house.
        if(HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");//Checking if the house is already owned.
        HInfo[i][Owned] = 1;//Setting the house owned var to 1.
        new file[60],pName[24],string[100];//Creating the necessary vars.
        GetPlayerName(playerid,pName,sizeof(pName));//Retrieving the player's name.
        format(HInfo[i][Owner],24,"%s",pName);//Setting the House Owner's var
        new INI:file = INI_Open("FHouse/Houses/%i.ini",i);
        INI_WriteInt(file,"Owned",1);//Setting in the ini file "Owned" to 1
        INI_WriteString(file,"Owner",pName);//Setting the "Owner" to the player's name.
        //INI_Save();//Saving the ini
        INI_Close();//Closing the ini
        format(string,sizeof(string),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Price],pName);//Formating the string, so we can update the label of the house
        Update3DTextLabelText(HInfo[i][HouseLabel],0xFF0000FF,string);//Updating the label with a red color
        return 1;
    }
    SendClientMessage(playerid,-1,"You aren't near a house!");
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)