[Help] Cuff command -
[Aka]Dragonu - 01.12.2010
Ok , so i made this command . But i have a problem . If you tipe /cuff you cuff yourself , and i want to cuff a player that is in that radius . How to fix that ?
Command :
pawn Код:
if(strcmp(cmd, "/cuff", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /cuff [playerid]");
}
giveplayerid = strval(tmp);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
{
if(PlayerToPoint(7.5, giveplayerid, x , y, z))
{
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2 && IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 104)
{
format(string, sizeof(string), "Officer %s has cuffed (suspect) %s", PlayerName[playerid], PlayerName[giveplayerid]);
SendClientMessageToAll(COLOR_BLUE, string);
TogglePlayerControllable(giveplayerid, false);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You could not cuff an officer that follows the law to.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "That playerid is not close (enough) to you!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not a part of the cops team.");
}
return 1;
}
Re: [Help] Cuff command -
Jochemd - 01.12.2010
Well try using sscanf atleast, it's simple and much better (tip: zcmd and sscanf).
Re: [Help] Cuff command -
[Aka]Dragonu - 01.12.2010
I don't want to use that . I just want to edit the line that cuffs me instead of other player !
Re: [Help] Cuff command -
Jochemd - 01.12.2010
pawn Код:
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /cuff [playerid]");
}
else
{
giveplayerid = strval(tmp);
// etc.
Try
Re: [Help] Cuff command -
[Aka]Dragonu - 01.12.2010
No ! It isn't working . You made something wrong here . It gave loads of errors . More help please !
Re: [Help] Cuff command -
6d - 01.12.2010
what are those errors?
Re: [Help] Cuff command -
Mokerr - 01.12.2010
pawn Код:
if(strcmp(cmd, "/cuff", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /cuff [playerid]");
}
giveplayerid = strval(tmp);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
{
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_RED, "You cannot cuff yourself!");
return 1;
}
if (ProxDetectorS(7.5, playerid, giveplayerid))
{
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2 && IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 104)
{
format(string, sizeof(string), "Officer %s has cuffed (suspect) %s", PlayerName[playerid], PlayerName[giveplayerid]);
SendClientMessageToAll(COLOR_BLUE, string);
TogglePlayerControllable(giveplayerid, false);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You could not cuff an officer that follows the law to.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "That playerid is not close (enough) to you!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not a part of the cops team.");
}
return 1;
}
If you dont have ProxDetectorS yet add:
pawn Код:
forward ProxDetectorS(Float:radi, playerid, targetid);
pawn Код:
public ProxDetectorS(Float:radi, playerid, targetid)
{
if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
GetPlayerPos(targetid, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
Re: [Help] Cuff command -
[Aka]Dragonu - 02.12.2010
Ty a lot ! It worked
Re: [Help] Cuff command -
Mokerr - 02.12.2010
Quote:
Originally Posted by [Aka]Dragonu
Ty a lot ! It worked 
|
Your welcome.
Re: [Help] Cuff command -
SkizzoTrick - 02.12.2010
This script is using IsPlayerInRange of point,you can always do that with proxdetector too
Just replace the IsPlayerInRangeOfPoint with:
pawn Код:
if (ProxDetectorS(8.0, playerid, giveplayerid))
pawn Код:
if(strcmp(cmd, "/cuff", true) == 0 || strcmp(cmd, "/cu", true) == 0)
{
new Float:x,Float:y,Float:z;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
GetPlayerPos(giveplayerid, x, y, z);
if (IsPlayerInRangeOfPoint(playerid, 8.0 ,x,y,z)
{
if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot cuff yourself!");
SendClientMessage(giveplayerid, COLOR_WHITE, "You are cuffed");
SendClientMessage(playerid, COLOR_WHITE, "You have cuffed a suspect!");
GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
TogglePlayerControllable(giveplayerid, 1);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "* That player is not near you !");
return 1;
}
return 1;
}