SA-MP Forums Archive
Setting an object's virtual world - 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: Setting an object's virtual world (/showthread.php?tid=379656)



Setting an object's virtual world - fordawinzz - 22.09.2012

Is it possible without re-creating the object? Thank you.. (I'm using the Streamer plugin).


Re: Setting an object's virtual world - IstuntmanI - 22.09.2012

Use
pawn Код:
native Streamer_SetIntData(type, {Text3D,_}:id, data, value);
with type STREAMER_TYPE_OBJECT, id your object ID and data E_STREAMER_WORLD_ID, like this:
pawn Код:
Streamer_SetIntData( STREAMER_TYPE_OBJECT, MyObject, E_STREAMER_WORLD_ID, 1 );
- will set MyObject's world to 1.


Re: Setting an object's virtual world - fordawinzz - 22.09.2012

yeah, found that after I posted, thank you anyway !

EDIT: did that, but it won't work, wtf.


Re: Setting an object's virtual world - ReneG - 22.09.2012

Maybe you used Streamer_SetIntData wrong. In the case that you can't manipulate an object's virtual world without re-creating it, I made this really quick, it compiles, and should work in-game. Because there wasn't a function to get an object's model, you'll have to know the model of the object beforehand.

pawn Код:
stock SetDynamicObjectVirtualWorld(objectid, model, virtualworld)
{
    if(IsValidDynamicObject(objectid)) {
        new
            Float:fPos[3],
            Float:fRotPos[3];
           
        GetDynamicObjectPos(objectid, fPos[0], fPos[1], fPos[2]);
        GetDynamicObjectRot(objectid, fRotPos[0], fRotPos[1], fRotPos[2]);
        DestroyDynamicObject(objectid);
       
        CreateDynamicObject(model, fPos[0], fPos[1], fPos[2], fRotPos[0], fRotPos[1], fRotPos[2], virtualworld, _, _, _);
        return 1;
    }
   
    else return 0;
}