3 posts in this topic

В этой теме будет система Конвоя.

Спойлер

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, "Вас взяли под конвой");
                }
        }

 

Вводя команду и указывая ид игрока, она будет вполне рабочая. И тот игрок которого вы хотели бы взять под конвой будет следовать за вами

Спойлер

#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;
}

 

На этом система закончена.

Share this post


Link to post
Share on other sites

Можно на dc_cmd?

 

Share this post


Link to post
Share on other sites
Спойлер

CMD:konvoy(playerid, params[])
{
  				new gotplayer;
				if(sscanf(params, "u", gotplayer)) return SendClientMessage(playerid, 0xAA3333AA, "Введите: /konvoy [id/PartOfName/Name]"); 
                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, "Вас взяли под конвой");
                }
        }

 

 

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   You have pasted content with formatting.   Remove formatting

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

Loading...
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • warrion4ik
      By warrion4ik
      При телепорте по метке она тепает под текстуры и приходится перетелепортироваться, как это можно исправить?
      Видео: https://youtu.be/FLjer8lfGc0