/exit command doesn't work
#1

pawn Код:
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]))
                {
                    if(HouseEntered[playerid] == i)
                    {
                        SetPlayerInterior(playerid,0);
                        SetPlayerPos(playerid,HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez]);
                        PlayerInfo[playerid][pInt] = 0;
                        PlayerInfo[playerid][pLocal] = 255;
                        SetCameraBehindPlayer(playerid);
                        SetPlayerVirtualWorld(playerid,0);
                        HouseEntered[playerid] = 255;
                        if(HouseInfo[i][hHel] == 1)
                        {
                            new Float:tempheal;
                            GetPlayerHealth(playerid,tempheal);
                            if(tempheal < 100.0)
                            {
                                SetPlayerHealth(playerid,100.0);
                            }
                        }
                        return 1;
                    }
                }
            }
Compiler doesn't find any errors, but it doesn't work when I try to exit a buyed house.
Reply
#2

pawn Код:
if(strcmp(cmd, "/exit", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
                        SetPlayerInterior(playerid,0);
                        SetPlayerPos(playerid,HouseInfo[HouseEntered[playerid]][hEntrancex],HouseInfo[HouseEntered[playerid]][hEntrancey],HouseInfo[HouseEntered[playerid]][hEntrancez]);
                        PlayerInfo[playerid][pInt] = 0;
                        PlayerInfo[playerid][pLocal] = 255;
                        SetCameraBehindPlayer(playerid);
                        SetPlayerVirtualWorld(playerid,0);
                        HouseEntered[playerid] = 255;
                        if(HouseInfo[HouseEntered[playerid]][hHel] == 1)
                        {
                            new Float:tempheal;
                            GetPlayerHealth(playerid,tempheal);
                            if(tempheal < 100.0)
                            {
                                SetPlayerHealth(playerid,100.0);
                            }
                        }
                        return 1;
            }
You should use common sense next time..

Now you should add the check your self, to check if a player is in a house
pawn Код:
if(HouseEntered[playerid] == 0)
{
     SendClientMessage(playerid, COLOR_YELLOW, "You're not in  a house");
     return 1;
}
Something like this

EDIT: edited some code
Reply
#3

Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/exit", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
                        SetPlayerInterior(playerid,0);
                        SetPlayerPos(playerid,HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez]);
                        PlayerInfo[playerid][pInt] = 0;
                        PlayerInfo[playerid][pLocal] = 255;
                        SetCameraBehindPlayer(playerid);
                        SetPlayerVirtualWorld(playerid,0);
                        HouseEntered[playerid] = 255;
                        if(HouseInfo[i][hHel] == 1)
                        {
                            new Float:tempheal;
                            GetPlayerHealth(playerid,tempheal);
                            if(tempheal < 100.0)
                            {
                                SetPlayerHealth(playerid,100.0);
                            }
                        }
                        return 1;
            }
You should use common sense next time..

Now you should add the check your self, to check if a player is in a house
pawn Код:
if(HouseEntered[playerid] == 0)
{
     SendClientMessage(playerid, COLOR_YELLOW, "You're not in  a house");
     return 1;
}
Something like this
Now hes going to get "undefined symbol: i"
Maybe YOU should use common sense next time
Reply
#4

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
Now hes going to get "undefined symbol: i"
Maybe YOU should use common sense next time
Are you blind or what?
pawn Код:
if(strcmp(cmd, "/exit", true) == 0)
    {
         if(HouseEntered[playerid] == 255)
         {
             SendClientMessage(playerid, COLOR_YELLOW, "You're not in  a house");
             return 1;
        }
        if(IsPlayerConnected(playerid))
        {
                        SetPlayerInterior(playerid,0);
                        SetPlayerPos(playerid,HouseInfo[HouseEntered[playerid]][hEntrancex],HouseInfo[HouseEntered[playerid]][hEntrancey],HouseInfo[HouseEntered[playerid]][hEntrancez]);
                        PlayerInfo[playerid][pInt] = 0;
                        PlayerInfo[playerid][pLocal] = 255;
                        SetCameraBehindPlayer(playerid);
                        SetPlayerVirtualWorld(playerid,0);
                        if(HouseInfo[HouseEntered[playerid]][hHel] == 1)
                        {
                            new Float:tempheal;
                            GetPlayerHealth(playerid,tempheal);
                            if(tempheal < 100.0)
                            {
                                SetPlayerHealth(playerid,100.0);
                            }
                        }
                        HouseEntered[playerid] = 255;
                        return 1;
            }
This should work now
Reply
#5

When I add your newest code my compiler stops responding..
Reply
#6

You're missing a bracket at the end. Also why do you guys keep adding IsPlayerConnected checks in your commands? How in the world would a player type in a command if he's not connected?
Reply
#7

Silenthunter: My server has a login system... :P
Reply
#8

IsPlayerConnected doesn't check if they're logged in, it justchecks if the player is on your server, and a player will have a hard time typing in commands if he's not on your server
Reply
#9

You could do as I did and make a stock function similar to "IsPlayerConnected", but it also checks if they are logged in as well!
Reply
#10

Haha okay. Im new at scripting.. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)