SA-MP Forums Archive
/exit command doesn't work - 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: /exit command doesn't work (/showthread.php?tid=213545)



/exit command doesn't work - xemper - 19.01.2011

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.


Re: /exit command doesn't work - armyoftwo - 19.01.2011

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


Re: /exit command doesn't work - Antonio [G-RP] - 19.01.2011

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


Re: /exit command doesn't work - armyoftwo - 19.01.2011

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


Re: /exit command doesn't work - xemper - 19.01.2011

When I add your newest code my compiler stops responding..


Re: /exit command doesn't work - Joe Staff - 19.01.2011

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?


Re: /exit command doesn't work - xemper - 19.01.2011

Silenthunter: My server has a login system... :P


Re: /exit command doesn't work - Joe Staff - 19.01.2011

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


Re: /exit command doesn't work - Scenario - 19.01.2011

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!


Re: /exit command doesn't work - xemper - 19.01.2011

Haha okay. Im new at scripting.. :P