Hotkeys IN-Game
#1

Hello everyone, I want an hotkey "f" which will make the user say: /enter or /exit.

Something like this:
http://forum.sa-mp.com/showthread.ph...ghlight=hotkey

But I'm not sure how to start this is where I get:

Code:
public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if( newkeys & KEY_SECONDARY_ATTACK )
    {
        NOT SURE WHAT TO ADD HERE!
    }
    return 1;
}
Reply
#2

Several different options here. I'll give you a quick example though...

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by RealCop228
View Post
Several different options here. I'll give you a quick example though...

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
    }
    return 1;
}
I appreciate ur help, but it still gives me some errors:

Code:
C:\Users\Vinay\Downloads\megag.pwn(13965) : error 017: undefined symbol "X"
C:\Users\Vinay\Downloads\megag.pwn(13967) : error 017: undefined symbol "X"
C:\Users\Vinay\Downloads\megag.pwn(13968) : error 017: undefined symbol "INTERIOR"
C:\Users\Vinay\Downloads\megag.pwn(13970) : error 017: undefined symbol "X"
C:\Users\Vinay\Downloads\megag.pwn(13972) : error 017: undefined symbol "X"
C:\Users\Vinay\Downloads\megag.pwn(13973) : error 017: undefined symbol "INTERIOR"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Lines:
Code:
  if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
        {
            SetPlayerPos(playerid, X, Y, Z);
            SetPlayerInterior(playerid, INTERIOR);
        }
Reply
#4

X, Y, Z)

It's your possitions where the need to be.. You need to replace them!
Reply
#5

Quote:
Originally Posted by Scrillex
View Post
X, Y, Z)

It's your possitions where the need to be.. You need to replace them!
No, no! You don't get it. It shouldn't only work at one specific location.

I want it to automaticlly do /enter or /exit before a dynamic door/business/house etc. ! No matter the coordinates
Reply
#6

Are you using ZCMD for commands?

Also, do you already have both /enter and /exit commands scripted?
Reply
#7

Quote:
Originally Posted by RealCop228
View Post
Are you using ZCMD for commands?

Also, do you already have both /enter and /exit commands scripted?
Yeah, I use ZCMD. And yes, I got them both scripted!
Reply
#8

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(EnteredInterior[playerid]) return cmd_exit(playerid, "");
        else return cmd_enter(playerid, "");
    }
    return 1;
}
The above code will basically call /enter or /exit depending on the validity of this bool statement:

pawn Code:
EnteredInterior[playerid]
You will want to make this a true statement in your /enter command, so towards the bottom or something, do this:

pawn Code:
EnteredInterior[playerid] = true;
... and you'll want to make this a false statement in your /exit command, so towards the bottom or something, add this:

pawn Code:
EnteredInterior[playerid] = false;
Don't forget to add this at the top of your script...

pawn Code:
new bool:EnteredInterior[MAX_PLAYERS] = false;
Reply
#9

Quote:
Originally Posted by RealCop228
View Post
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(EnteredInterior[playerid]) return cmd_exit(playerid, "");
        else return cmd_enter(playerid, "");
    }
    return 1;
}
The above code will basically call /enter or /exit depending on the validity of this bool statement:

pawn Code:
EnteredInterior[playerid]
You will want to make this a true statement in your /enter command, so towards the bottom or something, do this:

pawn Code:
EnteredInterior[playerid] = true;
... and you'll want to make this a false statement in your /exit command, so towards the bottom or something, add this:

pawn Code:
EnteredInterior[playerid] = false;
Don't forget to add this at the top of your script...

pawn Code:
new bool:EnteredInterior[MAX_PLAYERS] = false;
Appreciate it, testing it now!
Reply
#10

It worked! Thank you so F*cking much!!!! I love you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)