Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
Hi guys!
I need a little help with entering and exiting bizzes.
I've made a system, that teleports u to the right place'n'stuff, but the thing, that I can't figure out is how to get the ID of the closest biz. I need some kind of system to get the closest biz by the biz x, y and z params.
The teleport'n'stuff code:
pawn Код:
public EnterNExitBiz(playerid, bizid)
{
if(PlayerInfo[playerid][InABiz] == 0) // OUT
{
new string[128];
format(string, sizeof(string), "%s", BizInfo[bizid][fName]);
if(BizInfo[firmaid][fClosed] == 1) return GameTextForPlayer(playerid, "~r~Da biz is closed!", 5000, 1);
if(PlayerInfo[playerid][BizKey] == bizid)
{
SetPlayerInterior(playerid, BizInfo[bizid][fInterj88r]);
PlayerInfo[playerid][Int] = BizInfo[bizid][fInterj88r];
SetPlayerPos(playerid, BizInfo[bizid][fIntX], BizInfo[bizid][fIntY], BizInfo[bizid][fIntZ]);
GameTextForPlayer(playerid, string, 5000, 1);
if(bizid == 2) return PlayerInfo[playerid][Riidepoes] = 1; // IGNORE THIS
}
}
return 1;
}
The thing, that I need, is the id of the closest biz.
It's suposed to be got by the next params:
pawn Код:
Float:fEntranceX,
Float:fEntranceY,
Float:fEntranceZ,
((Translated from Estonian
))
Re: Enter&Exit biz - Help needed. -
Mike_Peterson - 18.12.2012
I assume you aren't using pickups or checkpoints, so. Here is the if statement
pawn Код:
for(new bizids=0; bizids < MAX_BUSINESSES; bizids++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0,BizInfo[bizids][fEntranceX],BizInfo[bizids][fEntranceY],BizInfo[bizids][fEntranceZ]))
You might want to break the loop once you are entering the biz
Re: Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
Like this? (Firma = biz)
pawn Код:
public NearBiz(playerid)
{
new kokkufirmasi = FirmasiKokku();
for(new i = 1; i <= kokkufirmasi; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, FirmaInfo[i][fSisseX], FirmaInfo[i][fSisseY], FirmaInfo[i][fSisseZ]))
{
return 1;
}
else
{
return 0;
}
}
return 0;
}
And how can I use this to get the ID of the biz?
(Like this? if(NearBiz(playerid))...)
Re: Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
kokkufirmasi and firmasikokku mean MAX_BIZZES
firmainfo means BizInfo and Sisse means Entrance.
Re: Enter&Exit biz - Help needed. -
Mike_Peterson - 18.12.2012
Well, always try these things, don't ask before you try
Re: Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
Well I did it like this and it didn't work...
OnPlayerKeyStateChange
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SPRINT)
{
//Some stuff....//
else
{
EnterNExitBiz(playerid);
}
}
...
The new EnterNExitBiz:
pawn Код:
public EnterNExitBiz(playerid)
{
new kokkufirmasi = FirmasiKokku();
for(new i = 1; i <= kokkufirmasi; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, FirmaInfo[i][fSisseX], FirmaInfo[i][fSisseY], FirmaInfo[i][fSisseZ]))
{
if(M2ngijaInfo[playerid][Firmas] == 0) // Outside
{
new string[128];
format(string, sizeof(string), "%s", FirmaInfo[i][fNimi]);
if(FirmaInfo[i][fLukus] == 1) return GameTextForPlayer(playerid, "~w~Firma on ~r~suletud!", 5000, 1);
if(M2ngijaInfo[playerid][FirmaV6ti] == i)
{
SetPlayerInterior(playerid, FirmaInfo[i][fInterj88r]);
M2ngijaInfo[playerid][Int] = FirmaInfo[i][fInterj88r];
SetPlayerPos(playerid, FirmaInfo[i][fIntX], FirmaInfo[i][fIntY], FirmaInfo[i][fIntZ]);
GameTextForPlayer(playerid, string, 5000, 1);
if(i == 2) return M2ngijaInfo[playerid][Riidepoes] = 1;
}
}
}
else
{
return 0;
}
}
return 1;
}
Re: Enter&Exit biz - Help needed. -
Mike_Peterson - 18.12.2012
i think you'll have to add a break after the if(i == 2), to stop the loop. (why continue if u already found what u were looking for?)
Re: Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
When the id of the biz is 2, it sets the playerinfo parameter *clothesshop* to 1.
Re: Enter&Exit biz - Help needed. -
Mike_Peterson - 18.12.2012
Oh I see, well still what I said applies, but it's not neccesary.
So, the big question? Will it blen.......Work?
Re: Enter&Exit biz - Help needed. -
tsonn1 - 18.12.2012
Nope, nothing...