Enter Key to enter in a building
#1

Hi everyone,
i already wrote about this problem in another topic, but i think that it is the problem that i very need to resolve.
I need that when i want to enter in a building, i have to press the enter key... can you suggest me some script? I tried with this:
Код:
OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
 if(newkeys & KEY_SECONDARY_ATTACK)
{
enter script
}
It give me four errors:

Код:
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 029: invalid expression, assumed zero
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 017: undefined symbol "oldkeys"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24707) : error 001: expected token: ";", but found "if"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24707) : error 017: undefined symbol "newkeys"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
So...what i can do? Can you help me?
Reply
#2

pawn Код:
OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
 if(newkeys & KEY_SECONDARY_ATTACK)
{
enter script
}
You're missing a couple of brackets there. A callback is usually opened with a bracket, so why wouldn't this be?

pawn Код:
public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        // enter script
    }
    return 1;
}
Reply
#3

I applied your modification and the answer of pawno was:

Код:
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 029: invalid expression, assumed zero
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 017: undefined symbol "oldkeys"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24707) : error 017: undefined symbol "newkeys"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24874) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#4

Show more code around it.
Reply
#5

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
            if(newkeys & KEY_SECONDARY_ATTACK)
            {
             // enter script
             }
    return 1;
}
the New keys is first:

Look

pawn Код:
public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
to
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
Reply
#6

pawn Код:
OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
if(newkeys == KEY_SECONDARY_ATTACK)
{
enter script
}
Reply
#7

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Show more code around it.
This is all the enter script!

