05.08.2013, 13:33
CMD detain
stock
and this as a public
// forward ProxDetectorS(Float:radi, playerid, targetid);
pawn Код:
if(strcmp(cmd, "/detain", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if() // here your cop
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Cannot use this while being in the Car !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid/PartOfName] [seatid]");
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [playerid/PartOfName] [seatid]");
new seat = strvalEx(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(seat < 1 || seat > 3)
{
SendClientMessage(playerid, COLOR_GREY, " Seat cannot be below 1 or above 3 !");
return 1;
}
if(/*here your cop*/(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREY, " You can't Detain Cops !");
return 1;
}
if(IsPlayerInAnyVehicle(giveplayerid))
{
SendClientMessage(playerid, COLOR_GREY, " Suspect is in a Car, get him out first !");
return 1;
}
if(ProxDetectorS(8.0, playerid, giveplayerid))
{
if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, " You cannot Detain yourself !"); return 1; }
if(PlayerCuffed[giveplayerid] == 2)
{
new carid = gLastCar[playerid];
if(IsInvalidDetainVehicle(carid)) { SendClientMessage(playerid, COLOR_GREY, " You can't Detain someone in that vehicle !"); return 1; }
//foreach(Player, i)
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == 596) // you can change it
{
if(GetPlayerVehicleSeat(i) == seat)
{
format(string, sizeof(string), " That seat is occupied by %s !", PlayerName(i));
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
}
}
}
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* You were detained by %s.", sendername);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You have detained %s.", PlayerName(giveplayerid));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s grabs %s and throws him in the car.", sendername, PlayerName(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(giveplayerid, "~r~Detained", 2500, 3);
ClearAnimations(giveplayerid);
TogglePlayerControllable(giveplayerid, 0);
if(IsInvalidDetainSeat(carid))
{
PutPlayerInVehicle(giveplayerid,carid,1);
}
else
{
PutPlayerInVehicle(giveplayerid,carid,seat);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player needs to be restrained first !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is not near you !");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop / FBI / SAST !");
}
}
return 1;
}
pawn Код:
stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
new invehicle[MAX_PLAYERS];
new virtualworld = GetPlayerVirtualWorld(playerid);
new interior = GetPlayerInterior(playerid);
new vehicleid = GetPlayerVehicleID(playerid);
new ivehicleid;
if(vehicleid)
{
GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
}
else
{
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
vehicleid = GetPlayerVehicleID(playerid);
}
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!BigEar[i])
{
if(GetPlayerVirtualWorld(i) == virtualworld)
{
if((GetPlayerInterior(i) == interior))
{
if(vehicleid)
{
if(IsPlayerInVehicle(i,vehicleid))
{
invehicle[i] = 1;
}
}
if(!invehicle[i])
{
if(IsPlayerInAnyVehicle(i))
{
ivehicleid = GetPlayerVehicleID(i);
GetVehiclePos(ivehicleid,posx,posy,posz);
} else {
GetPlayerPos(i,posx,posy,posz);
}
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, string);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, string);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, string);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, string);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, string);
}
}
else
{
SendClientMessage(i, col1, string);
}
}
}
} else {
SendClientMessage(i, col1, string);
}
}
}
}
return 1;
}
stock IsInvalidDetainSeat(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 528,601,599: return 1;
}
return 0;
}
// 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;
}