[Help] OnPlayerEditObject Issue
#1

Hi there,

I've tried this a few times now, but everytime I use the OnPlayerEditObject function and hit the save button on the pins in game nothing happens, doesn't matter if I cancel it or if I hit the save key, it doesn't work. I've tried it on different functions I tried to make but shut it down since the OnPlayerEditObject never works for me.

Just to clearify I use Incognito's streamer but not for the editing function part. What I do is to add a none streamed object and edits it, after that the object is fully edited it will remove it and add the object in a streamed one.

Any ideas what the problem is here?

pawn Код:
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(objectid, oldX, oldY, oldZ);
    GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
    new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT;
    if(!playerobject)
    {
        if(!IsValidObject(objectid)) return;
        MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
    }

    if(response == EDIT_RESPONSE_FINAL)
    {
        new string[254];
        OVW = GetPlayerVirtualWorld(playerid);
        OINT = GetPlayerInterior(playerid);
        GetObjectPos(objectid, OX, OY, OZ);
        GetObjectRot(objectid, ORX, ORY, ORZ);
        AddObjectToFile(OBJECT_FILE_NAME, OX, OY, OZ, ORX, ORY, ORZ, OVW, OINT);
        SendClientMessage(playerid, 0xD8D8D8FF, "Object Placed");
        CreateDynamicObject(oModel, Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, -1, 200.0);
        DestroyObject(Object1337);
    }

    if(response == EDIT_RESPONSE_CANCEL)
    {
        if(!playerobject)
        {
            SetObjectPos(objectid, oldX, oldY, oldZ);
            SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
        }
        else
        {
            SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
            SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
        }
    }
}
Where the editobject is executed.
pawn Код:
new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ;
GetPlayerPos(playerid, OX, OY, OZ);
oModel = 19172;
ORX = 0.0;
ORY = 0.0;
ORZ = 0.0;
Object1337 = CreateObject(oModel, OX+2, OY, OZ, ORX, ORY, ORZ);
EditObject(playerid, Object1337);
Reply
#2

You defined EDIT_RESPONSE_FINAL and CANCEL on your own? if so show me that line.
Reply
#3

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
You defined EDIT_RESPONSE_FINAL and CANCEL on your own? if so show me that line.
I where looking at your account details, to be having 1,262 posts I wonder if thats spam or if you know anything about OnPlayerEditObject. Well I take that as you don't know anything about this problem, no offence. https://sampwiki.blast.hk/wiki/OnPlayerEditObject look at the example please.

I never mentioned anything about doing EDIT_RESPONSE_FINAL and EDIT_RESPONSE_CANCEL by my self, there's an example of it on samps wiki.
Reply
#4

Thing is I DO know about it but I don't use those defines. Simple if(response) or if(!response) does the job. And no, those posts aren't spam. Second thing is if your code isn't called maybe, for example, your statements don't allow it to execute. Check all filters again. Debug if necessary.
Reply
#5

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Thing is I DO know about it but I don't use those defines. Simple if(response) or if(!response) does the job. And no, those posts aren't spam. Second thing is if your code isn't called maybe, for example, your statements don't allow it to execute. Check all filters again. Debug if necessary.
Okey so if I understanded this correct it's better to just do if(response) then if(response == EDIT_RESPONSE_FINAL) Also I just tried that, it's still the same
Reply
#6

Nope. It's not better but it's same. As for your code add something like this:

pawn Код:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    print("[DEBUG] Callback Started");
    new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
    GetObjectPos(objectid, oldX, oldY, oldZ);
    GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
    new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT;
    if(!playerobject)
    {
        print("[DEBUG] if(!playerobject) called");
        if(!IsValidObject(objectid)) return;
        MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
    }

    if(response == EDIT_RESPONSE_FINAL)
    {
        print("[DEBUG] response FINAL called");
        new string[254];
        OVW = GetPlayerVirtualWorld(playerid);
        OINT = GetPlayerInterior(playerid);
        GetObjectPos(objectid, OX, OY, OZ);
        GetObjectRot(objectid, ORX, ORY, ORZ);
        AddObjectToFile(OBJECT_FILE_NAME, OX, OY, OZ, ORX, ORY, ORZ, OVW, OINT);
        SendClientMessage(playerid, 0xD8D8D8FF, "Object Placed");
        CreateDynamicObject(oModel, Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, -1, 200.0);
        DestroyObject(Object1337);
    }

    if(response == EDIT_RESPONSE_CANCEL)
    {
        print("[DEBUG] response CANCEL called");
        if(!playerobject)
        {
            print("[DEBUG] if(!playerobject) inside response CANCEL called");
            SetObjectPos(objectid, oldX, oldY, oldZ);
            SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
        }
        else
        {
            print("[DEBUG] else of !playerobject under CANCEL called");
            SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
            SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
        }
    }
}
Edit object and save it. Show us server_log.txt afterwards.
Reply
#7

Okey, so I just tried the print the debug out, nothing ends up in the server_log.txt, it only shows that I connected and logged in thats all.

Also I get no errors from the codes, to be honest I have no clue what this warning stands for but it may have something to do with it?

pawn Код:
I:\FTP\gamemodes\General.pwn(62343) : warning 209: function "Streamer_OnPlayerEditObject" should return a value
I:\FTP\gamemodes\General.pwn(62383) : warning 209: function "Streamer_OnPlayerEditObject" should return a value
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase

Header size:          14632 bytes
Code size:          3448632 bytes
Data size:         10413168 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:13892816 bytes

2 Warnings.
Reply
#8

Bump*

How it the world can it be that my OnPlayerEditObject is not working, I also fixed the warnings and it still not working. Doesn't even print a damn thing in to the server_log.txt

Any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)