House system help
#1

I need help with

I want to enter house without any command when I stand in house pick up its auto enter in to house
Reply
#2

You can make a checkpoint at the house's door, and OnPlayerEnterCheckPoint you can SetPlayerPos and Interior etc, which is the inside of the house.
Reply
#3

I can't do that with pickup??
Reply
#4

You can. If you use a streamer make sure to place the code in public OnPlayerPickupDynamicPickup, if you use normal pickups without streamer, the code goes under public OnPlayerPickupPickup. To do this, you should make a new variable on top of the script, like, housepickup or something. Then when loading houses, assign the Create(Dynamic)Pickup function to the variable[houseid]. Then under OnPlayerPickup(Dynamic)Pickup you can check the pickupid, and set the correct position.
How I would do it:
pawn Код:
//includes
#define MAX_HOUSES 100 //define how big you want the MAX_HOUSES array
new HousePickup[MAX_HOUSES]; //create the new variable with the size defined above

//some other code

public LoadHouses() //use your loading callback
{
    //your loading code, if you use a loop or something you can assign the function to the variable like this
    HousePickup[i] = Create(Dynamic)Pickup(......);// the [i] is the houseid
    //some moar code probably
}

public OnPlayerPickup(Dynamic)Pickup(pickupid) //this is called when picking up a pickup
{
    for(new i=0; i < MAX_HOUSES; i++) //loop trough all houses
    {
        if(HousePickup[i] == pickupid) //if the variable 'i' in the HousePickup variable matches the pickupid, continue
        {  
        //set the position and world, interior e.t.c. of the player to the corresponding houseid
        }
    }
}

//rest of script
I hope you get it like that
Reply
#5

Or with a "hotkey" example, while you near the house entrance and you press ENTER(or F) you will enter the house
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK) // Key ENTER
		{
			for(new i=0; i < sizeof(HouseInfo); i++) //here the variable of the HouseInfo
			{
			    if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][hEX], HouseInfo[i][hEY], HouseInfo[i][hEZ])) //hEX, hEY, hEZ are the coordinate of the house entrance
			    {
			        if(HouseInfo[i][hLocked] == 0) // the variable if the house is closed or not
			        {
			        	SetPlayerPos(playerid, HouseInfo[i][hExX], HouseInfo[i][hExY], HouseInfo[i][hExZ]); // hExX, hExY, hExZ are the coordinates you will be set that are the coordinates of the Exit point from the house
				}
			    }
			}
		}
return 1;
}
Reply
#6

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK) // Key ENTER
        {
            for(new i=0; i < sizeof(HouseInfo); i++) //here the variable of the HouseInfo
            {
                if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][hEX], HouseInfo[i][hEY], HouseInfo[i][hEZ])) //hEX, hEY, hEZ are the coordinate of the house entrance
                {
                    if(HouseInfo[i][hLocked] == 0) // the variable if the house is closed or not
                    {
                        SetPlayerPos(playerid, HouseInfo[i][hExX], HouseInfo[i][hExY], HouseInfo[i][hExZ]); // hExX, hExY, hExZ are the coordinates you will be set that are the coordinates of the Exit point from the house
                }
                }
            }
        }
return 1;
}
C:\Users\DELL\Desktop\TKA\filterscripts\GarHouse.p wn(349) : error 017: undefined symbol "i"

Plz i want fix now
Reply
#7

Quote:
Originally Posted by Muhammad1
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK) // Key ENTER
        {
            for(new i=0; i < sizeof(HouseInfo); i++) //here the variable of the HouseInfo
            {
                if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][hEX], HouseInfo[i][hEY], HouseInfo[i][hEZ])) //hEX, hEY, hEZ are the coordinate of the house entrance
                {
                    if(HouseInfo[i][hLocked] == 0) // the variable if the house is closed or not
                    {
                        SetPlayerPos(playerid, HouseInfo[i][hExX], HouseInfo[i][hExY], HouseInfo[i][hExZ]); // hExX, hExY, hExZ are the coordinates you will be set that are the coordinates of the Exit point from the house
                }
                }
            }
        }
return 1;
}
C:\Users\DELL\Desktop\TKA\filterscripts\GarHouse.p wn(349) : error 017: undefined symbol "i"

Plz i want fix now
What is the line 349?
Reply
#8

i fixed it Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)