pawn Код:
//  if(strcmp(cmd, "/entra", true) == 0)
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
if(newkeys & KEY_SECONDARY_ATTACK) {
        for(new i = 0; i < sizeof(Houses); i++)
        {
                if (PlayerToPoint(1.0, playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]))
                {
                //if(GetPlayerVirtualWorld(playerid) == Houses[i][EnterWorldщ])
                //{
                    if(PlayerInfo[playerid][pHouseKey] == i || Houses[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >= 1)
                    {
                        PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                        SetPlayerInterior(playerid,Houses[i][ExitInterior]);
                        SetPlayerPos(playerid,Houses[i][ExitX],Houses[i][ExitY],Houses[i][ExitZ]);
                        SetPlayerVirtualWorld(playerid,i);
                        SetPlayerFacingAngle(playerid,Houses[i][ExitAngle]);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~r~Chiuso", 5000, 1);
                    }
                //}

            }
        }
        for(new i = 0; i < sizeof(Building); i++)
        {
            if (PlayerToPoint(1.0, playerid,Building[i][EnterX], Building[i][EnterY], Building[i][EnterZ]))
            {
                if(GetPlayerVirtualWorld(playerid) == Building[i][EnterWorld])
                {
                    if(Building[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >=  1)
                    {
                        if(GetPlayerCash(playerid) >= Building[i][EntranceFee])
                        {
                            PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                            SetPlayerInterior(playerid,Building[i][ExitInterior]);
                            SetPlayerVirtualWorld(playerid,i);
                            SetPlayerPos(playerid,Building[i][ExitX],Building[i][ExitY],Building[i][ExitZ]);
                            SetPlayerFacingAngle(playerid,Building[i][ExitAngle]);
                            GivePlayerCash(playerid,-Building[i][EntranceFee]);
                        }
                        else
                        {
                            PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                            SetPlayerInterior(playerid,Building[i][ExitInterior]);
                            SetPlayerVirtualWorld(playerid,i);
                            SetPlayerPos(playerid,Building[i][ExitX],Building[i][ExitY],Building[i][ExitZ]);
                            SetPlayerFacingAngle(playerid,Building[i][ExitAngle]);
                        }
                    }
                    else
                    {
                    GameTextForPlayer(playerid, "~r~Chiuso", 5000, 1);
                    }
                }
            }
        }
        for(new i = 0; i < sizeof(Businesses); i++)
            {
                if (PlayerToPoint(1.0, playerid,Businesses[i][EnterX], Businesses[i][EnterY], Businesses[i][EnterZ]))
                {
                    if(GetPlayerVirtualWorld(playerid) == Businesses[i][EnterWorld])
                    {
                        if(PlayerInfo[playerid][pBizKey] == i || GetPlayerCash(playerid) >= Businesses[i][EntranceCost])
                        {
                            if(PlayerInfo[playerid][pBizKey] != i)
                            {
                                if(Businesses[i][Locked] == 1 && PlayerInfo[playerid][pAdmin] == 0)
                                {
                                    GameTextForPlayer(playerid, "~r~Business Chiuso.", 5000, 1);
                                    return 1;
                                }
                                if(Businesses[i][Products] == 0)
                                {
                                    GameTextForPlayer(playerid, "~r~Non ci sono prodotti.", 5000, 1);
                                    return 1;
                                }
                                new businesstype[126];
                                if(Businesses[i][BizType] == 1) { businesstype = "[INFO] Comandi disponibili: /mangia"; }
                                else if(Businesses[i][BizType] == 2) { businesstype = "[INFO] Comandi disponibili: /compracellulare"; }
                                else if(Businesses[i][BizType] == 3) { businesstype = "[INFO] Comandi disponibili: /compra"; }
                                else if(Businesses[i][BizType] == 4) { businesstype = "[INFO] Comandi disponibili: /compraarma"; }
                                else if(Businesses[i][BizType] == 5) { businesstype = "[INFO] Comandi disponibili: /pub"; }
                                else if(Businesses[i][BizType] == 6) { businesstype = "[INFO] Comandi disponibili: /vestiti"; }
                                else if(Businesses[i][BizType] == 7) { businesstype = "[INFO] Comandi disponibili: /bere"; }
                                else if(Businesses[i][BizType] == 12) { businesstype = "[INFO] Comandi disponibili: /comprapc - /installamsn - /installaantivirus"; }
                                else if(Businesses[i][BizType] == 13) { businesstype = "[INFO] Comandi disponibili: /assicura"; }
                                PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                                GivePlayerCash(playerid,-Businesses[i][EntranceCost]);
                                format(string, sizeof(string), "[INFO:] Hai pagato $%d per entrare in %s.", Businesses[i][EntranceCost],Businesses[i][BusinessName]);
                                SendClientMessage(playerid,COLOR_LIGHTYELLOW2,string);
                                SendClientMessage(playerid,COLOR_LIGHTYELLOW2,businesstype);
                                Businesses[i][Till] += Businesses[i][EntranceCost];
                                Businesses[i][Products]--;
                                SetPlayerInterior(playerid,Businesses[i][ExitInterior]);
                                SetPlayerPos(playerid,Businesses[i][ExitX],Businesses[i][ExitY],Businesses[i][ExitZ]);
                                SetPlayerVirtualWorld(playerid,i);
                                SetPlayerFacingAngle(playerid,Businesses[i][ExitAngle]);
                                if(Businesses[i][BizType] == 8)
                                {
                                    PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                                    SoftAirPlayers ++;
                                    SetPlayerVirtualWorld(playerid,0);
                                    PlayerSoftAiring[playerid] = 1;
                                    SetPlayerInterior(playerid,10);
                                    new rand = random(sizeof(SoftAirSpawns));
                                    SetPlayerPos(playerid, SoftAirSpawns[rand][0], SoftAirSpawns[rand][1], SoftAirSpawns[rand][2]);
                                    TogglePlayerControllable(playerid, 0);
                                }
                                if(Businesses[i][BizType] == 9)
                                {
                                    PlayerKarting[playerid] = 1;
                                    SendClientMessage(playerid, COLOR_GREEN, "Puoi adesso partecipare alla Kart Race. Prendi un Kart");
                                    SetPlayerInterior(playerid,Businesses[i][EnterInterior]);
                                    SetPlayerVirtualWorld(playerid,Businesses[i][EnterWorld]);
                                    SetPlayerPos(playerid,Businesses[i][EnterX],Businesses[i][EnterY],Businesses[i][EnterZ]);
                                    SetPlayerFacingAngle(playerid,Businesses[i][EnterAngle]);
                                }
                                SaveBusinesses();
                            }
                            else
                            {
                                new businesstype[126];
                                if(Businesses[i][BizType] == 1) { businesstype = "[INFO] Comandi disponibili: /mangia"; }
                                else if(Businesses[i][BizType] == 2) { businesstype = "[INFO] Comandi disponibili: /compracellulare"; }
                                else if(Businesses[i][BizType] == 3) { businesstype = "[INFO] Comandi disponibili: /compra"; }
                                else if(Businesses[i][BizType] == 4) { businesstype = "[INFO] Comandi disponibili: /compraarma"; }
                                else if(Businesses[i][BizType] == 5) { businesstype = "[INFO] Comandi disponibili: /pub"; }
                                else if(Businesses[i][BizType] == 6) { businesstype = "[INFO] Comandi disponibili: /vestiti"; }
                                else if(Businesses[i][BizType] == 7) { businesstype = "[INFO] Comandi disponibili: /bere"; }
                                else if(Businesses[i][BizType] == 12) { businesstype = "[INFO] Comandi disponibili: /comprapc - /installamsn - /installaantivirus"; }
                                PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
                                SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] Entrata Free per il proprietario.");
                                SendClientMessage(playerid,COLOR_LIGHTYELLOW2, businesstype);
                                SetPlayerInterior(playerid,Businesses[i][ExitInterior]);
                                SetPlayerPos(playerid,Businesses[i][ExitX],Businesses[i][ExitY],Businesses[i][ExitZ]);
                                SetPlayerVirtualWorld(playerid,i);
                                SetPlayerFacingAngle(playerid,Businesses[i][ExitAngle]);
                                if(Businesses[i][BizType] == 8)
                                {
                                    SoftAirPlayers ++;
                                    SetPlayerVirtualWorld(playerid,0);
                                    PlayerSoftAiring[playerid] = 1;
                                    SetPlayerInterior(playerid,10);
                                    new rand = random(sizeof(SoftAirSpawns));
                                    SetPlayerPos(playerid, SoftAirSpawns[rand][0], SoftAirSpawns[rand][1], SoftAirSpawns[rand][2]);
                                    TogglePlayerControllable(playerid, 0);
                                }
                                if(Businesses[i][BizType] == 9)
                                {
                                    PlayerKarting[playerid] = 1;
                                    SendClientMessage(playerid, COLOR_GREEN, "Puoi adesso partecipare alla Kart Race. Prendi un Kart");
                                    SetPlayerInterior(playerid,Businesses[i][EnterInterior]);
                                    SetPlayerVirtualWorld(playerid,Businesses[i][EnterWorld]);
                                    SetPlayerPos(playerid,Businesses[i][EnterX],Businesses[i][EnterY],Businesses[i][EnterZ]);
                                    SetPlayerFacingAngle(playerid,Businesses[i][EnterAngle]);
                                }
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERRORE:] Non hai abbastanza soldi per entrare!");
                        }
                    }
                }
            }
        return 1;
    }
The error message is the same:
Код:
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 029: invalid expression, assumed zero
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24706) : error 017: undefined symbol "oldkeys"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24707) : error 017: undefined symbol "newkeys"
C:\Users\Marco\Desktop\Atlantis City\gamemodes\crp.pwn(24874) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.

Quote:
Originally Posted by axxelac
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
            if(newkeys & KEY_SECONDARY_ATTACK)
            {
             // enter script
             }
    return 1;
}
the New keys is first:

Look

pawn Код:
public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
to
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
I tried but it doesn't change...
Reply
#8

Show about 10-20 lines before this.
Reply
#9

There aren't lines before this. I explain... the lines before this codes are admin commands...so the script starts here...
Reply
#10

Quote:
Originally Posted by MarcoWesley
Посмотреть сообщение
There aren't lines before this. I explain... the lines before this codes are admin commands...so the script starts here...
So this is inside OnPlayerCommandText? That's the problem, it should be outside any callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)