Object - Please help!
#1

Hello!

I'm making an in-game object edior, using 0.3e's EditObject(); function.
And I made 3 commands and they're: /co (create object), /eo (edit object), /do (destroy object).

And the thing is the actual object ID? I don't mean the object's model ID, I mean the object ID (1, 2, 3, 7, 14, 21, etc...).

I know there is no such function as GetObjectID, as it wouldn't even make any sense though...

What I want? I want a notification message which will show me the object ID when it's created (not object's model id), same as in /eo and /do command.

Is that even possible?

(Please don't tell me to search the forums, because I did and my eyes hurt, I don't know what to do anymore... So that's why I'm asking for help here, again...)

Here are my commands:



pawn Код:
CMD:co(playerid, params[])
{
    if(sscanf(params, "i", oID)) return SendClientMessage(playerid, 0xF81414FF, "USAGE: /co [objectid].");

    GetPlayerPos(playerid, X, Y, Z);

    CreateObject(oID, X, Y, Z, 0.0, 0.0, 0.0, 300.0);

    format(String, sizeof(String), "You have successfully created objectid: %d", oID);
    SendClientMessage(playerid, 0x33AA33FF, String);
    return 1;
}
pawn Код:
CMD:eo(playerid, params[])
{
    if(sscanf(params, "d", oID)) return SendClientMessage(playerid, 0xF81414FF, "USAGE: /eo [objectid].");

    if(IsValidObject(oID))
    {
    EditObject(playerid, oID);
   
    format(String, sizeof(String), "You're now editing objectid: %d", oID);
    SendClientMessage(playerid, 0x33AA33FF, String);
    }
    else
    {
    SendClientMessage(playerid, 0xF81414FF, "ERROR: Invalid objectid.");
    }
    return 1;
}
pawn Код:
CMD:do(playerid, params[])
{
    if(sscanf(params, "d", oID)) return SendClientMessage(playerid, 0xF81414FF, "USAGE: /do [objectid].");

    if(IsValidObject(oID))
    {
    DestroyObject(oID);
   
    format(String, sizeof(String), "You have successfully destroyed objectid: %d", oID);
    SendClientMessage(playerid, 0x33AA33FF, String);
    }
    else
    {
    SendClientMessage(playerid, 0xF81414FF, "ERROR: Invalid objectid.");
    }
    return 1;
}
Reply
#2

Anyone? Anything?
Reply
#3

if(strcmp(cmd, "/playerlabel", true) == 0)
{
new PlayerText3Dlayertextid;
new Float:X, Float:Y, Float:Z;
GetPlayerPos( playerid, X, Y, Z );
playertextid = CreatePlayer3DTextLabel(playerid);
return 1;
}

Something like that make sure you add your "CreateObject" no brackets make two spaces than sue SendClientMessage And use the string of your CreateObject try that and then refer to me..
Reply
#4

what I did once is this:

pawn Код:
new objectident;

CMD:co(playerid, params[])
{
    new str1[128];
    if(sscanf(params, "d", objectident)) return SendClientMessage(playerid, -1, "USAGE: /co [object id]");
    else
    {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        objectident = CreateObject(objectident,x,y+3,z,0,0,0);
        EditObject(playerid, objectident);
        format(str1,sizeof(str1),"You Have Created Object %d.", objectident);
        SendClientMessage(playerid, -1, str1);
    }
    return 1;
}

CMD:eo(playerid, params[])
{
    new str1[128];
    if(sscanf(params, "d", objectident)) return SendClientMessage(playerid, -1, "USAGE: /eo [object id]");
    if(!IsValidObject(objectident)) return SendClientMessage(playerid,-1,"This Object Does Not Exist.");
    else
    {
        format(str1,sizeof(str1),"You Are Now Editing Object %d.", objectident);
        SendClientMessage(playerid, -1, str1);
        EditObject(playerid, objectident);
    }
    return 1;
}

CMD:do(playerid, params[])
{
    new str1[128];
    if(sscanf(params, "d", objectident)) return SendClientMessage(playerid, -1, "USAGE: /do [object id]");
    if(!IsValidObject(objectident)) return SendClientMessage(playerid,-1,"This Object Does Not Exist.");
    else
    {
        format(str1,sizeof(str1),"You Have Deleted Object %d.", objectident);
        SendClientMessage(playerid, -1, str1);
        DestroyObject(objectident);
    }
    return 1;
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
    GetObjectPos(objectident, oldX, oldY, oldZ);
    GetObjectRot(objectident, oldRotX, oldRotY, oldRotZ);
    if(!playerobject)
    {
        if(!IsValidObject(objectident)) return 1;
        SetObjectPos(objectident, fX, fY, fZ);
        SetObjectRot(objectident, fRotX, fRotY, fRotZ);
    }

    if(response == EDIT_RESPONSE_FINAL)
    {
        if(!IsValidObject(objectident)) return 1;
        SetObjectPos(objectident, fX, fY, fZ);
        SetObjectRot(objectident, fRotX, fRotY, fRotZ);
    }

    if(response == EDIT_RESPONSE_CANCEL)
    {
        if(!playerobject)
        {
            SetObjectPos(objectident, oldX, oldY, oldZ);
            SetObjectRot(objectident, oldRotX, oldRotY, oldRotZ);
        }
        else
        {
            SetPlayerObjectPos(playerid, objectident, oldX, oldY, oldZ);
            SetPlayerObjectRot(playerid, objectident, oldRotX, oldRotY, oldRotZ);
        }
    }
    return 1;
}
This happened to return the object id and not the model id. It tells you the object identification number used to delete it.
Reply
#5

CreateObject returns the ID of the object created, so you can just do:

pawn Код:
new oID = CreateObject(model, X, Y, Z, 0.0, 0.0, 0.0, 300.0);
oID now holds the object ID.
Reply
#6

It really works! So, guys, I'm really thankful, to all of You! Especially Banana_Ghost (will add credits for You all), thanks again!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)