Restricting Commands Error? -
Hereford - 16.12.2012
I try to make a command so that only Team 1 (In this case the Red County Sheriff's Department) can use it, but when I do, I get in game and I type in the command, it comes up with "You are not apart of the Red County Sheriff's Department, i've checked the scriptfiles etc, my Team = 1. it should all be working but for some reason it doesn't. Please help me.
pawn Код:
CMD:rcsd(playerid, params[])
{
if(PlayerInfo[playerid][pTeam] == 1) return SendClientMessage(playerid, white, "You are not apart of the Red County Sheriff's Department!");
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!");
{
ShowPlayerDialog(playerid, DIALOG_RCSD, DIALOG_STYLE_LIST, "RCSD Locker", "Equipment\nUniform", "Select","Cancel");
}
return 1;
}
Re: Restricting Commands Error? -
Lordzy - 16.12.2012
The mistake you done is that, you've scripted the command restricted to the players who are in that team.
pawn Код:
CMD:rcsd(playerid, params[])
{
if(PlayerInfo[playerid][pTeam] == 1) return SendClientMessage(playerid, white, "You are not apart of the Red County Sheriff's Department!"); //You're restricting the team here.
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!");
{
ShowPlayerDialog(playerid, DIALOG_RCSD, DIALOG_STYLE_LIST, "RCSD Locker", "Equipment\nUniform", "Select","Cancel");
}
return 1;
}
Correct:
pawn Код:
CMD:rcsd(playerid, params[])
{
if(PlayerInfo[playerid][pTeam] == 1)
{
if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!");
ShowPlayerDialog(playerid, DIALOG_RCSD, DIALOG_STYLE_LIST, "RCSD Locker", "Equipment\nUniform", "Select","Cancel");
}
else return SendClientMessage(playerid, white, "You are not apart of the Red County Sheriff's Department!");
return 1;
}
Re: Restricting Commands Error? -
Hereford - 16.12.2012
Quote:
Originally Posted by Lordz™
The mistake you done is that, you've scripted the command restricted to the players who are in that team.
pawn Код:
CMD:rcsd(playerid, params[]) { if(PlayerInfo[playerid][pTeam] == 1) return SendClientMessage(playerid, white, "You are not apart of the Red County Sheriff's Department!"); //You're restricting the team here. if(IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!"); { ShowPlayerDialog(playerid, DIALOG_RCSD, DIALOG_STYLE_LIST, "RCSD Locker", "Equipment\nUniform", "Select","Cancel"); } return 1; }
Correct:
pawn Код:
CMD:rcsd(playerid, params[]) { if(PlayerInfo[playerid][pTeam] == 1) { if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!"); ShowPlayerDialog(playerid, DIALOG_RCSD, DIALOG_STYLE_LIST, "RCSD Locker", "Equipment\nUniform", "Select","Cancel"); } else return SendClientMessage(playerid, white, "You are not apart of the Red County Sheriff's Department!"); return 1; }
|
Thankyou, im gonna try that out!
EDIT: Well it worked, thanks alot bro.
Re: Restricting Commands Error? -
Lordzy - 16.12.2012
Np, glad that it worked. Also I've done a change in your 'IsPlayerInRangeOfPoint' because you did same mistake as done in team restriction. You returned the error if a player is in position, so I've added a "!" before the function which means if not.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!");
//It returns the error message if player is at range.
if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1799.37, -163.40, 4.10)) return SendClientMessage(playerid,white,"You are not at the lockers!");
//returns the message if player isn't at the range of point.