[HELP] /Exit command.
#1

- Hello.
I've working to an Dynamic House System.
Works fine all commands. Except one. /Exit.
I enter In-Game, I use command /Enter to enter in house, but, when I use /Exit, teleports me under map.
Code: www.pastebin.com;

pawn Код:
CMD:iesi(playerid, params[])
{
    for(new i = 0; i < MAX_CASE; i++)
    {
        if(InHouse[playerid] == 1)
        {
            SetPlayerPos(playerid, CasaInfo[i][cX], CasaInfo[i][cY], CasaInfo[i][cZ]);
            SetPlayerInterior(playerid, 0);
            SendClientMessage(playerid, -1, "{FF0000}[CASĂ]: {FFFFFF}Ai iesit dintr-o casă.");
        }
    }
    return 1;
}
Everything else works fine.
What I did wrong?
Reply
#2

it will teleport player to Exit position of ALL Houses !!

because you used it inside a loop without a condition !

you have to store house it which playerid entered, or with your loop get closest house id ...

i'll give you an example.

make a new player variable and when player uses /enter, swtore house id into it and use it for exit

pawn Код:
new PHouseID[MAX_PLAYERS];

//inside "/enter" CMD:
PHouseID[playerid] = hid;
//hid is houseid that player entered.

CMD:iesi(playerid, params[])
{
  new hid = PHouseID[playerid];
  if(InHouse[playerid] == 1)
  {
      SetPlayerPos(playerid, CasaInfo[hid][cX], CasaInfo[hid][cY], CasaInfo[hid][cZ]);
      SetPlayerInterior(playerid, 0);
      SendClientMessage(playerid, -1, "{FF0000}[CASĂ]: {FFFFFF}Ai iesit dintr-o casă.");
  }
    return 1;
}
Reply
#3

Quote:
Originally Posted by M4D
Посмотреть сообщение
it will teleport player to Exit position of ALL Houses !!

because you used it inside a loop without a condition !

you have to store house it which playerid entered, or with your loop get closest house id ...

i'll give you an example.

make a new player variable and when player uses /enter, swtore house id into it and use it for exit

pawn Код:
new PHouseID[MAX_PLAYERS];

//inside "/enter" CMD:
PHouseID[playerid] = hid;
//hid is houseid that player entered.

CMD:iesi(playerid, params[])
{
  new hid = PHouseID[playerid];
  if(InHouse[playerid] == 1)
  {
      SetPlayerPos(playerid, CasaInfo[hid][cX], CasaInfo[hid][cY], CasaInfo[hid][cZ]);
      SetPlayerInterior(playerid, 0);
      SendClientMessage(playerid, -1, "{FF0000}[CASĂ]: {FFFFFF}Ai iesit dintr-o casă.");
  }
    return 1;
}
Thank you. I'm so clumsy sometimes. I don't need code, I just need to learn. I knew this, but I didn't realise what I did.

Variable command I transformed it to:

pawn Код:
new InHouse[MAX_PLAYERS][MAX_HOUSES];
When player enters:

pawn Код:
new InHouse[playerid][i] = 1;
And I put condition, how @M4D said:

pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
{
    if(InHouse[playerid][i] == 1)
    {
        // Rest of the code.
    }
}
So, thanks @M4D. +Rep.
Reply
#4

i've explained it for you and i suggest you 2 ways to do it.
also i edited your code to tell you what i say.

Quote:
Originally Posted by HY
Посмотреть сообщение
And I put condition, how @M4D said:

pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
{
    if(InHouse[playerid][i] == 1)
    {
        // Rest of the code.
    }
}
you didn't understand what i said.

"InHouse[playerid][i]" only check player is inside a house or no ! we need to store "House ID" and use it to exit

look at my code again.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)