Key to command
#1

How to add a key to a command?
like i press H to open a gate
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


That should give you a good grasp on how to manage keys (It even goes into a bit of explanation on the bitwise & operator ).



Код:
This forum requires that you wait 120 seconds between posts. Please try again in 16 seconds.
Reply
#3

pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
  if(IsPlayerInAnyVehicleID(playerid)
  {
    if(newkeys & KEY_CROUCH) // key_crouch is the define for H in vehicle.
    {
       MoveObject(Gate.etc.etc.);
       return 1;
    }
  }
}
Reply
#4

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
  if(IsPlayerInAnyVehicleID(playerid)
  {
    if(newkeys & KEY_CROUCH) // key_crouch is the define for H in vehicle.
    {
       MoveObject(Gate.etc.etc.);
       return 1;
    }
  }
}
You missed a closing parenthese, aren't taking the players area into consideration, and not even checking if the gate is opened or closed :\.

I wrote a little gate engine AGES ago, but its gone lol. Im sure if you search you can find one (it is one of THE most popular releases on account of its simplicity, yet usefulness).
Reply
#5

so wath i do?
Reply
#6

Quote:
Originally Posted by Thebest96
Посмотреть сообщение
so wath i do?
I suggest you take advantage of one of the pre-written scripts made for this if you're new at pawn.

http://forum.sa-mp.com/search.php?searchid=385160


if you're not willing to use one of the premade systems, look up enumerations (Search the wiki for initializers), arrays and variables (should be in the scripting basic part of the wiki), loops (statements), and that previous link regarding OnPlayerKeyStateChange.

Some people are going to argue and tell you to do it like the above poster did but with an area check, thats rubbish though. Static code is a pain to manage, gets big quickly, and should be illegal (hehe). The extra work into making it "dynamic" is worth it (at the very least you have a ton of them already made for you :P).
Reply
#7

Dude I Didnt HackI Dont Know How Follow Your Instruction i thought the link you said was to download and put into with your larp seriously dude
Reply
#8

BUMP!fddbgdbdbfddf
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)