SA-MP Forums Archive
go to house, bussines or other with enter! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: go to house, bussines or other with enter! (/showthread.php?tid=124347)



go to house, bussines or other with enter! - povilaslt2 - 30.01.2010

How to do this? i verry need this!


Re: go to house, bussines or other with enter! - GaGlets(R) - 30.01.2010

its simple..

You need to make if cmds.

Just make is key Enter and then if is at pickup or is at point..


Re: go to house, bussines or other with enter! - Mr L - 30.01.2010

use this to go inside house:
Код:
if(strcmp(cmd, "/goinhouse", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goinhouse [HouseNumber]");
					return 1;
				}
				new housenum = strval(tmp);
				SetPlayerInterior(playerid, HouseInfo[housenum][hInt]);
				SetPlayerPos(playerid,HouseInfo[housenum][hExitx],HouseInfo[housenum][hExity],HouseInfo[housenum][hExitz]);
				GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
				SetPlayerVirtualWorld(playerid, HouseInfo[housenum][hVW]);
				HouseEntered[playerid] = housenum;
			}
		}
		return 1;
	}
this to go to house outside
Код:
if(strcmp(cmd, "/gotohouse", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotohouse [HouseNumber]");
					return 1;
				}
				new housenum = strval(tmp);
				SetPlayerPos(playerid,HouseInfo[housenum][hEntrancex],HouseInfo[housenum][hEntrancey],HouseInfo[housenum][hEntrancez]);
				GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
			}
		}
		return 1;
	}
and this to go biz
Код:
	if(strcmp(cmd, "/biz", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /biz [biznumber]");
					return 1;
				}
				new housenum = strval(tmp);
				SetPlayerInterior(playerid, BizzInfo[housenum][bInterior]);
				SetPlayerPos(playerid,BizzInfo[housenum][bExitX],BizzInfo[housenum][bExitY],BizzInfo[housenum][bExitZ]);
				GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
			}
		}
		return 1;
	}
