House system help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House system help (
/showthread.php?tid=454269)
House system help -
Muhammad1 - 28.07.2013
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
Re: House system help -
JimmyCh - 28.07.2013
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.
Re: House system help -
Muhammad1 - 28.07.2013
I can't do that with pickup??
Re: House system help -
Jstylezzz - 28.07.2013
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
Re: House system help -
Sk1lleD - 28.07.2013
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;
}
Re: House system help -
Muhammad1 - 28.07.2013
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
Re: House system help -
wumpyc - 28.07.2013
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?
Re: House system help -
Muhammad1 - 28.07.2013
i fixed it Thanks