SA-MP Forums Archive
using get player keys, should be easy help + rep. - 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)
+--- Thread: using get player keys, should be easy help + rep. (/showthread.php?tid=358324)



using get player keys, should be easy help + rep. - grantism - 10.07.2012

pawn Код:
if (newkeys == KEY_SECONDRY_FIRE)
        {
            if(GetPlayerInterior < 1) return cmd_enter;
            else if(GetPlayerInterior >= 1) return cmd_exit;
        }
Samp wiki isn't very helpful, i've done this... Any ideas what the proper code is? I get five errors using this.


Re: using get player keys, should be easy help + rep. - clarencecuzz - 10.07.2012

KEY_SECONDARY_FIRE

You missed an 'A'.

EDIT: Full code
pawn Код:
if (newkeys == KEY_SECONDARY_FIRE)
        {
            if(GetPlayerInterior(playerid) < 1) return cmd_enter;
            else if(GetPlayerInterior(playerid) >= 1) return cmd_exit;
        }



Re: using get player keys, should be easy help + rep. - grantism - 10.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
KEY_SECONDARY_FIRE

You missed an 'A'.

EDIT: Full code
pawn Код:
if (newkeys == KEY_SECONDARY_FIRE)
        {
            if(GetPlayerInterior(playerid) < 1) return cmd_enter;
            else if(GetPlayerInterior(playerid) >= 1) return cmd_exit;
        }
Woah woops haha, three errors.
pawn Код:
hrp.pwn(18653) : error 017: undefined symbol "newkeys"
hrp.pwn(18655) : error 076: syntax error in the expression, or invalid function call
hrp.pwn(18656) : error 076: syntax error in the expression, or invalid function call



Re: using get player keys, should be easy help + rep. - clarencecuzz - 10.07.2012

Oh sorry, I'm thinking of OnPlayerKeyStateChange. Give me a second and I will edit this post.

EDIT: I'm still confused as to what you're trying to script. Can you please post the WHOLE function/command or whatever it is you are using GetPlayerKeys in?


Re: using get player keys, should be easy help + rep. - grantism - 10.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Oh sorry, I'm thinking of OnPlayerKeyStateChange. Give me a second and I will edit this post.

EDIT: I'm still confused as to what you're trying to script. Can you please post the WHOLE function/command or whatever it is you are using GetPlayerKeys in?
I'm using public OnPlayerUpdate(playerid) should i use OnPlayerKeyStateChange instead? I'm basically trying to just make it so you press f IG to enter/exit buildings.


Re: using get player keys, should be easy help + rep. - zT KiNgKoNg - 10.07.2012

he missed out the _

This if (newkeys == KEY SECONDARY FIRE)
To if (newkeys == KEY_SECONDARY_FIRE)


Re: using get player keys, should be easy help + rep. - clarencecuzz - 10.07.2012

Quote:
Originally Posted by Ultra-Gaming
Посмотреть сообщение
he missed out the _

This if (newkeys == KEY SECONDARY FIRE)
To if (newkeys == KEY_SECONDARY_FIRE)
No I didn't?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_FIRE)
    {
        if(GetPlayerInterior(playerid) < 1)
        return cmd_enter;
        else if(GetPlayerInterior(playerid) >= 1)
        return cmd_exit;
    }
    return 1;
}
If it gives you an error for KEY_SECONDARY_FIRE, change it to KEY_SECONDARY_ATTACK


Re: using get player keys, should be easy help + rep. - grantism - 10.07.2012

Quote:
Originally Posted by Ultra-Gaming
Посмотреть сообщение
he missed out the _

This if (newkeys == KEY SECONDARY FIRE)
To if (newkeys == KEY_SECONDARY_FIRE)
No I had the _..


Re: using get player keys, should be easy help + rep. - grantism - 10.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
No I didn't?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_FIRE)
    {
        if(GetPlayerInterior(playerid) < 1)
        return cmd_enter;
        else if(GetPlayerInterior(playerid) >= 1)
        return cmd_exit;
    }
    return 1;
}
If it gives you an error for KEY_SECONDARY_FIRE, change it to KEY_SECONDARY_ATTACK
hrp.pwn(18365) : error 017: undefined symbol "enter"
hrp.pwn(18366) : error 029: invalid expression, assumed zero

I get them, any idea how to call a command?


Re: using get player keys, should be easy help + rep. - clarencecuzz - 10.07.2012

Post your commands for Enter and Exit.