SA-MP Forums Archive
Help with holding keys. - 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: Help with holding keys. (/showthread.php?tid=615849)



Help with holding keys. - DeeadPool - 28.08.2016

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
  




Re: Help with holding keys. - Threshold - 28.08.2016

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


Re: Help with holding keys. - DeeadPool - 28.08.2016

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


Re: Help with holding keys. - Shinja - 28.08.2016

errors in the compiler? show em


Re: Help with holding keys. - Threshold - 28.08.2016

You never said it showed errors or warnings...


Re: Help with holding keys. - DeeadPool - 28.08.2016

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


Re: Help with holding keys. - Konstantinos - 28.08.2016

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.


Re: Help with holding keys. - DeeadPool - 28.08.2016

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);
               }
         }

    } 



Re: Help with holding keys. - Konstantinos - 28.08.2016

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.


Re: Help with holding keys. - DeeadPool - 28.08.2016

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.