(FS) Воздушный Десант / Динамический ящик

Описание: Готовые решения скриптов, filterScript
Модератор: SJplayer

Дим M
Автор темы, Администратор
Администратор
Аватара
Дим M
Автор темы, Администратор
Администратор
Сообщения: 1608
Зарегистрирован: 5 апреля 2013
С нами: 10 лет 11 месяцев

#1 Дим » 13 декабря 2020, 16:08

Изображение
phpBB [media]


Ящик приземлится на землю в течение 22 секунд, после указанного времени игрок должен будет использовать /findcrate, чтобы найти местоположение ящика.
Игроку нужно будет разблокировать ящик в течение 5 минут, чтобы разграбить его.
Игрок, запирающий ящик, должен будет защищать контейнер в течение 5 минут.
Если игрок умер или покинул территорию, отмычка остановится, и у других игроков появится шанс ее взломать.
Ящик самоликвидируется через 10 минут, даже если он пуст.

Команды:
/spawncrate -команда администратора; аналогично затравленному событию.
/picklock (может быть изменен на /unlockcrate) - команда игрока; для разблокировки ящика в течение 5 минут.
/opencrate -команда игрока; открыть контейнер и ограбить его.

Код: Выделить всё

#include <a_samp>
#include <ZCMD>
#include <sscanf2>
#include <streamer>
 
#define COLOR_LIGHTRED             0xFF6347AA
#define COLOR_ORANGE             0xFF8000FF
#define COLOR_LIGHTBLUE         0x33CCFFAA
#define COLOR_WHITE             0xFFFFFFAA
#define COLOR_GREY                 0xAFAFAFAA
#define COLOR_BLUE                 0x003366AA
#define COLOR_GREEN             0x008000FF
#define COLOR_RED                 0xFF6347FF
 
#define CRATECOLOR                0xFFC8C8C8
 
#define CRATEGUN1                 890
#define CRATEGUN2                 891
#define DROPSPEED                 5
#define PICKLOCKTIME            300000
#define CRATEDESTRUCT            600000
 
new dynamicCrate
,
    dynamicFlare,
    dynamicParachute,
    Text3D:dynamicCrate3DText,
    fcratePlayer,
    crateUnlocked,
    crateOnGround,
    Float:cratePos[4],
    weaponsTook[10],
    crateExist,
    weaponsTooked = 0,
    isPicklocking[MAX_PLAYERS],
    picklockTimer,
    cratedestroyTimer,
    cratedropTimer,
    progressBar,
    crateChecker,
    CountDown = PICKLOCKTIME / 1000,
    randomDialog;
 
