Help with holding keys.
#1

Hello all!

I was trying HOLDING keys in 'OnPlayerKeyStateChange' but it doesn't work due to some reasons. I have even defined it on the top of the script too. have a look:-
PHP код:
//at the top
// HOLDING(keys)
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0)) 
PHP код:
//under OnPlayerKeyStateChange
if(HOLDING(KEY_WALK))
  {
     
//my code
  

Reply
#2

I don't think you're using the right macro... KEY_WALK is 'Left ALT' by default, it is NOT the 'W' or 'Up Arrow' key that you use to walk on foot.

https://sampwiki.blast.hk/wiki/Keys
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
I don't think you're using the right macro... KEY_WALK is 'Left ALT' by default, it is NOT the 'W' or 'Up Arrow' key that you use to walk on foot.

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

I know that, key_walk is LALT, I'm saying that it shows an error/warning
Reply
#4

errors in the compiler? show em
Reply
#5

You never said it showed errors or warnings...
Reply
#6

Here's the error:- error 029: invalid expression, assumed zero
Reply
#7

Apparently the error is not from the code you posted in your first post. Show the code in the line reported (mark it so we can know which one) and post 5 lines before and 5 lines after the said line.
Reply
#8

Here you go:-
PHP код:
if(PRESSED(KEY_CTRL_BACK))
  {
      if(
IsPlayerInRangeOfPoint(playerid2.0, -2908.8135497.35215.2000))
         {
            
ShowPlayerDialog(playerid34DIALOG_STYLE_TABLIST_HEADERS"Shop",
            
"Item\tPrice\n\
             Medkit\t$2000\n\
             Medic Pack\t$3000\n\
             Ammokit\t$6500\n\
             Ammo Pack\t$2500\n\
             Smoke\t$500(each)\n\
             Reinforced Kevlar\t$12500\n\
             Laser\t$5000\n\
             Silencer\t$2500"
,
             
"Buy","");
        }
    }
      
if(
HOLDING(KEY_WALK))
   {

      if(
IsPlayerInRangeOfPoint(playerid1.5276.76434050.377928.5322))
         {
            if(
HUnderBomb[CASTLE] == && gTeam[playerid] == TEAM_DEFENDERS) return SendClientMessage(playeridCOLOR_RED"There is no bomb planted yet!");
            if(
HBombed[CASTLE] == && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playeridCOLOR_RED"This area has already been bombed by someone!");
            if(
HUnderBomb[CASTLE] == && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playeridCOLOR_RED"The area is already underbomb!");
            if(
IsPlayerInAnyVehicle(playerid) && gTeam[playerid] == TEAM_DEFENDERS) return SendClientMessage(playeridCOLOR_RED"You can not defuse the bomb while you are in a vehicle");
            if(
IsPlayerInAnyVehicle(playerid) && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playeridCOLOR_RED"You can not plant a bomb while you are in a vehicle!");
            if(
gTeam[playerid] == TEAM_ATTACKERS && HBombed[CASTLE] == 0)
               {
                  
HIsPlayerBombing[playerid][CASTLE] = 1;
                  
HBombed[CASTLE] = 0;
                  
HUnderBomb[CASTLE] = 0;
                  
SendClientMessage(playeridCOLOR_LIGHTERBLUE"Planting...");
                  
Timer[castle1] = SetTimerEx("castlebomb"1000false"i"playerid);
                  
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.000000);
               }
            if(
gTeam[playerid] == TEAM_DEFENDERS && HUnderBomb[CASTLE] == 1)
               {
                  
SendClientMessage(playeridCOLOR_LIGHTERBLUE"Defusing...");
                  
HIsPlayerBombing[playerid][CASTLE] = 1;
                  
HUnderBomb[playerid] = 1;
                  
Timer[castled1] = SetTimerEx("castledefusebomb"1000false"i"playerid);
                  
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.000000);
               }
         }

    } 
Reply
#9

Marking the line which gives the error really helps. I had to define all those just to try compile it.

You use both "CASTLE" and "playerid" as indexes for HUnderBomb, you probably want to check this out.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Marking the line which gives the error really helps. I had to define all those just to try compile it.

You use both "CASTLE" and "playerid" as indexes for HUnderBomb, you probably want to check this out.
Changed that, but I still get the same error.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)