SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 04/10/2011, 10:44 PM   #21
FireCat
High-roller
 
FireCat's Avatar
 
Join Date: Jul 2010
Posts: 2,322
Reputation: 609
Default Re: Respuesta: Creating a house system with checkpoints!

Quote:
Originally Posted by TheBest6 View Post
very Nice
Thanks :b
Quote:
Originally Posted by [00]Luis View Post
Thanks
Lol, no problem (:
FireCat is offline   Reply With Quote
Old 05/10/2011, 07:36 AM   #22
Stefans94
Big Clucker
 
Join Date: Nov 2010
Posts: 75
Reputation: 0
Default Re: Creating a house system with checkpoints!

1. Did you even test this? there are allot of faults in this tutorial
2. This only works if your server never restarts right? i don't see anything in this script that loads the houses..
Stefans94 is offline   Reply With Quote
Old 05/10/2011, 10:33 AM   #23
FireCat
High-roller
 
FireCat's Avatar
 
Join Date: Jul 2010
Posts: 2,322
Reputation: 609
Default Re: Creating a house system with checkpoints!

Ok, added the loading part.
FireCat is offline   Reply With Quote
Old 07/10/2011, 07:07 PM   #24
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: Creating a house system with checkpoints!

FireCat i have a problem i get a bunch of errors on ur code

pawn Code:
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(102) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(102) : error 001: expected token: ")", but found "return"
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(148) : warning 213: tag mismatch
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(148) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(150) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.

i changed it abit to suit my Gm but its in ur main code itself in the Sell command and the OnPlayerEnterDynamicCP thing here is the code:

pawn Code:
#include <a_samp>
#include <SII>
#include <streamer>
#include <zcmd>
#include <sscanf2>

#define MAX_HOUSES 100//Lets define that we can have the max limit of our houses to 100.

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.

IsAdmin(playerid, level)
{
    if(IsPlayerAdmin(playerid)) return 1;
    if(CallRemoteFunction("GetPlayerAVSAdmin", "d", playerid) >= level) return 1;
    return 0;
}

CMD:createhouse(playerid,params[])
{
    if(!IsAdmin(playerid, 10)) 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".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id]  = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//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,0xFF0000FF,x,y,z,25.0,GetPlayerVirtualWorld(playerid));
    HouseCount++;
    return 1;
}

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
        format(file,sizeof(file),"FHouse/Houses/%i.ini",i);//Formating the house file
        INI_Open(file);//Opening the house file
        INI_WriteInt("Owned",1);//Setting in the ini file "Owned" to 1
        INI_WriteString("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;
}

CMD:sell(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(HInfo[i][Owned] == 0) return SendClientMessage(playerid,-1,"This house isn't owned");//Checking if the house is already owned.
        new pName[24];
        GetPlayerName(playerid,pName,sizeof(pName));//Retrieving the player's name.
        if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner] != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");//Checking if the house is owned but the owners name is different
        HInfo[i][Owned] = 0;//Setting the house owned var to 1.
        new file[60],string[100];//Creating the necessary vars.
        format(HInfo[i][Owner],24,"Nonusablenameforthishouse");//Setting the House Owner's var
        format(file,sizeof(file),"FHouse/Houses/%i.ini",i);//Formating the house file
        INI_Open(file);//Opening the house file
        INI_WriteInt("Owned",0);//Setting in the ini file "Owned" to 0
        INI_WriteString("Owner","Nonusablenameforthishouse");//Setting the "Owner" to the "Nonusablenameforthishouse".
        INI_Save();//Saving the ini
        INI_Close();//Closing the ini
        format(string,sizeof(string),"Owned: No \nPrice: %i \nOwner: None",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;
}

public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
    {
        if(checkpointid == 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(checkpointid == HouseExit[i])//Checking if the checkpointid is an House exit
        {
            SetPlayerPos(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;
}

stock LoadHouses()//Creating the stock function
{
    new file[60],houseowner[24];//creating the "file" var. And also creating the "houseowner" var so we can store it, when we are reading the house owner ini line.
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw every house
    {
        format(file,sizeof(file),"FAdmin/Houses/%i.ini",i);//Opening the house file with the current selected number with "i".
        if(INI_Exist(file)) break;//Checking if the ini house file exist, if not to stop there.
        INI_Open(file);//Opening the house ini
        HInfo[i][Price] = INI_ReadInt("Price");//Reading the price.
        HInfo[i][Owned] = INI_ReadInt("Owned");//Reading if it's owned.
        HInfo[i][XPos] = INI_ReadInt("XPos");//Reading the X float position.
        HInfo[i][YPos] = INI_ReadInt("YPos");//Reading the Y float position.
        HInfo[i][ZPos] = INI_ReadInt("ZPos");//Reading the Z float position.
        HInfo[i][VirtualWorld] = INI_ReadInt("VirtualWorld");//Reading the virtual world.
        INI_ReadString(houseowner,"Owner");//Reading the house owner.
        format(HInfo[i][Owner],24,"%s"houseowner);//Formating the "Owner" house id value to the red one.
        HouseEnter[i]  = CreateDynamicCP(x,y,z,1.5,HInfo[i][VirtualWorld]);//Creating the checkpoint and storing it in the HouseEnter value.
        HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HInfo[i][VirtualWorld]);//Creating the house exit checkpoint and storing it in the HouseExit value.
        new labelstring[100];//Creating the labelstring var.
        switch(HInfo[i][Owned])//Using the "switch" method to check if the house is owned
        {
            case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[i][Price]);}//If it isnt...
            case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Owner]);}//If it is...
        }
        HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,HInfo[i][VirtualWorld]);//Creating the label with the formatted string.
        HouseCount++;//+ counting the HouseCount var.
        INI_Close();//Closing the SII file.
    }
    return 1;
}

