SA-MP Forums Archive
warning 209: function "Streamer_OnPlayerEditObject" should return a value - 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: warning 209: function "Streamer_OnPlayerEditObject" should return a value (/showthread.php?tid=495308)



warning 209: function "Streamer_OnPlayerEditObject" should return a value - Phil_Cutcliffe - 16.02.2014

What have I done wrong 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 this is a global object, move it for other players
    {
        if(!IsValidObject(objectid)) return;
        MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
    }
    if(response == EDIT_RESPONSE_FINAL)
    {
        for(new object; object < sizeof(ObjectInfo); object++)
        {
            ObjectInfo[object][oVW] = GetPlayerVirtualWorld(playerid);
            ObjectInfo[object][oINT] = GetPlayerInterior(playerid);
            GetObjectPos(objectid, OX, OY, OZ);
            ObjectInfo[object][oX] = OX;
            ObjectInfo[object][oY] = OY;
            ObjectInfo[object][oZ] = OZ;
            GetObjectRot(objectid, ORX, ORY, ORZ);
            ObjectInfo[object][oRX] = ORX;
            ObjectInfo[object][oRY] = ORY;
            ObjectInfo[object][oRZ] = ORZ;
            ObjectInfo[object][oCreated] = 1;
            SaveObjects();
            SendClientMessage(playerid, COLOR_BLUE, "Object Saved.");
            CreateDynamicObject(ObjectInfo[object][oModel], Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, -1, 200.0);
            DestroyObject(ObjectInfo[object][oObject]);
        }
    }
    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);
        }
    }
}



Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - iZN - 16.02.2014

Return value. I think the streamer plugin hooking is causing this. Just return true in the last lines, it would fix it.

pawn Код:
}
    return true;
}



Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - NewerthRoleplay - 16.02.2014

You have to add
pawn Код:
return true;
to the end


Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - Phil_Cutcliffe - 16.02.2014

Quote:
Originally Posted by iZN
Посмотреть сообщение
Return value. I think the streamer plugin hooking is causing this. Just return true in the last lines, it would fix it.

pawn Код:
}
    return true;
}
I put it like this but I now get 1 error and 1 warning..

: warning 209: function "Streamer_OnPlayerEditObject" should return a value
: error 078: function uses both "return" and "return <value>"

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 this is a global object, move it for other players
    {
        if(!IsValidObject(objectid)) return;
        MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
    }
    if(response == EDIT_RESPONSE_FINAL)
    {
        for(new object; object < sizeof(ObjectInfo); object++)
        {
            ObjectInfo[object][oVW] = GetPlayerVirtualWorld(playerid);
            ObjectInfo[object][oINT] = GetPlayerInterior(playerid);
            GetObjectPos(objectid, OX, OY, OZ);
            ObjectInfo[object][oX] = OX;
            ObjectInfo[object][oY] = OY;
            ObjectInfo[object][oZ] = OZ;
            GetObjectRot(objectid, ORX, ORY, ORZ);
            ObjectInfo[object][oRX] = ORX;
            ObjectInfo[object][oRY] = ORY;
            ObjectInfo[object][oRZ] = ORZ;
            ObjectInfo[object][oCreated] = 1;
            SaveObjects();
            SendClientMessage(playerid, COLOR_BLUE, "Object Saved.");
            CreateDynamicObject(ObjectInfo[object][oModel], Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, -1, 200.0);
            DestroyObject(ObjectInfo[object][oObject]);
        }
    }
    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);
        }
    }
    return true;
}



Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - NewerthRoleplay - 16.02.2014

What happens if you replace
pawn Код:
if(!IsValidObject(objectid)) return;
with
pawn Код:
if(!IsValidObject(objectid)) return 0;



Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - Phil_Cutcliffe - 16.02.2014

Then it won't move the object back to its default location if it is not a valid object?


Re: warning 209: function "Streamer_OnPlayerEditObject" should return a value - iZN - 16.02.2014

pawn Код:
if(!IsValidObject(objectid))
   return MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
If the object is valid return what? Just process your function.