grod
Умник
система Конвоя
Автор: Emtrent(если не он то прошу написать мне в лс)
1. Сама команда
Код:
if(strcmp(cmd, "/konvoy", true) == 0)
{
new var[255];
var = strtok(cmdtext, idx);
if(!strlen(var)) return SendClientMessage(playerid, 0xAA3333AA, "Вы не ввели имя игрока");
new gotplayer = strval(var);
if(IsACop(playerid))
{
if(playerid == gotplayer) return SendClientMessage(playerid, 0xAA3333AA, "Вы не можете сопровождать самого себя ");
else if(!IsPlayerConnected(gotplayer)) return SendClientMessage(playerid, 0xAA3333AA, "Такого игрока нет на сервере");
else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xAA3333AA, "Вы не можете вести конвой с машины!");
else if(FollowBy[playerid] != MAX_PLAYERSS) return SendClientMessage(playerid, 0xAA3333AA, "Вы не можете взять игрока под конвой, когда сами конвоируетесь!");
else if(IsPlayerInAnyVehicle(gotplayer)) return SendClientMessage(playerid, 0xAA3333AA, "Вы не можете взять под конвой когда игрок в машине!");
new Float: X, Float: Y, Float: Z; GetPlayerPos(gotplayer, X, Y, Z);
if(!IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z)) return SendClientMessage(playerid, 0xAA3333AA, "Игрок далеко от вас!");
else if(FollowBy[gotplayer] != MAX_PLAYERS)
{
//if(FollowBy[gotplayer] != playerid)
SetPVarInt(playerid, "TempFollowBy", -1);
FollowBy[gotplayer] = MAX_PLAYERS;
KillTimer(TimerForPlayer[gotplayer]);
TimerForPlayer[gotplayer] = MAX_PLAYERS;
ClearAnimations(playerid);
TogglePlayerControllable(gotplayer, 1);
SendClientMessage(playerid, 0x33AA33AA, "Вы успешно установили конвой за игроком!");
return SendClientMessage(gotplayer, 0xFFFF00AA, "С вас был снят конвой!");
}
if(GetPVarInt(playerid, "TempFollowBy") != -1) return SendClientMessage(playerid, 0xAA3333AA, "Вы не можете сопровождать больше 2х игроков одновременно!");
FollowBy[gotplayer] = playerid;
SetPVarInt(playerid, "TempFollowBy", gotplayer);
TimerForPlayer[gotplayer] = SetTimerEx("FollowToPlayer", 1000, 1, "i", gotplayer);
SendClientMessage(playerid, 0x33AA33AA, "Вы успешно начали сопровождение этого игрока!");
return SendClientMessage(gotplayer, 0xFFFF00AA, "Вас взяли под конвой");
}
}
Ко всем переменным #deifne установим эти данные.
Код:
#define gpvi GetPVarInt
#define spvi SetPVarInt
Код:
new FollowBy[MAX_PLAYERS];
new TimerForPlayer[MAX_PLAYERS];
Код:
TimerForPlayer[playerid] = MAX_PLAYERS;
FollowBy[playerid] = MAX_PLAYERS;
SetPVarInt(playerid, "TempFollowBy", -1);
Код:
new GotPVar = GetPVarInt(playerid, "TempFollowBy");
if(FollowBy[playerid] != MAX_PLAYERSS)
{
SetPVarInt(FollowBy[playerid], "TempFollowBy", -1);
KillTimer(TimerForPlayer[playerid]);
SendClientMessage(FollowBy[playerid], COLOR_LIGHTBLUE, "Ваш заключенный мертв");
TimerForPlayer[playerid] = MAX_PLAYERS;
FollowBy[playerid] = MAX_PLAYERS;
}
else if(GotPVar != -1)
{
SetPVarInt(playerid, "TempFollowBy", -1);
KillTimer(TimerForPlayer[GotPVar]);
SendClientMessage(FollowBy[playerid], COLOR_LIGHTBLUE, "Ваш конвой мертв.");
TimerForPlayer[GotPVar] = MAX_PLAYERS;
FollowBy[GotPVar] = MAX_PLAYERS;
}
Код:
new GotPVar = GetPVarInt(playerid, "TempFollowBy");
if(FollowBy[playerid] != MAX_PLAYERS)
{
SetPVarInt(FollowBy[playerid], "TempFollowBy", -1);
KillTimer(TimerForPlayer[playerid]);
SendClientMessage(FollowBy[playerid], COLOR_LIGHTBLUE, "Ваш заключенный мертв.");
TimerForPlayer[playerid] = MAX_PLAYERSS;
FollowBy[playerid] = MAX_PLAYERS;
}
else if(GotPVar != -1)
{
SetPVarInt(playerid, "TempFollowBy", -1);
KillTimer(TimerForPlayer[GotPVar]);
SendClientMessage(FollowBy[playerid], COLOR_LIGHTBLUE, "Ваш конвой мертв.");
TimerForPlayer[GotPVar] = MAX_PLAYERS;
FollowBy[GotPVar] = MAX_PLAYERS;
}
Код:
forward FollowToPlayer(playerid);
public FollowToPlayer(playerid)
{
static AnimShot[MAX_PLAYERSS];
if(!IsPlayerConnected(FollowBy[playerid]))
{
KillTimer(TimerForPlayer[playerid]);
TimerForPlayer[playerid] = MAX_PLAYERS;
FollowBy[playerid] = MAX_PLAYERS;
TogglePlayerControllable(playerid, 1);
ClearAnimations(playerid);
AnimShot[playerid] = false;
SendClientMessage(playerid, 0xFFFF00AA, "Вы свободны, конвой покинул сервер!");
return 1;
}
else if(!IsPlayerConnected(playerid))
{
SetPVarInt(FollowBy[playerid], "TempFollowBy", -1);
KillTimer(TimerForPlayer[playerid]);
TimerForPlayer[playerid] = MAX_PLAYERS;
AnimShot[playerid] = false;
SendClientMessage(FollowBy[playerid], 0xFFFF00AA, "Арестованный покинул сервер!");
FollowBy[playerid] = MAX_PLAYERS;
return 1;
}
else if(FollowBy[playerid] == MAX_PLAYERSS)
{
KillTimer(TimerForPlayer[playerid]);
TimerForPlayer[playerid] = MAX_PLAYERS;
AnimShot[playerid] = false;
SendClientMessage(playerid, 0xFFFF00AA, "С вашем конвоем произошла беда, вы свободны !");
TogglePlayerControllable(playerid, 1);
ClearAnimations(playerid);
return 1;
}
else if(IsPlayerInAnyVehicle(playerid))
{
SetPVarInt(FollowBy[playerid], "TempFollowBy", -1);
KillTimer(TimerForPlayer[playerid]);
TimerForPlayer[playerid] = MAX_PLAYERS;
AnimShot[playerid] = false;
SendClientMessage(FollowBy[playerid], 0xFFFF00AA, "Ваш заключенный в машине. Конвой остановлен");
FollowBy[playerid] = MAX_PLAYERS;
return 1;
}
else if(GetPlayerVirtualWorld(FollowBy[playerid]) != GetPlayerVirtualWorld(playerid) || GetPlayerInterior(FollowBy[playerid]) != GetPlayerInterior(playerid))
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(FollowBy[playerid], X, Y, Z);
SetPlayerPos(playerid, X, Y, Z);
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(FollowBy[playerid]));
SetPlayerInterior(playerid, GetPlayerInterior(FollowBy[playerid]));
TogglePlayerControllable(playerid, 0);
AnimShot[playerid] = false;
return 1;
}
new Float: GotDistance = GetDistanceBetweenPlayers(playerid, FollowBy[playerid]);
if(GotDistance < 0.95)
{
TogglePlayerControllable(playerid, 0);
SetPlayerToFacePlayer(playerid, FollowBy[playerid]);
AnimShot[playerid] = false;
return 1;
}
else if(GotDistance > 10.0)
{
SetPVarInt(FollowBy[playerid], "TempFollowBy", -1);
SendClientMessage(FollowBy[playerid], 0xFFFF00AA, "Вы ушли слишком далеко. Конвой закончен");
SendClientMessage(playerid, 0xFFFF00AA, "Ваш конвой ушел слишком далеко, вы свободны.");
TogglePlayerControllable(playerid, 1);
ClearAnimations(playerid);
KillTimer(TimerForPlayer[playerid]);
TimerForPlayer[playerid] = MAX_PLAYERS;
FollowBy[playerid] = MAX_PLAYERS;
return 1;
}
else
{
TogglePlayerControllable(playerid, 1);
SetPlayerToFacePlayer(playerid, FollowBy[playerid]);
ApplyAnimation(playerid, "ped", "WALK_civi", 6.0, 1, 1, 1, 1, 0, 1);
}
return 1;
}
