Command to Key? - ColdIce - 31.05.2011
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?
Re: Command to Key? -
Sasino97 - 31.05.2011
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;
}
Re: Command to Key? - ColdIce - 31.05.2011
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
Re: Command to Key? -
Sasino97 - 31.05.2011
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;
}
Re: Command to Key? - ColdIce - 31.05.2011
Is it H to open/close?
Edit: I get 4 errors
Re: Command to Key? - ColdIce - 31.05.2011
Nvm, they are gone

And should I delete that onplayercommandtext thingy?
Re: Command to Key? -
sim_sima - 31.05.2011
KEY_SUBMISSION is 2 as default
Re: Command to Key? - ColdIce - 31.05.2011
Forgot to comment, I got it working

It's perfect!! Thanks ALOT u guys!!! Btw, it opens on 1
Re: Command to Key? - ColdIce - 31.05.2011
Still one problem, it only works when I'm on foot
Re: Command to Key? -
Sasino97 - 01.06.2011
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))