and this to enter somewhere for no admin level
Код:
if(strcmp(cmd, "/enter", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
			for(new i = 0; i < sizeof(HouseInfo); i++)
			{
				if (PlayerToPoint(3, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
				{
					//printf("Found House :%d",i);
					if(PlayerInfo[playerid][pPhousekey] == i || HouseInfo[i][hLock] == 0)
					{
						SetPlayerInterior(playerid,HouseInfo[i][hInt]);
						SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
						GameTextForPlayer(playerid, "~w~Welcome Home", 5000, 1);
						PlayerInfo[playerid][pInt] = HouseInfo[i][hInt];
						PlayerInfo[playerid][pLocal] = i;
					}
					else
					{
						GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
					}
				}
			}
			for(new i = 0; i < sizeof(BizzInfo); i++)
			{
				if (PlayerToPoint(3, playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
				{
					//printf("Found House :%d",i);
					if(!IsACop(playerid) && i == 3)
					{
					  SendClientMessage(playerid, COLOR_GREY, "  Cops only !");
					  return 1;
					}
					if(PlayerInfo[playerid][pPbiskey] == i || GetPlayerMoney(playerid) >= BizzInfo[i][bEntranceCost])
					{
						if(PlayerInfo[playerid][pPbiskey] != i)
						{
							if(BizzInfo[i][bLocked] == 1)
							{
								GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
								return 1;
							}
							if(BizzInfo[i][bProducts] == 0)
							{
								GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
								return 1;
							}
							GivePlayerMoney(playerid,-BizzInfo[i][bEntranceCost]);
							format(string, sizeof(string), "~r~-$%d~n~~w~type /exit~n~to get out", BizzInfo[i][bEntranceCost]);
							BizzInfo[i][bTill] += BizzInfo[i][bEntranceCost];
							ExtortionBiz(i, BizzInfo[i][bEntranceCost]);
							BizzInfo[i][bProducts]--;
							OnPropUpdate();
							GameTextForPlayer(playerid, string, 5000, 3);
						}
						SetPlayerInterior(playerid,BizzInfo[i][bInterior]);
						SetPlayerPos(playerid,BizzInfo[i][bExitX],BizzInfo[i][bExitY],BizzInfo[i][bExitZ]);
						PlayerInfo[playerid][pInt] = BizzInfo[i][bInterior];
						PlayerInfo[playerid][pLocal] = i+99;
						new dood[MAX_PLAYER_NAME];
						GetPlayerName(playerid, dood, sizeof(dood));
						format(string, sizeof(string), "%s payed $%d to enter biz %d", dood, BizzInfo[i][bEntranceCost], i);
						printf("%s", string);
						PayLog(string);
						//PlayerInfo[playerid][pLocal] = i;
					}
					else
					{
						GameTextForPlayer(playerid, "~r~You dont have the cash", 5000, 1);
					}
				}
			}
			for(new i = 0; i < sizeof(SBizzInfo); i++)
			{
				if (PlayerToPoint(3, playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
				{
					if(PlayerInfo[playerid][pPbiskey] == i || GetPlayerMoney(playerid) >= SBizzInfo[i][sbEntranceCost])
					{
						if(PlayerInfo[playerid][pPbiskey] != i)
						{
							if(SBizzInfo[i][sbLocked] == 1)
							{
								GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
								return 1;
							}
							if(SBizzInfo[i][sbProducts] == 0)
							{
								GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
								return 1;
							}
							if(i == 10)
							{
							  PaintballPlayers ++;
							  PlayerPaintballing[playerid] = 1;
							  new rand = random(sizeof(PaintballSpawns));
								SetPlayerPos(playerid, PaintballSpawns[rand][0], PaintballSpawns[rand][1], PaintballSpawns[rand][2]);
								TogglePlayerControllable(playerid, 0);
							}
							else if(i == 11)
							{
							  PlayerKarting[playerid] = 1;
							  SendClientMessage(playerid, TEAM_GROVE_COLOR, "You can now parcipitate in a Karting Race, grab a Kart.");
							}
							else
							{
							  return 1;
							}
							GivePlayerMoney(playerid,-SBizzInfo[i][sbEntranceCost]);
							gSpentCash[playerid] = GetPlayerMoney(playerid);
							SBizzInfo[i][sbProducts]--;
							SBizzInfo[i][sbTill] += SBizzInfo[i][sbEntranceCost];
							ExtortionSBiz(i, SBizzInfo[i][sbEntranceCost]);
							new dood[MAX_PLAYER_NAME];
							GetPlayerName(playerid, dood, sizeof(dood));
							format(string, sizeof(string), "%s payed $%d to enter sbiz %d", dood, SBizzInfo[i][sbEntranceCost], i);
							printf("%s", string);
							PayLog(string);
							OnPropUpdate();
						}
					}
					else
					{
						GameTextForPlayer(playerid, "~r~You dont have the cash", 5000, 1);
					}
				}
			}
		}
		return 1;
	}
and this to exit
Код:
if(strcmp(cmd, "/exit", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
			for(new i = 0; i < sizeof(HouseInfo); i++)
			{
				//printf("House :%d",i);
				if (PlayerToPoint(3, playerid,HouseInfo[i][hExitx], HouseInfo[i][hExity], HouseInfo[i][hExitz]))
				{
					SetPlayerInterior(playerid,0);
					SetPlayerPos(playerid,HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez]);
					PlayerInfo[playerid][pInt] = 0;
					PlayerInfo[playerid][pLocal] = 255;
					if(HouseInfo[i][hHel] == 1)
					{
						new Float:tempheal;
						GetPlayerHealth(playerid,tempheal);
						if(tempheal < 100.0)
						{
							SetPlayerHealth(playerid,100.0);
						}
					}
				}
			}
			for(new i = 0; i < sizeof(BizzInfo); i++)
			{
				//printf("Bizz :%d",i);
				if (PlayerToPoint(3, playerid,BizzInfo[i][bExitX], BizzInfo[i][bExitY], BizzInfo[i][bExitZ]))
				{
					SetPlayerInterior(playerid,0);
					PlayerInfo[playerid][pInt] = 0;
					SetPlayerPos(playerid,BizzInfo[i][bEntranceX],BizzInfo[i][bEntranceY],BizzInfo[i][bEntranceZ]);
					PlayerInfo[playerid][pLocal] = 255;
				}
			}
			else if(NoFuel[playerid] == 1)
			{
			  TogglePlayerControllable(playerid, 1);
				RemovePlayerFromVehicle(playerid);
				NoFuel[playerid] = 0;
			}
		}
		return 1;
	}



Re: go to house, bussines or other with enter! - GaGlets(R) - 30.01.2010

yes just like that but dont make cmds remove cmd line and add keyline


Re: go to house, bussines or other with enter! - povilaslt2 - 30.01.2010

No, no, no. I need: press the key "Enter" and you enter in the house.


Re: go to house, bussines or other with enter! - Mr L - 31.01.2010

use OnPlayerKeyStateChange and put your ENTER cmd there