HAving trouble with Keybinds for pawno script
#1

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange this is the site to it but don't understand it I only want to create a keybind for /enter and /exit as well as /car engine (Y for enter, N for Exit, and Y also for /car engine or C key)
Reply
#2

I know But I don't understand
Reply
#3

Assuming you're using NGRP.
You go to
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){

}
and add your 'cmd:enter' code under that. You take away the zcmd code and add
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
  {

  }
Then all your ENTER code goes within the curly brackets;
pawn Код:
{
         //Chunk of code.
           }
Like the other person said, you can't just use any keys. Use the ones that are available,
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#4

Okay so I put the Whole enter command under
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
  {

}
and where do I put
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
Reply
#5

Quote:
Originally Posted by Zach7
Посмотреть сообщение
Okay so I put the Whole enter command under
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
  {

}
and where do I put
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
Within the curly brackets yes. The if statement I provided would make the keybind ENTER/F.
Reply
#6

Quote:
Originally Posted by Zach7
Посмотреть сообщение
Okay so I put the Whole enter command under
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
  {

}
and where do I put
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
Something like this;

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
      if(newkeys == KEY_SECONDARY_ATTACK)
  {

            //All your coding goes in here.



}

}
Reply
#7

Quote:
Originally Posted by aaronwelsh
Посмотреть сообщение
Within the curly brackets yes. The if statement I provided would make the keybind ENTER/F.
Ty i will check it out
Reply
#8

Quote:
Originally Posted by Zach7
Посмотреть сообщение
Ty i will check it out
No problem man. Just remember not to add your zcmd code.
By that, don't add;

pawn Код:
CMD:randomcmd(playerid, params[])
    {
             //add all the coding in here, not anything above this message or after the ending curly bracket.

}
Reply
#9

i still don't know what do to do what do you mean by no coding and stuff ughh so frustrated
Reply
#10

Quote:
Originally Posted by Zach7
Посмотреть сообщение
i still don't know what do to do what do you mean by no coding and stuff ughh so frustrated
I'm not going to type the full code out for you because I don't want to be helping someone run a server on a black listed script.
So I'll just explain simple statements to you.

When creating a statement, you use the name and two parentheses "()" after that you use two curly brackets which the coding for that statement goes in. For example;

pawn Код:
cmd:thisisthename(these are the parentheses){
//Within here is where your coding goes for this statement.
}
So for what you're doing. You're using;
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {

          }
This is where your enter code will be going. But before that you have to modify your cmd.
As you have to add which key you will be using, you do this;
pawn Код:
if(newkeys == KEY_SECONDARY_ATTACK)
  {
      //Within here is where your enter code is going.

   }
So all you would need to do is take away the cmd line and the ending bracket but keep your enter code.

pawn Код:
cmd:thisisthename(these are the parentheses){
//take away what's on top and the bracket below. and where i am typing will be your /enter code
}
So your final result will be;

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
   
     
if(newkeys == KEY_SECONDARY_ATTACK)
  {

   //ALL YOUR ENTER CODE WILL GO IN HERE.
   // Which means when you press ENTER you will enter a building.

} // this bracket is closing the if(){} statemnet
} // this bracket is closing the public OnPlayerKeyStateChange
Try and learn at least JavaScript before trying to script in Pawno, it uses a lot of advanced programming.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)