SA-MP Forums Archive
Dynamic Door help. Will REP++++ - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dynamic Door help. Will REP++++ (/showthread.php?tid=472135)



Dynamic Door help. Will REP++++ - Alex_T - 27.10.2013

How would I be able to toggle the Dynamic door to be able to be accessed from vehicles with?


pawn Код:
CMD:createdoor(playerid, params[])
{
    new string[128], type;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
    if(sscanf(params, "i", type)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /createdoor [pickupid]");
    if(type == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door type.");
    for(new idx=0; idx<MAX_DOORS; idx++)
    {
        if(!DoorInfo[idx][dType])
        {
            GetPlayerPos(playerid, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]);
            DoorInfo[idx][dType] = type;
            DoorInfo[idx][dOInt] = GetPlayerInterior(playerid);
            DoorInfo[idx][dOVW] = GetPlayerVirtualWorld(playerid);
            GetPlayerFacingAngle(playerid, DoorInfo[idx][dOA]);
            // Creating the door
            DoorInfo[idx][dPickup] = CreateDynamicPickup(DoorInfo[idx][dType], 1, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ], DoorInfo[idx][dOVW], DoorInfo[idx][dOInt]);
            format(string, sizeof(string), "ID: %d\n/dedit to set the text", idx);
            DoorInfo[idx][dTextID] = CreateDynamic3DTextLabel(string, COLOR_WHITE, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]+0.3, 15);
            format(string, sizeof(string), "AdmWarn: %s has created door ID %d. (Int: %d | VW: %d)", RPN(playerid), idx, DoorInfo[idx][dOInt], DoorInfo[idx][dOVW]);
            SendAdminMessage(COLOR_DARKRED, 1, string);
            Log("logs/doors.log", string);
            idx = MAX_DOORS;
        }
    }
    return 1;
}




Add it on to the dedit.

pawn Код:
CMD:dedit(playerid, params[])
{
    new idx, text[128], string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
    if(sscanf(params, "s[128]", params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit [option] [doorid]");
        SendClientMessage(playerid, COLOR_GREY, "OPTIONS: Pickup | Text | Interior | Exterior | CustomInterior | CustomExterior");
        return 1;
    }
    if(!strcmp(params, "pickup", true, 6))
    {
        new pickup;
        if(sscanf(params, "s[128]ii", params, idx, pickup)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit pickup [doorid] [pickupid]");
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        DoorInfo[idx][dType] = pickup;
        if(IsValidDynamicPickup(DoorInfo[idx][dPickup]))
        {
            DestroyDynamicPickup(DoorInfo[idx][dPickup]);
        }
        DoorInfo[idx][dPickup] = CreateDynamicPickup(DoorInfo[idx][dType], 1, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ], DoorInfo[idx][dOVW], DoorInfo[idx][dOInt]);
        format(string, sizeof(string), " You have set door ID %d's pickup to %d", idx, pickup);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    if(!strcmp(params, "text", true, 4))
    {
        if(sscanf(params, "s[128]is[128]", params, idx, text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit text [doorid] [text]");
        if(AntiAdv(playerid, params)) return 1;
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        format(DoorInfo[idx][dText], 128, "%s", text);
        format(string, sizeof(string), "ID: %d\n%s", idx, DoorInfo[idx][dText]);
        UpdateDynamic3DTextLabelText(DoorInfo[idx][dTextID], COLOR_WHITE, string);
        format(string, sizeof(string), " You have set door ID %d's text to %s", idx, text);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    if(!strcmp(params, "interior", true, 8))
    {
        if(sscanf(params, "s[128]i", params, idx, text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit interior [doorid]");
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        DoorInfo[idx][dIInt] = GetPlayerInterior(playerid);
        DoorInfo[idx][dIVW] = GetPlayerVirtualWorld(playerid);
        GetPlayerFacingAngle(playerid, DoorInfo[idx][dIA]);
        GetPlayerPos(playerid, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]);
        format(string, sizeof(string), " You have set door ID %d's interior to your coordinates. (Int: %d | VW: %d)", idx, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    if(!strcmp(params, "exterior", true, 8))
    {
        if(sscanf(params, "s[128]i", params, idx, text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit interior [doorid]");
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        DoorInfo[idx][dOInt] = GetPlayerInterior(playerid);
        DoorInfo[idx][dOVW] = GetPlayerVirtualWorld(playerid);
        GetPlayerFacingAngle(playerid, DoorInfo[idx][dOA]);
        GetPlayerPos(playerid, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]);
        DestroyDynamicPickup(DoorInfo[idx][dPickup]);
        DoorInfo[idx][dPickup] = CreateDynamicPickup(DoorInfo[idx][dType], 1, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ], DoorInfo[idx][dOVW], DoorInfo[idx][dOInt]);
        DestroyDynamic3DTextLabel(DoorInfo[idx][dTextID]);
        format(string, sizeof(string), "ID: %d\n%s", idx, DoorInfo[idx][dText]);
        DoorInfo[idx][dTextID] = CreateDynamic3DTextLabel(string, COLOR_WHITE, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]+0.3, 15);
        format(string, sizeof(string), " You have set door ID %d's exterior to your coordinates. (Int: %d | VW: %d)", idx, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    if(!strcmp(params, "custominterior", true, 14))
    {
        if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit custominterior [doorid]");
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        if(!DoorInfo[idx][dCInt])
        {
            DoorInfo[idx][dCInt] = 1;
            format(string, sizeof(string), " You have set door ID %d to have a custom interior.", idx, text);
        }
        else
        {
            DoorInfo[idx][dCInt] = 0;
            format(string, sizeof(string), " You have set door ID %d to have a normal interior.", idx, text);
        }
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    if(!strcmp(params, "customexterior", true, 14))
    {
        if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /dedit customexterior [doorid]");
        if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid door id.");
        if(!DoorInfo[idx][dCExt])
        {
            DoorInfo[idx][dCExt] = 1;
            format(string, sizeof(string), " You have set door ID %d to have a custom exterior.", idx, text);
        }
        else
        {
            DoorInfo[idx][dCExt] = 0;
            format(string, sizeof(string), " You have set door ID %d to have a normal exterior.", idx, text);
        }
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
}


Will rep++++


Re: Dynamic Door help. Will REP++++ - Mattakil - 27.10.2013

pawn Код:
CMD:enter(playerid, params[])
{
    for(new idx=0; idx<MAX_DOORS; idx++)
    {
        if(!DoorInfo[idx][dType])
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]))
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                SetVehiclePos(vehicleid, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]);
                SetVehicleVW(vehicleid, DoorInfo[idx][dIVW]);
                LinkVehicleToInterior(vehicleid, DoorInfo[idx][dIINT]);
                return 1;
            }
        }
    }
    return 1;
}
thats a basic outline, im sure you can make it work from here, checking if the player is in the vehicle, if they are at the interior, and how to pass on foot


Re: Dynamic Door help. Will REP++++ - Alex_T - 27.10.2013

Does not work. It wont let them go through the door.


Re: Dynamic Door help. Will REP++++ - bensmart469 - 27.10.2013

Try to increase the range for /enter? It won't work well if the range is something low e.g. 2, so i'd suggest increasing it to around 5 or 7 to let cars enter/exit.