please help me Firecat
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 07/10/2011, 07:24 PM   #25
FireCat
High-roller
 
FireCat's Avatar
 
Join Date: Jul 2010
Posts: 2,322
Reputation: 609
Default Re: Creating a house system with checkpoints!

Quote:
Originally Posted by Zonoya View Post
FireCat i have a problem i get a bunch of errors on ur code

pawn Code:
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(102) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(102) : error 001: expected token: ")", but found "return"
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(148) : warning 213: tag mismatch
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(148) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Rhys\Desktop\samp03dsvr_RC1_win32 (2)\filterscripts\H_System.pwn(150) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.

i changed it abit to suit my Gm but its in ur main code itself in the Sell command and the OnPlayerEnterDynamicCP thing here is the code:

pawn Code:
#include <a_samp>
#include <SII>
#include <streamer>
#include <zcmd>
#include <sscanf2>

#define MAX_HOUSES 100//Lets define that we can have the max limit of our houses to 100.

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.

IsAdmin(playerid, level)
{
    if(IsPlayerAdmin(playerid)) return 1;
    if(CallRemoteFunction("GetPlayerAVSAdmin", "d", playerid) >= level) return 1;
    return 0;
}

CMD:createhouse(playerid,params[])
{
    if(!IsAdmin(playerid, 10)) 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".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id]  = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//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,0xFF0000FF,x,y,z,25.0,GetPlayerVirtualWorld(playerid));
    HouseCount++;
    return 1;
}

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
        format(file,sizeof(file),"FHouse/Houses/%i.ini",i);//Formating the house file
        INI_Open(file);//Opening the house file
        INI_WriteInt("Owned",1);//Setting in the ini file "Owned" to 1
        INI_WriteString("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;
}

CMD:sell(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(HInfo[i][Owned] == 0) return SendClientMessage(playerid,-1,"This house isn't owned");//Checking if the house is already owned.
        new pName[24];
        GetPlayerName(playerid,pName,sizeof(pName));//Retrieving the player's name.
        if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner] != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");//Checking if the house is owned but the owners name is different
        HInfo[i][Owned] = 0;//Setting the house owned var to 1.
        new file[60],string[100];//Creating the necessary vars.
        format(HInfo[i][Owner],24,"Nonusablenameforthishouse");//Setting the House Owner's var
        format(file,sizeof(file),"FHouse/Houses/%i.ini",i);//Formating the house file
        INI_Open(file);//Opening the house file
        INI_WriteInt("Owned",0);//Setting in the ini file "Owned" to 0
        INI_WriteString("Owner","Nonusablenameforthishouse");//Setting the "Owner" to the "Nonusablenameforthishouse".
        INI_Save();//Saving the ini
        INI_Close();//Closing the ini
        format(string,sizeof(string),"Owned: No \nPrice: %i \nOwner: None",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;
}