public OnDialogResponse
(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == CRATEGUN1)
    {
        if(response) 
        
{
            if(listitem == 0) // Shotgun
            {
                if(weaponsTook[0] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 25, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Shotgun.");
                weaponsTook[0] = 1;
                weaponsTooked++;
            }
            if(listitem == 1) // MP5
            {
                if(weaponsTook[1] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 29, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a MP5!");
                weaponsTook[1] = 1;
                weaponsTooked++;
            }
            if(listitem == 2) // Rifle
            {
                if(weaponsTook[2] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 33, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Rifle!");
                weaponsTook[2] = 1;
                weaponsTooked++;
            }
            if(listitem == 3) // Desert Eagle
            {
                if(weaponsTook[3] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 24, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Desert Eagle!");
                weaponsTook[3] = 1;
                weaponsTooked++;
            }
            if(listitem == 4) // AK-47
            {
                if(weaponsTook[4] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 30, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken an AK-47!");
                weaponsTook[4] = 1;
                weaponsTooked++;
            }
            if(listitem == 5) // Light Kevlar vest
            {
                if(weaponsTook[8] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                SetPlayerArmour(playerid, 50.0);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Kevlar vest!");
                weaponsTook[8] = 1;
                weaponsTooked++;
            }
            if(listitem == 6)
            {
                if(weaponsTook[9] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                SetPlayerHealth(playerid, 100);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a First aid kit!");
                weaponsTook[9] = 1;
                weaponsTooked++;
            }
        }
        return 1; 
    
}
 
       if
(dialogid == CRATEGUN2)
    {
        if(response) 
        
{
            if(listitem == 0) // Combat Shotgun
            {
                if(weaponsTook[0] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 27, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Combat Shotgun.");
                weaponsTook[0] = 1;
                weaponsTooked++;
            }
            if(listitem == 1) // tec9
            {
                if(weaponsTook[1] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 32, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Tec-9!");
                weaponsTook[1] = 1;
                weaponsTooked++;
            }
            if(listitem == 2) // Rifle
            {
                if(weaponsTook[2] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 34, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Sniper!");
                weaponsTook[2] = 1;
                weaponsTooked++;
            }
            if(listitem == 3) // Desert Eagle
            {
                if(weaponsTook[3] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 24, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Desert Eagle!");
                weaponsTook[3] = 1;
                weaponsTooked++;
            }
            if(listitem == 4) // AK-47
            {
                if(weaponsTook[4] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                GivePlayerWeapon(playerid, 31, 99999);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken an M4!");
                weaponsTook[4] = 1;
                weaponsTooked++;
            }
            if(listitem == 5) // Heavy Kevlar vest
            {
                if(weaponsTook[8] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                SetPlayerArmour(playerid, 100.0);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a Kevlar vest!");
                weaponsTook[8] = 1;
                weaponsTooked++;
            }
            if(listitem == 6)
            {
                if(weaponsTook[9] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED,"Someone already took this item.");
                SetPlayerHealth(playerid, 100);
                SendClientMessage(playerid, COLOR_LIGHTBLUE,"You have taken a First aid kit!");
                weaponsTook[9] = 1;
                weaponsTooked++;
            }
        }
        return 1;
    }
    return 0; 
}
 
public OnPlayerEnterCheckpoint
(playerid)
{
    if(fcratePlayer == 1)
    {
        SendClientMessage(playerid, COLOR_WHITE, " * You are now at the weapon crate.");
        DisablePlayerCheckpoint(playerid);
        fcratePlayer = 0;
    }
 
    return 1
;
}
 
public OnPlayerUpdate
(playerid)
{
    if(isPicklocking[playerid] == 1 )
    {
        if(crateUnlocked == 0)
        {
            if(crateExist == 0) return 1;
             if(crateOnGround != 1) return 1;
            GetDynamicObjectPos(dynamicCrate, cratePos[0], cratePos[1], cratePos[2]);
            if(!IsPlayerInRangeOfPoint(playerid, 20.0, cratePos[0], cratePos[1], cratePos[2]))
            {
                isPicklocking[playerid] = 0;    
                SendClientMessage
(playerid, COLOR_LIGHTRED, " * You have left the area, and the lockpick machine signal has been depleted.");
                KillTimer(picklockTimer);
                KillTimer(progressBar);
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, "/picklock\nTo unlock the weapon crate.");
                 CountDown = PICKLOCKTIME / 1000;
            }
        }
    }        
 
    return 1
;
}
 
public OnPlayerDeath
(playerid, killerid, reason)
{
    if(isPicklocking[playerid] == 1)
    {
        if(crateUnlocked == 0)
        {
            if(crateExist == 0) return 1;
             if(crateOnGround != 1) return 1;
            isPicklocking[playerid] = 0;    
            SendClientMessage
(playerid, COLOR_LIGHTRED, " * You died, and your lockpick machine signal has been depleted.");
            KillTimer(picklockTimer);
            KillTimer(progressBar);
            UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, "/picklock\nTo unlock the weapon crate.");
            CountDown = PICKLOCKTIME / 1000;
        }
    }    
    return 1
;
}
 
stock strreplace
(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}
 
CountdownTillUnlocked
()
{
    new string[180], pickLocker[MAX_PLAYER_NAME];
    switch(CountDown)
    {
        case 1..300:
        {
             for(new i; i < MAX_PLAYERS; i++)
             {    
                 if
(    isPicklocking[i] == 1)
                 {
                           GetPlayerName(i, pickLocker, sizeof(pickLocker));
                          strreplace(pickLocker, '_', ' ');            
                 
}
             }
            if(CountDown == 300)
            {
                format(string, sizeof(string), "%s is picklocking this weapon crate!\n> %d minutes left <\n > |||||||||| {FF8000}< ", pickLocker, (CountDown/60));
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, string);
                SendClientMessageToAll(COLOR_LIGHTBLUE, " * The weapon crate will be unlocked in 5 minutes, kill the person unlocking it!");
            }
            else if(CountDown == 240)
            {
                format(string, sizeof(string), "%s is picklocking this weapon crate!\n> %d minutes left <\n > ||||||||{FF6347}|| {FF8000}< ", pickLocker, (CountDown/60));
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, string);
                SendClientMessageToAll(COLOR_LIGHTBLUE, " * The weapon crate will be unlocked in 4 minutes, kill the person unlocking it!");
            }
            else if(CountDown == 180)
            {
                format(string, sizeof(string), "%s is picklocking this weapon crate!\n> %d minutes left <\n > ||||||{FF6347}|||| {FF8000}< ", pickLocker, (CountDown/60));
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, string);
                SendClientMessageToAll(COLOR_LIGHTBLUE, " * The weapon crate will be unlocked in 3 minutes, kill the person unlocking it!");
            }
            else if(CountDown == 120)
            {
                format(string, sizeof(string), "%s is picklocking this weapon crate!\n> %d minutes left <\n > ||||{FF6347}|||||| {FF8000}< ", pickLocker, (CountDown/60));
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, string);
                SendClientMessageToAll(COLOR_LIGHTBLUE, " * The weapon crate will be unlocked in 2 minutes, kill the person unlocking it!");
            }
            else if(CountDown == 60)
            {
                format(string, sizeof(string), "%s is picklocking this weapon crate!\n> %d minute left <\n > ||{FF6347}|||||||| {FF8000}< ", pickLocker, (CountDown/60));
                UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_ORANGE, string);
                SendClientMessageToAll(COLOR_LIGHTBLUE, " * The weapon crate will be unlocked in 1 minute, kill the person unlocking it!");
            }
        }
    }
    return CountDown--;
}
 
CMD
:findcrate(playerid, params[])
{
    new Float:Position[3];
    if(crateExist == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, " * There is no weapon crate available.");
    if(IsPlayerInRangeOfPoint(playerid, 20.0, cratePos[0], cratePos[1], cratePos[2])) return SendClientMessage(playerid, COLOR_LIGHTRED, " * You are already inside the crate area.");
    if(fcratePlayer != 1)
    {
        if(crateOnGround != 1)
            SendClientMessageToAll(COLOR_LIGHTRED, " * The weapon crate is not yet on the ground.");
        else
        
{
            GetDynamicObjectPos(dynamicCrate, Position[0], Position[1], Position[2]);
            SetPlayerCheckpoint(playerid, Position[0], Position[1], Position[2], 15.0);
            fcratePlayer = 1;
            SendClientMessage(playerid, COLOR_WHITE, " * A checkpoint has been added to the weapon crate.");
        }
    }
    else
        SendClientMessage
(playerid, COLOR_WHITE, " * There is already a checkpoint on your map.");
 
    return 1
;
}
 
CMD
:picklock(playerid, params[])
{
    
    new pickLocker
[MAX_PLAYER_NAME], string[128];
    if(crateExist == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, " * There is no weapon crate available.");
     if(crateOnGround != 1) return SendClientMessage(playerid, COLOR_LIGHTRED, " * The weapon crate is not yet on the ground.");
     if(crateUnlocked == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, " * This weapon crate is already unlocked.");
     for(new i; i < MAX_PLAYERS; i++)
     {
          GetPlayerName(i, pickLocker, sizeof(pickLocker));
          strreplace(pickLocker, '_', ' ');
          format(string, sizeof(string), " * %s is already picklocking this weapon crate, kill that person!", pickLocker);
         if(isPicklocking[i] == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, string);    
     
}
    picklockTimer = SetTimerEx("UnlockCrate", PICKLOCKTIME, false, "i", playerid);
    progressBar = SetTimerEx("ProgressBar", 1000, true, "i", playerid);
    SendClientMessage(playerid, COLOR_WHITE, " * You placed a lockpick machine on the lock, stay at the area for 5 minutes!");
    SendClientMessageToAll(COLOR_LIGHTBLUE, " * Someone is trying to unlock the weapon crate, you have 5 minutes to stop them! - /findcrate");
    isPicklocking[playerid] = 1;
 
    return 1
;
}
forward ProgressBar(playerid);
public ProgressBar(playerid)
{
    CountdownTillUnlocked();
    return 1;
}
forward UnlockCrate(playerid);
public UnlockCrate(playerid)
{
    if(crateExist == 0) return 1;
    KillTimer(progressBar);
    crateUnlocked = 1;
    randomDialog = random(2);
    SendClientMessageToAll(COLOR_LIGHTRED, " * The weapon crate has been unlocked, and it will self-destruct after 10 minutes! - /opencrate");
    UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_GREEN, "This weapon crate is unlocked\n/opencrate - To open the weapon crate.");
    crateChecker = SetTimerEx("CrateChecker", 2000, true, "i", playerid);
    cratedestroyTimer = SetTimerEx("CrateEnd", CRATEDESTRUCT, false, "i", playerid);    
    return 1
;
}
forward CrateChecker(playerid);
public CrateChecker(playerid)
{
    if(weaponsTooked == 7)
    {
        UpdateDynamic3DTextLabelText(dynamicCrate3DText, COLOR_RED, "This weapon crate is now empty - wait for it to self-destruct.");    
        KillTimer
(crateChecker);    
    
}
    return 1;
}
 
CMD
:opencrate(playerid, params[])
{
    new Float:Position[3];
    if(crateExist == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, " * There is no weapon crate available.");
     if(crateOnGround != 1) return SendClientMessageToAll(COLOR_LIGHTRED, " * The weapon crate is not yet on the ground.");
    GetDynamicObjectPos(dynamicCrate, Position[0], Position[1], Position[2]);
     if(!IsPlayerInRangeOfPoint(playerid, 5.0, Position[0], Position[1], Position[2])) return SendClientMessage(playerid, COLOR_LIGHTRED, " * You're not near the weapon crate - /findcrate");
     if(weaponsTooked == 7) return SendClientMessageToAll(COLOR_LIGHTRED, " * This weapon crate is now empty.");
    if(crateUnlocked == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, Position[0], Position[1], Position[2]))
        {
            if(randomDialog == 0)
                ShowPlayerDialog(playerid, CRATEGUN1, DIALOG_STYLE_LIST, "Light Weapon Crate","Shotgun\nMP5\nRifle\nDesert Eagle\nAK-47\nLight Vest\nFirst Aid Kit", "Loot", "Cancel");
            else if(randomDialog == 1)
                ShowPlayerDialog(playerid, CRATEGUN2, DIALOG_STYLE_LIST, "Heavy Weapon Crate","Combat Shotgun\nTEC-9\nSniper\nDesert Eagle\nM4\nHeavy Vest\nFirst Aid Kit", "Loot", "Cancel");
        }
        else
            SendClientMessage
(playerid, COLOR_WHITE, " * You're not near the weapon crate - /findcrate");
    }
    else
        SendClientMessage
(playerid, COLOR_LIGHTRED, " * The weapon crate is not still unlocked, wait for it!");
 
    return 1
;
}
 
CMD
:spawncrate(playerid, params[])
{
    new Float:Position[4];
 
    if 
(IsPlayerAdmin(playerid))
    {
        if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, " * You must be on foot to use this command.");
        if(crateExist == 0)
        {
            crateExist = 1;
            GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
            GetPlayerFacingAngle(playerid, Position[3]);
            cratePos[0] = Position[0];
            cratePos[1] = Position[1];
            cratePos[2] = Position[2];
            cratePos[3] = Position[3];
            dynamicFlare = CreateDynamicObject(18728, Position[0], Position[1]+1.5, Position[2]+125.9096, 0.0, 0.0, Position[3], -1, -1, -1, 200.0);
            dynamicParachute = CreateDynamicObject(18849, Position[0], Position[1], Position[2]+133.4096, 0.0, 0.0, Position[3], -1, -1, -1, 200.0);
            SendClientMessageToAll(COLOR_LIGHTBLUE, " * Reporter says: A military cargo plane accidentally dropped a weapon crate.");
            SendClientMessageToAll(COLOR_LIGHTBLUE, " * Reporter says: The weapon crate will land in ETA 22 seconds!");
            MoveDynamicObject(dynamicFlare, Position[0], Position[1]+1.5, Position[2]-2.5, DROPSPEED, -1, -1, -1);
            MoveDynamicObject(dynamicParachute, Position[0], Position[1], Position[2]+6.4, DROPSPEED, -1, -1, 1000);
            cratedropTimer = SetTimerEx("CrateMove", 21600, false, "i", playerid);
        }
        else
        
{
            CrateEnd(playerid);
        }
    }
    return 1;
}
forward CrateMove(playerid);
public CrateMove(playerid)
{
    new Float:Position[3];
    DestroyDynamicObject(dynamicParachute);
    dynamicCrate = CreateDynamicObject(964, cratePos[0], cratePos[1], cratePos[2]-1, 0.0, 0.0, cratePos[3], -1, -1, -1, 200.0);
    SetDynamicObjectMaterial(dynamicCrate, 0, 11745, "kmb_chute", "ParaDropNonDynamic", CRATECOLOR);
    GetDynamicObjectPos(dynamicCrate, Position[0], Position[1], Position[2]);
    dynamicCrate3DText = CreateDynamic3DTextLabel("/picklock\nTo unlock the weapon crate.", COLOR_RED,Position[0], Position[1], Position[2]+1.2,8.0);
    SetDynamicObjectMaterial(dynamicCrate, 3, 17555, "eastbeach3c_lae2", "metpull_law", COLOR_RED);
    crateOnGround = 1;
    SendClientMessageToAll(COLOR_LIGHTRED, " * The weapon crate is now on the ground - /findcrate");
    SendClientMessageToAll(COLOR_LIGHTRED, " * The weapon crate will self-destruct in 10 minutes after picklocking!");
    //cratedestroyTimer = SetTimerEx("CrateEnd", CRATEDESTRUCT, false, "i", playerid);
    return 1;
}
forward CrateEnd(playerid);
public CrateEnd(playerid)
{
    KillTimer(progressBar);
    KillTimer(cratedropTimer);
    KillTimer(cratedestroyTimer);    
    KillTimer
(picklockTimer);    
    KillTimer
(crateChecker);
 
    DestroyDynamicObject
(dynamicCrate);
    DestroyDynamicObject(dynamicFlare);
    DestroyDynamicObject(dynamicParachute);
 
    DestroyDynamic3DTextLabel
(Text3D:dynamicCrate3DText);
 
    CountDown 
= PICKLOCKTIME / 1000;        
    crateUnlocked 
= 0;
    crateOnGround = 0;            
    crateExist 
= 0;
    randomDialog = 0;
    weaponsTooked = 0;
 
    for
(new i; i < sizeof(cratePos); i++)    
        cratePos
[i] = 0;
    for(new i; i < sizeof(weaponsTook); i++)
        weaponsTook[i] = 0;
    for(new i; i < MAX_PLAYERS; i++)
        if(isPicklocking[i] == 1)
            isPicklocking[i] = 0;    
 
    SendClientMessageToAll
(COLOR_LIGHTRED, " * The weapon crate has self-destructed.");
 
    return 1
;
}
[center]i love you [s]mxIni[/s] Mysql[/center]


Вернуться в «Скрипты / FS»

Кто сейчас на форуме (по активности за 5 минут)

Сейчас этот раздел просматривают: 5 гостей