SA-MP Forums Archive
OnPlayerSelectObject - 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: OnPlayerSelectObject (/showthread.php?tid=357625)



OnPlayerSelectObject - SnG.Scot_MisCuDI - 07.07.2012

When doing OnPlayerSelectObject, than making it call the EditObject, it doesnt show the object moving for any player besides the player editing. Even after clicking save.
Code im using (from samp wiki)
And im adding this into GarObject so theyre might be an issue with that

UPDATED CODE: STILL NOT WORKING
pawn Код:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    new o = Objects[playerid][objectid];
    new Float:oX, Float:oY, Float:oZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ, Float:rX, Float:rY, Float:rZ;
    GetObjectPos(o, oX, oY, oZ);
    GetObjectRot(o, oldRotX, oldRotY, oldRotZ);
    if(ObjectCreator[Objects[playerid][objectid]] == playerid)
    {
        if(!playerobject) // If this is a global object, move it for other players
        {
            if(!IsValidObject(objectid)) return;
            GetObjectPos(o, X, Y, Z);
            SetObjectPos(o, X, Y, Z);
        }

        if(response == EDIT_RESPONSE_FINAL)
        {
            // The player clicked on the save icon
            // Do anything here to save the updated object position (and rotation)
            GetObjectPos(o, X, Y, Z);
            SetObjectPos(o, X, Y, Z);
            SetObjectRot(o, rX, rY, rZ);
        }

        if(response == EDIT_RESPONSE_CANCEL)
        {
            //The player cancelled, so put the object back to it's old position
            if(!playerobject) //Object is not a playerobject
            {
                SetObjectPos(o, oX, oY, oZ);
                SetObjectRot(o, oldRotX, oldRotY, oldRotZ);
            }
            else
            {
                SetPlayerObjectPos(playerid, o, oX, oY, oZ);
                SetPlayerObjectRot(playerid, o, oldRotX, oldRotY, oldRotZ);
            }
        }
    }
}
public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
    if(type == SELECT_OBJECT_GLOBAL_OBJECT)
    {
        EditObject(playerid, objectid);
    }
    else
    {
        EditPlayerObject(playerid, objectid);
    }
    return 1;
}
pawn Код:
dcmd_select(playerid, params[])
{
    #pragma unused params
    new objectid;
    if(ObjectCreator[Objects[playerid][objectid]] == playerid)
    {
        SelectObject(playerid);
    }
    else
    {
        SendClientMessage(playerid, COLOUR_SYSTEM, "This isnt your object!");
        return 0;
    }
    return 1;
}



Re: OnPlayerSelectObject - vassilis - 07.07.2012

Why don't you return a value to the command?


Re: OnPlayerSelectObject - Vince - 07.07.2012

I haven't used these functions yet myself, but I believe that you must confirm the new object's position by using SetObjectPos in OnPlayerEditObject.


Re: OnPlayerSelectObject - SnG.Scot_MisCuDI - 07.07.2012

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Why don't you return a value to the command?
Quote:

This callback does not handle returns.

Quote:
Originally Posted by Vince
Посмотреть сообщение
I haven't used these functions yet myself, but I believe that you must confirm the new object's position by using SetObjectPos in OnPlayerEditObject.
Hmm, i will try that. Thanks


Re: OnPlayerSelectObject - vassilis - 07.07.2012

Quote:
Originally Posted by SnG.Scot_MisCuDI
Посмотреть сообщение
Hmm, i will try that. Thanks
I am talking for the cmd not for the callback..
But anyway what Vince said might be right..


Re: OnPlayerSelectObject - SnG.Scot_MisCuDI - 08.07.2012

Quote:
Originally Posted by vassilis
Посмотреть сообщение
I am talking for the cmd not for the callback..
But anyway what Vince said might be right..
Oh haha, didnt catch that thanks.. But its not the problem
Still havnt tested it yet


Re: OnPlayerSelectObject - vassilis - 08.07.2012

Quote:
Originally Posted by SnG.Scot_MisCuDI
Посмотреть сообщение
Oh haha, didnt catch that thanks.. But its not the problem
Still havnt tested it yet
Oh lol, it's ok but anyway commands should always return a value just to let you know


Re: OnPlayerSelectObject - SnG.Scot_MisCuDI - 08.07.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
I haven't used these functions yet myself, but I believe that you must confirm the new object's position by using SetObjectPos in OnPlayerEditObject.
Look at my new code!


Re: OnPlayerSelectObject - SnG.Scot_MisCuDI - 10.07.2012

bump