Garsino House System - help -
Saddin - 30.12.2012
Hi all, I'm using Garsino House System, the last version. And I want to change that when player pickup up a dynamic pickup he teleport into the house. I want to make it happen with "enter" button onplayerkeystatechange:
Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
new string[256], tmpstring[50];
foreach(Houses, h)
{
if(pickupid == HousePickupOut[h])
{
SetPVarInt(playerid, "LastHouseCP", h);
if(!strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE))
{
SetPlayerHouseInterior(playerid, h);
ShowInfoBoxEx(playerid, COLOUR_INFO, I_HMENU);
break;
}
format(tmpstring, sizeof(tmpstring), "HouseKeys_%d", h);
if(GetPVarInt(playerid, tmpstring) == 1)
{
SetPlayerHouseInterior(playerid, h);
break;
}
if(strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE) && strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
{
if(hInfo[h][HousePassword] == udb_hash("INVALID_HOUSE_PASSWORD"))
{
switch(hInfo[h][ForSale])
{
case 0: ShowInfoBox(playerid, LABELTEXT2, hInfo[h][HouseOwner], hInfo[h][HouseValue], h);
case 1:
{
switch(hInfo[h][HousePrivacy])
{
case 0: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In", "Select", "Cancel");
case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
}
}
}
break;
}
}
if(!strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE) && hInfo[h][HouseValue] > 0 && GetPVarInt(playerid, "JustCreatedHouse") == 0)
{
format(string, sizeof(string), HMENU_BUY_HOUSE, hInfo[h][HouseValue]);
ShowPlayerDialog(playerid, HOUSEMENU+4, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
break;
}
}
if(pickupid == HousePickupInt[h])
{
switch(GetPVarInt(playerid, "HousePreview"))
{
case 0: ExitHouse(playerid, h);
#if GH_HINTERIOR_UPGRADE == true
case 1:
{
GetPVarString(playerid, "HousePrevName", tmpstring, 50);
format(string, sizeof(string), HMENU_BUY_HINTERIOR, tmpstring, GetPVarInt(playerid, "HousePrevValue"));
ShowPlayerDialog(playerid, HOUSEMENU+17, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
}
#endif
}
break;
}
}
}
return 1;
}
This to turn into onplayerkeystatechange, when player press enter button.
Re: Garsino House System - help -
ikbenremco - 30.12.2012
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SECONDARY_ATTACK)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
new string[256], tmpstring[50];
foreach(Houses, h)
{
if(pickupid == HousePickupOut[h])
{
SetPVarInt(playerid, "LastHouseCP", h);
if(!strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE))
{
SetPlayerHouseInterior(playerid, h);
ShowInfoBoxEx(playerid, COLOUR_INFO, I_HMENU);
break;
}
format(tmpstring, sizeof(tmpstring), "HouseKeys_%d", h);
if(GetPVarInt(playerid, tmpstring) == 1)
{
SetPlayerHouseInterior(playerid, h);
break;
}
if(strcmp(hInfo[h][HouseOwner], pNick(playerid), CASE_SENSETIVE) && strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
{
if(hInfo[h][HousePassword] == udb_hash("INVALID_HOUSE_PASSWORD"))
{
switch(hInfo[h][ForSale])
{
case 0: ShowInfoBox(playerid, LABELTEXT2, hInfo[h][HouseOwner], hInfo[h][HouseValue], h);
case 1:
{
switch(hInfo[h][HousePrivacy])
{
case 0: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In", "Select", "Cancel");
case 1: ShowPlayerDialog(playerid, HOUSEMENU+23, DIALOG_STYLE_LIST, INFORMATION_HEADER, "Buy House (Step 1)\nBreak In\nEnter House", "Select", "Cancel");
}
}
}
break;
}
}
if(!strcmp(hInfo[h][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE) && hInfo[h][HouseValue] > 0 && GetPVarInt(playerid, "JustCreatedHouse") == 0)
{
format(string, sizeof(string), HMENU_BUY_HOUSE, hInfo[h][HouseValue]);
ShowPlayerDialog(playerid, HOUSEMENU+4, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
break;
}
}
if(pickupid == HousePickupInt[h])
{
switch(GetPVarInt(playerid, "HousePreview"))
{
case 0: ExitHouse(playerid, h);
#if GH_HINTERIOR_UPGRADE == true
case 1:
{
GetPVarString(playerid, "HousePrevName", tmpstring, 50);
format(string, sizeof(string), HMENU_BUY_HINTERIOR, tmpstring, GetPVarInt(playerid, "HousePrevValue"));
ShowPlayerDialog(playerid, HOUSEMENU+17, DIALOG_STYLE_MSGBOX, INFORMATION_HEADER, string, "Buy", "Cancel");
}
#endif
}
break;
}
}
}
return 1;
}
NOTE: NOT TESTED.
Re: Garsino House System - help -
Threshold - 30.12.2012
That doesn't have to be tested in order to see that you have failed. Where are you getting the value for pickupid from?? First of all, you need the coordinates of your pickup.
pawn Код:
CreatePickup(model, 1, 156.23, 1996.24, -19.532, -1)
So our coordinates would be:
156.23, 1996.24, -19.532
Remember to make sure that your pickup type is '1'. As the second parameter in the above code shows, so the pickup will not disappear when the player enters it, see
HERE for further information.
Then we will need to take those coordinates, and insert them into our OnPlayerKeyStateChange, seeing as you are looking for the 'enter' button, I am assuming you have the default settings, as ****** usually explains to me in this case, the keys are only what the player has defined, so by assumption, I'm guessing your KEY_SECONDARY_ATTACK is currently set as 'Enter/Return'.
The code would be as follows:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SECONDARY_ATTACK)
{
if(IsPlayerInRangeOfPoint(playerid, 2, 156.23, 1996.24, -19.532)) //This is where we insert the coordinates, which can be replaced by your enum data as well.
{
SetPlayerInterior(playerid, houseinterior); //Your house interior will go here.
SetPlayerPos(playerid, houseposx, houseposy, houseposz); //Your house coords will go here
//SetPlayerFacingAngle(playerid, houseangle); //Optional, but might be necessary.
}
//Code continues...
}
return 1;
}
This is an example code of what you should really be doing.
Re: Garsino House System - help -
Saddin - 30.12.2012
Ok. I made this:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SECONDARY_ATTACK)
{new h = GetClosetHouseIntID(playerid);
if(h == -1) return 1;
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][ExitX],House[h][ExitY],House[h][ExitZ]))
{
SetPlayerPos(playerid,House[h][EnterX],House[h][EnterY],House[h][EnterZ]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
return 1;
}
}
if(newkeys == KEY_SECONDARY_ATTACK)
{ new h = GetClosetHouseID(playerid);
if(h == -1) return 1;
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][EnterX],House[h][EnterY],House[h][EnterZ]))
{
if(House[h][On_Sell] == 0 && House[h][Lock] == 0)
{
SetPlayerPos(playerid,House[h][ExitX],House[h][ExitY],House[h][ExitZ]);
SetPlayerInterior(playerid,House[h][IntID]);
SetPlayerVirtualWorld(playerid,House[h][VW]);
}
else return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"House is locked/Is not on sale.");
if(strcmp(House[h][Owner],GetName(playerid),false) == 0)
{
new Year, Month, Day;
getdate(Year, Month, Day);
House[h][DayEnter] = Day;
House[h][MonthEnter] = Month;
CheckHouse(h);
}
return 1;
}
}
return 1;
}
It works me only for the first case when I want to get out of the house, but when I want to get in the house it wont work....
Re: Garsino House System - help -
Threshold - 30.12.2012
Give this a shot:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SECONDARY_ATTACK)
{
new h = GetClosetHouseID(playerid);
if(h != -1)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][ExitX],House[h][ExitY],House[h][ExitZ]))
{
SetPlayerPos(playerid,House[h][EnterX],House[h][EnterY],House[h][EnterZ]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
return 1;
}
}
h = GetClosetHouseIntID(playerid);
if(h != -1)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][EnterX],House[h][EnterY],House[h][EnterZ]))
{
if(House[h][On_Sell] != 0 || House[h][Lock] != 0) return SCM(playerid,COLOR_RED,"ERROR: "COL_WHITE"House is locked/Is not for sale.");
SetPlayerPos(playerid,House[h][ExitX],House[h][ExitY],House[h][ExitZ]);
SetPlayerInterior(playerid,House[h][IntID]);
SetPlayerVirtualWorld(playerid,House[h][VW]);
if(strcmp(House[h][Owner],GetName(playerid),false) == 0)
{
new Year, Month, Day;
getdate(Year, Month, Day);
House[h][DayEnter] = Day;
House[h][MonthEnter] = Month;
CheckHouse(h);
}
}
}
}
return 1;
}
I have a feeling that "if(h == -1) return 1" may have been stopping the code from reaching the second range.
Re: Garsino House System - help -
Saddin - 31.12.2012
It's not working :S