Command to Key?
#1

Hello

pawn Код:
if(strcmp(cmdtext,"/openagate", true) == 0) {
     {
        if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 95.78)) {
            MoveObject (AdminGate, -1395.03, 2850.07, 101.43, 3);
            SendClientMessage(playerid, COLOR_RED, "Welcome to heaven");
        } else {
            return SendClientMessage(playerid,0xFFFFFF,"You aren't in range!");
        }
    }
    return 1;
}

if(strcmp(cmdtext,"/closeagate", true) == 0) {
     {
        if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 101.43)) {
            MoveObject (AdminGate, -1395.03, 2850.07, 95.78, 3);
            SendClientMessage(playerid, COLOR_RED, "The gate is closing! Be back soon sugahpuffs!");
        } else {
            return SendClientMessage(playerid,0xFFFFFF,"You aren't in range!");
        }
    }
    return 1;
}
return 0;
}
Is there a way to change that so that I can just press X and then the gate opens/closes instead of using the commands?
Reply
#2

Quote:
Originally Posted by ColdIce
Посмотреть сообщение
Hello

pawn Код:
if(strcmp(cmdtext,"/openagate", true) == 0) {
     {
        if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 95.78)) {
            MoveObject (AdminGate, -1395.03, 2850.07, 101.43, 3);
            SendClientMessage(playerid, COLOR_RED, "Welcome to heaven");
        } else {
            return SendClientMessage(playerid,0xFFFFFF,"You aren't in range!");
        }
    }
    return 1;
}

if(strcmp(cmdtext,"/closeagate", true) == 0) {
     {
        if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 101.43)) {
            MoveObject (AdminGate, -1395.03, 2850.07, 95.78, 3);
            SendClientMessage(playerid, COLOR_RED, "The gate is closing! Be back soon sugahpuffs!");
        } else {
            return SendClientMessage(playerid,0xFFFFFF,"You aren't in range!");
        }
    }
    return 1;
}
return 0;
}
Is there a way to change that so that I can just press X and then the gate opens/closes instead of using the commands?
X is not avaiable, but there are other keys.

pawn Код:
new Opened = 0;

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if(newkeys == KEY_SUBMISSION)
  {
      if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 95.78))
      {
          if(!Opened)
          {
            MoveObject (AdminGate, -1395.03, 2850.07, 101.43, 3);
            SendClientMessage(playerid, COLOR_RED, "Welcome to heaven");
            Opened = true;
          }
          else
          {
            MoveObject (AdminGate, -1395.03, 2850.07, 95.78, 3);
            SendClientMessage(playerid, COLOR_RED, "The gate is closing! Be back soon sugahpuffs!");
            Opened = false;
          }
      }
  }
  return 1;
}
Reply
#3

Okay thanks alot for your reply. My english is not so good and is keeping me back when learning scripting, so sometimes I dont understand the words in the script. Could you post it again with the key "H" or just whatever key that works I would be very appreciated
Reply
#4

This is working

pawn Код:
new Opened = 0; //Start of the script, under include and defines

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) //Outside any function or other callback
{
  if(newkeys == KEY_SUBMISSION) //if the new keys are KEY_SUBMISSION (Mouse Cen)
  {
      if(IsPlayerInRangeOfPoint(playerid, 150000.0, -1395.03, 2850.07, 95.78)) //If the player is in range of that point
      {
          if(!Opened) //If is not opened
          {
            MoveObject (AdminGate, -1395.03, 2850.07, 101.43, 3);//Move the object
            SendClientMessage(playerid, COLOR_RED, "Welcome to heaven");//Send the message
            Opened = true; //Set variable "Opened" to true, so the server will know it's opened
          }
          else //Else
          {
            MoveObject (AdminGate, -1395.03, 2850.07, 95.78, 3);//Move the object
            SendClientMessage(playerid, COLOR_RED, "The gate is closing! Be back soon sugahpuffs!");//Send the message
            Opened = false; //Set variable "Opened" to false, so the server will know it's not opened          
          }
      }
  }
  return 1;
}
Reply
#5

Is it H to open/close?


Edit: I get 4 errors
Reply
#6

Nvm, they are gone And should I delete that onplayercommandtext thingy?
Reply
#7

KEY_SUBMISSION is 2 as default
Reply
#8

Forgot to comment, I got it working It's perfect!! Thanks ALOT u guys!!! Btw, it opens on 1
Reply
#9

Still one problem, it only works when I'm on foot
Reply
#10

Quote:
Originally Posted by ColdIce
Посмотреть сообщение
Still one problem, it only works when I'm on foot
Do you want to work it in car?

Add if(IsPlayerInAnyVehicle(playerid))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)