object drop script question
#1

Hello i made this simple object drop and pickup script. I looked at some weapondrop scripts to see how they did it.
It all works fine, but now the question:
Is it possible to put a pickable object under onfilterscriptinit with this script ?
Obviously i tried it myself but it didnt work..thats why i im hoping someone could share some thoughts.

Please take a look if your in for it;

pawn Код:
#include <a_samp>
#define MAX_OBJ 50

new object[MAX_OBJ];
new Float:ObjCoords[MAX_OBJ][3];
new ObjectID[MAX_OBJ][2];

new Items[22][0] = {                  

    {0},        // Empty
    {18632},    //fishing rod
    {18633},    //wrench
    {18634},    //crowbar
    {18635},    //hammer
    {18641},    //flashlight
    {18642},    //taser1
    {18644},    //screwdriver
    {18890},    //rake1 (hark)
    {1650},     //can of gasoline
    {18865},    //phones
    {18866},
    {18867},
    {18868},
    {18869},
    {18870},
    {18871},
    {18872},
    {18873},
    {18874},
    {2966},
    {2967}
};

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("      Items [FS] By AIped");
    print("--------------------------------------\n");
    new f = MAX_OBJ+1;
//  new obj = Items[11][0];
//  ObjectID[f][0] = 1650;
/*
    ObjCoords[f][0] = 687.6618;
    ObjCoords[f][1] = -592.2153;
    ObjCoords[f][2] = 16.3359 -1;
    CreateObject(Items[5][0],ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0);
*/

    object[f] = CreateObject(1650,687.6618,-592.2153,16.3359 -1,93.7,120.0,120.0); //wont work hm
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/haveitem", true) == 0)
    {
        SetPVarInt(playerid, "ItemIndexSel", Items[21][0]);
        SetPlayerAttachedObject(playerid,0,Items[21][0],6,0.080998,0.039998,0.003000,93.300010,83.899993,-0.799999,1.000000,1.000000,1.000000);
        SendClientMessage(playerid, 0x33AA3300, "You have an item.");
        GivePlayerWeapon(playerid,18632,1);
        return 1;
    }
    if(strcmp(cmdtext, "/ditem", true) == 0)//drop item (object)
    {
        new f = MAX_OBJ+1;
        new itemID = GetPVarInt(playerid,"ItemIndexSel");
        for(new a = 0; a < sizeof(ObjCoords); a++)
        {
            if(ObjCoords[a][0] == 0.0)
            {
                f = a;
                break;
            }
        }
        for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
        if(GetPVarInt(playerid,"ItemIndexSel")>0)return SendClientMessage(playerid, 0x33AA3300, "You dont have anything on you");
        else
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not drop items at the moment, try again later.");
        ObjectID[f][0] = itemID;
        GetPlayerPos(playerid, ObjCoords[f][0], ObjCoords[f][1], ObjCoords[f][2]);
        object[f] = CreateObject(itemID,ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0);
        DeletePVar(playerid, "ItemIndexSel");
        RemovePlayerAttachedObject(playerid,0);
        return 1;
    }
   
    if(strcmp(cmdtext, "/pitem", true) == 0)//pickup item (object)
    {
        new f = MAX_OBJ+1;
        for(new a = 0; a < sizeof(ObjCoords); a++)
        {
                if(IsPlayerInRangeOfPoint(playerid, 5.0, ObjCoords[a][0], ObjCoords[a][1], ObjCoords[a][2]))
                {
                    f = a;
                    break;
                }
        }
        if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not close to any weapon which you can pick up.");
        else
        {
                ObjCoords[f][0] = 0.0;
                ObjCoords[f][1] = 0.0;
                ObjCoords[f][2] = 0.0;

                SetPVarInt(playerid, "ItemIndexSel",ObjectID[f][0]);
                SetPlayerAttachedObject(playerid,0,ObjectID[f][0],6,0.080998,0.039998,0.003000,93.300010,83.899993,-0.799999,1.000000,1.000000,1.000000);
                DestroyObject(object[f]);
        }
        return 1;
    }
    return 0;
}
Reply
#2

You could easily just have copied the /ditem script and modified it abit, here you go!

pawn Код:
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("      Items [FS] By AIped");
    print("--------------------------------------\n");
    new f = MAX_OBJ+1;
    new obj = Items[11][0];
    for(new a = 0; a < sizeof(ObjCoords); a++)
    {
        if(ObjCoords[a][0] == 0.0)
        {
            f = a;
            break;
        }
    }

    ObjectID[f][0] = 1650;
    ObjCoords[f][0] = 687.6618;
    ObjCoords[f][1] = -592.2153;
    ObjCoords[f][2] = 16.3359;

    object[f] = CreateObject(Items[5][0],ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0);
    return 1;
}
Untested but that should work.
Reply
#3

Hmm i thought i tried this before but now it worked thanks! XD
its a bit sad that if i want more objects then one, the code is gonna be big.
Reply
#4

Load your saved objects from flatfiles or a database then.
Reply
#5

Yea that should be the best option i guess
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)