public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
    {
        if(checkpointid == 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(checkpointid == HouseExit[i])//Checking if the checkpointid is an House exit
        {
            SetPlayerPos(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;
}

stock LoadHouses()//Creating the stock function
{
    new file[60],houseowner[24];//creating the "file" var. And also creating the "houseowner" var so we can store it, when we are reading the house owner ini line.
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw every house
    {
        format(file,sizeof(file),"FAdmin/Houses/%i.ini",i);//Opening the house file with the current selected number with "i".
        if(INI_Exist(file)) break;//Checking if the ini house file exist, if not to stop there.
        INI_Open(file);//Opening the house ini
        HInfo[i][Price] = INI_ReadInt("Price");//Reading the price.
        HInfo[i][Owned] = INI_ReadInt("Owned");//Reading if it's owned.
        HInfo[i][XPos] = INI_ReadInt("XPos");//Reading the X float position.
        HInfo[i][YPos] = INI_ReadInt("YPos");//Reading the Y float position.
        HInfo[i][ZPos] = INI_ReadInt("ZPos");//Reading the Z float position.
        HInfo[i][VirtualWorld] = INI_ReadInt("VirtualWorld");//Reading the virtual world.
        INI_ReadString(houseowner,"Owner");//Reading the house owner.
        format(HInfo[i][Owner],24,"%s"houseowner);//Formating the "Owner" house id value to the red one.
        HouseEnter[i]  = CreateDynamicCP(x,y,z,1.5,HInfo[i][VirtualWorld]);//Creating the checkpoint and storing it in the HouseEnter value.
        HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HInfo[i][VirtualWorld]);//Creating the house exit checkpoint and storing it in the HouseExit value.
        new labelstring[100];//Creating the labelstring var.
        switch(HInfo[i][Owned])//Using the "switch" method to check if the house is owned
        {
            case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[i][Price]);}//If it isnt...
            case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Owner]);}//If it is...
        }
        HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,HInfo[i][VirtualWorld]);//Creating the label with the formatted string.
        HouseCount++;//+ counting the HouseCount var.
        INI_Close();//Closing the SII file.
    }
    return 1;
}

please help me Firecat
What are lines
102 148 and 150?
FireCat is offline   Reply With Quote
Old 07/10/2011, 07:53 PM   #26
=WoR=G4M3Ov3r
High-roller
 
Join Date: Nov 2010
Location: www.Ambrosia-Servers.com
Posts: 1,751
Reputation: 329
Default Re: Creating a house system with checkpoints!

GoodJob Cat !!!
=WoR=G4M3Ov3r is offline   Reply With Quote
Old 07/10/2011, 09:39 PM   #27
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: Creating a house system with checkpoints!

Quote:
Originally Posted by FireCat View Post
What are lines
102 148 and 150?
Line 102 is :
Code:
        if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner] != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");//Checking if the house is owned but the owners name is different
line 148 is :
Code:
            SetPlayerPos(HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
and line 150 is :
Code:
            SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"PlayerVirtualWorldHouse");//Setting the players virtual world to the one we stored.
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 07/10/2011, 10:10 PM   #28
FireCat
High-roller
 
FireCat's Avatar
 
Join Date: Jul 2010
Posts: 2,322
Reputation: 609
Default Re: Creating a house system with checkpoints!

Quote:
Originally Posted by Zonoya View Post
Line 102 is :
Code:
        if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner] != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");//Checking if the house is owned but the owners name is different
line 148 is :
Code:
            SetPlayerPos(HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
and line 150 is :
Code:
            SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"PlayerVirtualWorldHouse");//Setting the players virtual world to the one we stored.
Change them too:
pawn Code:
f(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner]) != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");//Checking if the house is owned but the owners name is different

pawn Code:
SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3

pawn Code:
SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"PlayerVirtualWorldHouse"));//Setting the players virtual world to the one we stored.
FireCat is offline   Reply With Quote
Old 07/10/2011, 10:12 PM   #29
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: Creating a house system with checkpoints!

thanks works now
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 07/10/2011, 10:16 PM   #30
gamer931215
High-roller
 
gamer931215's Avatar
 
Join Date: Feb 2010
Location: That box in front of your house stealing your wifi.
Posts: 1,090
Reputation: 322
Default Re: Creating a house system with checkpoints!

nice tutorial, but i suggest to explain a little bit more about how SII works and what it exactly does! (because if "newbies" dont know what it is, they will just copy/paste and learn nothing about it!), the same counts for sscanf, ZCMD and the streamer.

Just a small discription per include/plugin you use, and a discription about how to use them would be good enough for players to also understand what the're copying and allowing them to edit the script for their needs.
__________________

Thanks to Zh3r0 for this awesome signature!
gamer931215 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Cali-Houses: Create a house anywhere, dynamic house creating! California Filterscripts 257 31/05/2018 02:23 AM
Need some help with loading Checkpoints from mySQL house jesse237 Help Archive 2 12/02/2011 10:52 PM
need help creating house cacauagiar Help Archive 0 09/01/2011 10:08 AM
Creating new house? iFuzo Help Archive 10 21/05/2010 02:08 PM
In-Game House Creating System Help Trill Help Archive 12 21/12/2009 04:28 PM


All times are GMT. The time now is 05:39 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.