SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/04/2018, 06:54 PM   #11
kovac
Banned
 
Join Date: Mar 2018
Posts: 182
Reputation: 14
Default Re: Problem with houses.

Quote:
I'm using KEY_FIRE or w/e for that
Then just replace
CMD:exit(playerid)
with (key n)
if(newkeys & KEY_NO)

and

CMD:enter(playerid)
with (key y)
if(newkeys & KEY_YES)

and of couse, move it all under public OnPlayerKeyStateChange

KEY_FIRE is for mouse click and I don't recommend using it because it's pressed often.
kovac is offline   Reply With Quote
Old 16/04/2018, 07:11 PM   #12
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

Quote:
Originally Posted by kovac View Post
Then just replace
CMD:exit(playerid)
with (key n)
if(newkeys & KEY_NO)

and

CMD:enter(playerid)
with (key y)
if(newkeys & KEY_YES)

and of couse, move it all under public OnPlayerKeyStateChange

KEY_FIRE is for mouse click and I don't recommend using it because it's pressed often.
Mnope, still the same problem
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:12 PM   #13
kovac
Banned
 
Join Date: Mar 2018
Posts: 182
Reputation: 14
Default Re: Problem with houses.

Give me your code when you create that vehicle
kovac is offline   Reply With Quote
Old 16/04/2018, 07:13 PM   #14
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

Quote:
Originally Posted by MaestrulFritz View Post
Mnope, still the same problem

Actually now, I can't enter the house anymore.

Code:
 	    for(new i = 0; i < MAX_HOUSES; i++)
    	{
        	if(IsPlayerInRangeOfPoint(playerid, 2.5, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2]))
        	{
            SetPlayerPos(playerid, HouseData[i][housePos][0], HouseData[i][housePos][1], HouseData[i][housePos][2]);
            SetPlayerFacingAngle(playerid, HouseData[i][housePos][3] - 180.0);
            SetPlayerVirtualWorld(playerid, HouseData[i][houseExteriorVW]); // I don't know why you use this, you should have a default virtual world and reset it
            SetCameraBehindPlayer(playerid);
            IsInHouse[playerid] = false;
            break;
        	}
    	}
    	
    	for(new i = 0; i < MAX_HOUSES; i++)
    	{
        	if(IsPlayerInRangeOfPoint(playerid, 2.5, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2]))
        	{
            if(HouseData[i][houseLocked]) return SendErrorMessage(playerid, "You cannot enter a locked house.");
            SetPlayerPos(playerid, HouseData[i][houseInt][0], HouseData[i][houseInt][1], HouseData[i][houseInt][2]);
            SetPlayerFacingAngle(playerid, HouseData[i][houseInt][3]);
            SetPlayerInterior(playerid, HouseData[i][houseInterior]);

            SetPlayerVirtualWorld(playerid, i); // You can just use house id as virtual world, it won't mix with others
            SetCameraBehindPlayer(playerid);
            IsInHouse[playerid] = true;
            break;
        	}
		}
// this is how it looks for business for example //


        if ((id = Business_Nearest(playerid)) != -1)
	    {

	        if (BusinessData[id][bizLocked])
	            return SendErrorMessage(playerid, "This business is closed by the owner.");

			if (PlayerData[playerid][pTask] && !PlayerData[playerid][pStoreTask])
			{
			    PlayerData[playerid][pStoreTask] = 1;
			    Dialog_Show(playerid, ShowOnly, DIALOG_STYLE_MSGBOX, "Retail Store", "This business is a Retail Store. You can purchase many items here using the /buy command.\nThere are many useful things that you can purchase here, which are added to your inventory.\n\nThe most useful item is the GPS System, as this device allows you to find what you need.\nYou can leave this business at any time by pressing the 'F' key at the door.", "Close", "");

			    if (IsTaskCompleted(playerid))
				{
    				PlayerData[playerid][pTask] = 0;
					ShowPlayerFooter(playerid, "You have ~g~completed~w~ all your tasks!");
				}
			}
			if (BusinessData[id][bizType] == 11 || BusinessData[id][bizType] == 12)
   			{
                GiveMoney(playerid, -5);
                BusinessData[id][bizVault] += 5;
			    SendClientMessage(playerid, COLOR_ORANGE, "You have paid 5$ for the entrance.");
			    
			}
			SetPlayerPos(playerid, BusinessData[id][bizInt][0], BusinessData[id][bizInt][1], BusinessData[id][bizInt][2]);
			SetPlayerFacingAngle(playerid, BusinessData[id][bizInt][3]);

			SetPlayerInterior(playerid, BusinessData[id][bizInterior]);
			SetPlayerVirtualWorld(playerid, BusinessData[id][bizID] + 6000);

			SetCameraBehindPlayer(playerid);
			PlayerData[playerid][pBusiness] = BusinessData[id][bizID];

			if (strlen(BusinessData[id][bizMessage]) && strcmp(BusinessData[id][bizMessage], "NULL", true)) {
			    SendClientMessage(playerid, COLOR_DEPARTMENT, BusinessData[id][bizMessage]);
			}
			return 1;
		}
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:16 PM   #15
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

