Help with this OnPlayerKey
#1

FIXED
Reply
#2

Its asking to define "done"

I dont know what your using that for so give this a try


Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    for(new idx=0; idx<MAX_DOORS; idx++) // Dynamic Doors
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]))
        {
            if(DoorInfo[idx][dIInt] == 83 && DoorInfo[idx][dIVW] == 8473 && BankBlock)
            {
                SendClientMessage(playerid, COLOR_GREY, "You can't enter the bank as it is being robbed at the moment.");
                return 1;
            }
            if(DoorInfo[idx][dCInt])
            {
                GameTextForPlayer(playerid, "~w~Loading Objects", 3500, 3);
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("EnterExitTimer", 5000, false, "i", playerid);
                PlayerInfo[playerid][pSpawnFreeze] = 1;
            }
            PlayerInfo[playerid][pSpawnFreeze] = 0;
            SetPlayerInterior(playerid, DoorInfo[idx][dIInt]);
            SetPlayerVirtualWorld(playerid, DoorInfo[idx][dIVW]);
            SetPlayerFacingAngle(playerid, DoorInfo[idx][dIA]);
            SetCameraBehindPlayer(playerid);
            SetPlayerPos(playerid, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]);
            return 1;
        }
    }
    for(new idx=1; idx<MAX_BIZ; idx++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            if(!BizInfo[idx][bStatus] && PlayerInfo[playerid][pBiz] != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "This business is closed.");
            if(BizInfo[idx][bType] == 1) // 24/7 Business
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, -27.3025,-57.6649,1003.5469);
                SetPlayerFacingAngle(playerid, 357.5915);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 6);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's 24/7 Market (( /list & /buy )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
            else if(BizInfo[idx][bType] == 2) // Clothes Shop Business
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, 207.0638,-139.9965,1003.5078);
                SetPlayerFacingAngle(playerid, 356.3849);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's Clothes Shop (( /buyclothes & /buytoys )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
            else if(BizInfo[idx][bType] == 3) // Ammunation Business
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, 285.8044,-85.9956,1001.5229);
                SetPlayerFacingAngle(playerid, 358.9898);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 4);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's Ammunation (( /list & /buy )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
            else if(BizInfo[idx][bType] == 4) // Club Business
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, 493.4252,-24.3061,1000.6797);
                SetPlayerFacingAngle(playerid, 0.2432);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 17);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's Club (( /list & /buy )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
            else if(BizInfo[idx][bType] == 5) // Advertisement Agency
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, 834.1631,7.4883,1004.1797);
                SetPlayerFacingAngle(playerid, 86.7239);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's Advertisement Agency (( /ad )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
            else if(BizInfo[idx][bType] == 6) // Fast Food
            {
                format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerPos(playerid, 372.3830,-133.2579,1001.4922);
                SetPlayerFacingAngle(playerid, 0.4216);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 5);
                SetPlayerVirtualWorld(playerid, idx+100);
                format(string, sizeof(string), "** Welcome to %s's Fast Food (( /list /buy )) **", BizInfo[idx][bOwner]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                return 1;
            }
        }
    }
    for(new idx=1; idx<MAX_HOUSES; idx++) // Dynamic Houses
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
        {
            if(!HouseInfo[idx][hStatus] && PlayerInfo[playerid][pHouse] != idx && PlayerInfo[playerid][pVHouse] != idx) return SendClientMessage(playerid, COLOR_GREY, "This house is locked.");
            format(string, sizeof(string), "* %s pushes the door and enters the house.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerVirtualWorld(playerid, idx+500);
            if(HouseInfo[idx][hLevel] == 1)
            {
                SetPlayerPos(playerid, 243.9951,304.9418,999.1484);
                SetPlayerFacingAngle(playerid, 267.0980);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 1);
            }
            else if(HouseInfo[idx][hLevel] == 2)
            {
                SetPlayerPos(playerid, 2259.6702,-1135.8542,1050.6328);
                SetPlayerFacingAngle(playerid, 267.3974);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 10);
            }
            else if(HouseInfo[idx][hLevel] == 3)
            {
                SetPlayerPos(playerid, 2308.8254,-1212.8070,1049.0234);
                SetPlayerFacingAngle(playerid, 359.8550);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 6);
            }
            else if(HouseInfo[idx][hLevel] == 4)
            {
                SetPlayerPos(playerid, 260.7436,1237.5563,1084.2578);
                SetPlayerFacingAngle(playerid, 1.6415);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 9);
            }
            else if(HouseInfo[idx][hLevel] == 5)
            {
                SetPlayerPos(playerid, -42.5742,1405.6521,1084.4297);
                SetPlayerFacingAngle(playerid, 359.1347);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 8);
            }
            else if(HouseInfo[idx][hLevel] == 6)
            {
                SetPlayerPos(playerid, 2468.6787,-1698.2617,1013.5078);
                SetPlayerFacingAngle(playerid, 89.1791);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 2);
            }
            else if(HouseInfo[idx][hLevel] == 7)
            {
                SetPlayerPos(playerid, 2365.2183,-1135.4014,1050.8750);
                SetPlayerFacingAngle(playerid, 359.8550);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 8);
            }
            else if(HouseInfo[idx][hLevel] == 8)
            {
                SetPlayerPos(playerid, 2270.1270,-1210.4855,1047.5625);
                SetPlayerFacingAngle(playerid, 89.4224);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 10);
            }
            else if(HouseInfo[idx][hLevel] == 9)
            {
                SetPlayerPos(playerid, 2324.4424,-1149.2057,1050.7101);
                SetPlayerFacingAngle(playerid, 0.7248);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 12);
            }
            else if(HouseInfo[idx][hLevel] == 10)
            {
                SetPlayerPos(playerid, 83.0863,1322.3020,1083.8662);
                SetPlayerFacingAngle(playerid, 359.5183);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 9);
            }
        }
    }
    for(new idx=0; idx<MAX_DOORS; idx++) // Dynamic Doors
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]) && GetPlayerVirtualWorld(playerid) == DoorInfo[idx][dIVW] && GetPlayerInterior(playerid) == DoorInfo[idx][dIInt])
        {
            if(BankRobber[playerid] && BankBlock && GetPlayerInterior(playerid) == 83 && GetPlayerVirtualWorld(playerid) == 8473)
            {
                new Rob = BankRobber[playerid]-1;
                DisablePlayerCheckpoint(playerid);
                BankRobbersCount --;
                format(BankRobbers[Rob], MAX_PLAYER_NAME, "");
                DeliverMoney[playerid] = 0;
                //
                foreach(Player, i)
                {
                    if(BankRobber[i] || PlayerInfo[i][pFac] == 1)
                    {
                        if(Rob == 0) TextDrawHideForPlayer(i, Textdraw1);
                        else if(Rob == 1) TextDrawHideForPlayer(i, Textdraw2);
                        else if(Rob == 2) TextDrawHideForPlayer(i, Textdraw3);
                        else if(Rob == 3) TextDrawHideForPlayer(i, Textdraw4);
                        else if(Rob == 4) TextDrawHideForPlayer(i, Textdraw5);
                    }
                }
                format(string, sizeof(string), "** %s has went out of the bank before loading money and has failed the robbery. **", RPN(playerid));
                SendRobberyMessage(COLOR_LIGHTRED, string);
                SendCopMessage(COLOR_LIGHTRED, string);
                BankRobber[playerid] = 0;
                if(BankRobbersCount == 0)
                {
                    TextDrawHideForAll(Textdraw0);
                    TextDrawHideForAll(Textdraw1);
                    TextDrawHideForAll(Textdraw2);
                    TextDrawHideForAll(Textdraw3);
                    TextDrawHideForAll(Textdraw4);
                    TextDrawHideForAll(Textdraw5);
                    BankRobbery = 0;
                    RobberyStarted = 0;
                    format(string, sizeof(string), "** The bank robbery has ended, $%d were stolen and $%d were saved. **", TotalStolen*10000, (TotalRobbers*10000-(TotalStolen*10000)));
                    SendClientMessageToAll(COLOR_YELLOW, string);
                    TotalRobbers = 0;
                    new copsonline;
                    foreach(Player, i)
                    {
                        if(IsACop(i)) copsonline++;
                    }
                    foreach(Player, i)
                    {
                        if(IsACop(i))
                        {
                            new Saved = (TotalRobbers*10000-(TotalStolen*10000));
                            GiveZaiatMoney(i, Saved/copsonline);
                            format(string, sizeof(string), "** You have received your cut from the saved money. ($%d)", Saved/copsonline);
                            SendClientMessage(i, COLOR_LIME, string);
                        }
                    }
                }
                return 1;
            }
            if(DoorInfo[idx][dCExt])
            {
                GameTextForPlayer(playerid, "~w~Loading Objects", 3500, 3);
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("EnterExitTimer", 5000, false, "i", playerid);
                PlayerInfo[playerid][pSpawnFreeze] = 1;
            }
            PlayerInfo[playerid][pSpawnFreeze] = 0;
            SetPlayerInterior(playerid, DoorInfo[idx][dOInt]);
            SetPlayerVirtualWorld(playerid, DoorInfo[idx][dOVW]);
            SetPlayerFacingAngle(playerid, DoorInfo[idx][dOA]);
            SetCameraBehindPlayer(playerid);
            SetPlayerPos(playerid, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]);
            break;
        }
    }
    if(IsPlayerInRangeOfPoint(playerid, 2, 243.9951,304.9418,999.1484) || IsPlayerInRangeOfPoint(playerid, 2, 2259.6702,-1135.8542,1050.6328) || IsPlayerInRangeOfPoint(playerid, 2, 2308.8254,-1212.8070,1049.0234) || IsPlayerInRangeOfPoint(playerid, 2, 260.7436,1237.5563,1084.2578)
    || IsPlayerInRangeOfPoint(playerid, 2, -42.5742,1405.6521,1084.4297) || IsPlayerInRangeOfPoint(playerid, 2, 2468.6787,-1698.2617,1013.5078) || IsPlayerInRangeOfPoint(playerid, 2, 2365.2183,-1135.4014,1050.8750) || IsPlayerInRangeOfPoint(playerid, 2, 2270.1270,-1210.4855,1047.5625)
    || IsPlayerInRangeOfPoint(playerid, 2, 2324.4424,-1149.2057,1050.7101) || IsPlayerInRangeOfPoint(playerid, 2, 83.0863,1322.3020,1083.8662)) // Houses
    {
        new idx;
        idx = GetPlayerVirtualWorld(playerid)-500;
        if(idx < MAX_HOUSES && HouseInfo[idx][hLevel])
        {
            format(string, sizeof(string), "* %s pushes the door and exits the house.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerPos(playerid, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
            break;
        }
    }
    if(IsPlayerInRangeOfPoint(playerid, 2, -27.3025,-57.6649,1003.5469) || IsPlayerInRangeOfPoint(playerid, 2, 207.0638,-139.9965,1003.5078) || IsPlayerInRangeOfPoint(playerid, 2, 285.8044,-85.9956,1001.5229) || IsPlayerInRangeOfPoint(playerid, 2, 493.4252,-24.3061,1000.6797) || IsPlayerInRangeOfPoint(playerid, 2, 834.1631,7.4883,1004.1797) || IsPlayerInRangeOfPoint(playerid, 2, 372.3830,-133.2579,1001.4922)) // 24/7 || Clothes Shop || Ammunation || Club || Advertisement Agency || FastFood
    {
        new idx;
        idx = GetPlayerVirtualWorld(playerid)-100;
        if(idx < MAX_BIZ && BizInfo[idx][bType])
        {
            format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        break;
    }
Reply
#3

Now I get this
Код:
C:\Users\Michael\Desktop\*\non school related\GTA\My server\ARP\gamemodes\ARP.pwn(16937) : warning 217: loose indentation
C:\Users\Michael\Desktop\*\non school related\GTA\My server\ARP\gamemodes\ARP.pwn(17215) : error 024: "break" or "continue" is out of context
C:\Users\Michael\Desktop\*\non school related\GTA\My server\ARP\gamemodes\ARP.pwn(17230) : error 024: "break" or "continue" is out of context
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#4

delete the break; on line 17215 and 17230.
Reply
#5

Fixed, Now I have another problem, I enter the place with the "f" key and it enters me then exits me fast
Reply
#6

Put an
Код:
else if
on the exit

Should be this give it a try:

Код:
else if(IsPlayerInRangeOfPoint(playerid, 2, -27.3025,-57.6649,1003.5469) || IsPlayerInRangeOfPoint(playerid, 2, 207.0638,-139.9965,1003.5078) || IsPlayerInRangeOfPoint(playerid, 2, 285.8044,-85.9956,1001.5229) || IsPlayerInRangeOfPoint(playerid, 2, 493.4252,-24.3061,1000.6797) || IsPlayerInRangeOfPoint(playerid, 2, 834.1631,7.4883,1004.1797) || IsPlayerInRangeOfPoint(playerid, 2, 372.3830,-133.2579,1001.4922)) // 24/7 || Clothes Shop || Ammunation || Club || Advertisement Agency || FastFood
    {
        new idx;
        idx = GetPlayerVirtualWorld(playerid)-100;
        if(idx < MAX_BIZ && BizInfo[idx][bType])
        {
            format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        break;
    }
Reply
#7

Sorry, but I am confused.
Reply
#8

On the part of your code where you want it to exit you need to put "else if" instead of "if" it thinks your pressing F to exit when your entering because it's finding the wrong coordinates.
Reply
#9

Would you mind doing it for me? I will rep and
Reply
#10

send me the working code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)