How to define PRESSED
#1

for example
if(PRESSED(KEY_BRAKE))
{
SendClientMessage(playerid,RED,"bla bla bla");
}

compiling....1 error(undefined symbol pressed)
Reply
#2

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Source: SA-MP Wiki
Reply
#3

undefined symbol newkeys
Reply
#4

do I have to define newkeys also?
Reply
#5

This define goes in the OnPlayerKeyStateChange callback.
Reply
#6

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
do I have to define newkeys also?
No, functions like if ( PRESSED( KEY_FIRE ) ) go under OnPlayerKeyStateChange
Reply
#7

... i wanted to make this but then it hink it's not possible as a command

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerCommandText
{
               if (strcmp("/infernalrace", cmdtext, true, 10) == 0)
    {
               new vehicleid=GetPlayerVehicleID(playerid);
               if(IsPlayerInAnyVehicle(playerid))
               {
                  GetVehicleModel(vehicleid);
                  if(GetVehicleModel(vehicleid) == 431)
                  {
                     GetPlayerSpeed(playerid,true);
                     if(GetPlayerSpeed(playerid,true) > 60)
                     {
                        GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
                     }
                     if(PRESSED(KEY_BRAKE/REVERSE))
                     {
                        GetPlayerSpeed(playerid,true);
                        if(GetPlayerSpeed(playerid,true) < 50)
                        {
                           SetVehicleHealth(vehicleid,0);
                           SendClientMessage(playerid,RED,"BYE BYE");
                        }
                     }
                  }
                }
return 1;
}
Reply
#8

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
... i wanted to make this but then it hink it's not possible as a command

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerCommandText
{
               if (strcmp("/infernalrace", cmdtext, true, 10) == 0)
    {
               new vehicleid=GetPlayerVehicleID(playerid);
               if(IsPlayerInAnyVehicle(playerid))
               {
                  GetVehicleModel(vehicleid);
                  if(GetVehicleModel(vehicleid) == 431)
                  {
                     GetPlayerSpeed(playerid,true);
                     if(GetPlayerSpeed(playerid,true) > 60)
                     {
                        GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
                     }
                     if(PRESSED(KEY_BRAKE/REVERSE))
                     {
                        GetPlayerSpeed(playerid,true);
                        if(GetPlayerSpeed(playerid,true) < 50)
                        {
                           SetVehicleHealth(vehicleid,0);
                           SendClientMessage(playerid,RED,"BYE BYE");
                        }
                     }
                  }
                }
return 1;
}
Do you mean that after the command you can press that button?

pawn Код:
new Bomb[MAX_PLAYERS];

public OnPlayerCommandText
{
               if (strcmp("/infernalrace", cmdtext, true, 10) == 0)
    {
               new vehicleid=GetPlayerVehicleID(playerid);
               if(IsPlayerInAnyVehicle(playerid))
               {
                  GetVehicleModel(vehicleid);
                  if(GetVehicleModel(vehicleid) == 431)
                  {
                     GetPlayerSpeed(playerid,true);
                     if(GetPlayerSpeed(playerid,true) > 60)
                     {
                        GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
                     }
                                    Bomb[playerid] = true;
                  }
                }

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
                     if(PRESSED(KEY_BRAKE) || PRESSED(KEY_REVERSE)) //Don't do KEY_BRAKE/REVERSE, it means KEY_BRAKE divided by REVERSE :). Also this 2 buttons aren't defined in samp
                     {
                                                if(!Bomb[playerid]) return 1;
                        GetPlayerSpeed(playerid,true);
                                                Bomb[playerid] = false;
                        if(GetPlayerSpeed(playerid,true) < 50)
                        {
                           SetVehicleHealth(vehicleid,0);
                           SendClientMessage(playerid,RED,"BYE BYE");
                        }
                     }
}
Reply
#9

( BRAKE is not defined why?than what am i supossed to use in stead of brake?handbrake?but I don't want handbrake ( can it be defined?
Reply
#10

Bomb[playerid] = true; gives me errors

D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 60) : error 017: undefined symbol "Bomb"
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 60) : warning 215: expression has no effect
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 60) : error 001: expected token: ";", but found "]"
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 60) : error 029: invalid expression, assumed zero
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 60) : fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)