Here:

Code:
CMD:veh(playerid, params[])
{
	static
	    model[32],
		color1,
		color2;

    if (PlayerData[playerid][pAdmin] < 3)
	    return SendErrorMessage(playerid, "You don't have permission to use this command.");

	if (sscanf(params, "s[32]I(-1)I(-1)", model, color1, color2))
	    return SendSyntaxMessage(playerid, "/veh [model id/name] <color 1> <color 2>");

	if ((model[0] = GetVehicleModelByName(model)) == 0)
	    return SendErrorMessage(playerid, "Invalid model ID.");

	static
	    Float:x,
	    Float:y,
	    Float:z,
	    Float:a,
		vehicleid;

	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, a);

	vehicleid = CreateVehicle(model[0], x, y + 2, z, a, color1, color2, 0);

	if (GetPlayerInterior(playerid) != 0)
	    LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));

	if (GetPlayerVirtualWorld(playerid) != 0)
		SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));

	//if (IsABoat(vehicleid) || IsAPlane(vehicleid) || IsAHelicopter(vehicleid))
 	PutPlayerInVehicle(playerid, vehicleid, 0);

	ResetVehicle(vehicleid);
	
    SetEngineStatus(vehicleid, true);
	CoreVehicles[vehicleid][vehTemporary] = true;
	SendServerMessage(playerid, "You have spawned a %s (%d, %d).", ReturnVehicleModelName(model[0]), color1, color2);
	return 1;
}
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:20 PM   #16
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

https://imgur.com/a/sFqJU

Here you can see, I am outside the house, and after entering the house everything just vanishes.

This applies for any static/dynamic vehicle
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:40 PM   #17
kovac
Banned
 
Join Date: Mar 2018
Posts: 182
Reputation: 14
Default Re: Problem with houses.

How about creating some debug messages

PHP Code:
// On vehicle spawn
new string[128];
format(stringsizeof(string), "World: %d"GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1string);

// On house leave
new string[128];
format(stringsizeof(string), "World: %d"GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1string); 
kovac is offline   Reply With Quote
Old 16/04/2018, 07:47 PM   #18
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

It's most likely with the houses..I'll try that now.
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:50 PM   #19
MaestrulFritz
Little Clucker
 
Join Date: Mar 2014
Location: Romania
Posts: 28
Reputation: 0
Default Re: Problem with houses.

Quote:
Originally Posted by kovac View Post
How about creating some debug messages

PHP Code:
// On vehicle spawn
new string[128];
format(stringsizeof(string), "World: %d"GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1string);

// On house leave
new string[128];
format(stringsizeof(string), "World: %d"GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1string); 
Yes, the message appears as expected.
MaestrulFritz is offline   Reply With Quote
Old 16/04/2018, 07:52 PM   #20
kovac
Banned
 
Join Date: Mar 2018
Posts: 182
Reputation: 14
Default Re: Problem with houses.

Okay, are the worlds same in both messages?
kovac 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
Problem with Houses. Drago987 Scripting Help 2 24/02/2014 06:23 PM
Houses problem AnonScripter Scripting Help 2 08/11/2013 11:18 AM
Problem houses NekErM@N Help Archive 4 12/02/2011 11:10 AM
Houses problem Razvann Help Archive 2 02/01/2010 06:52 PM


All times are GMT. The time now is 04:11 AM.


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