Land Dynamic System
#7

I don't know exactly how your code is structured, but I'll give you an example using an enumerator.

Lets say your objects are stored in the enumerator landObjData and it is structured as follows:
PHP код:
new LandData[/* Max number of lands that can be created on the server */][ /*Max number of objects EACH land can have */][landObjData]
enum landObjData
{
   
globalID// Ex. LandData[landid][objid][globalID] = CreateObject(id, x, y, z, rx, ry, rz);
   
modelID,
   
float:positionX,
   
float:positionY,
   
float:positionZ,
   
float:rotationX,
   
float:rotationY,
   
float:rotationZ
}; 
I'm going to suppose you have some sort of command that can be used to edit land_objectid. I would suggest setting player variables to store the land ID they are editing and the object ID they are editing just to be safe when calling OnPlayerEditObject. There are other ways to do this, but you will see that I use "EditingLandID" and "EditingObjectID" to save integer variables.

Somewhere in that command, you add:
PHP код:
EditObject(playeridland_objectid); 
When that function runs through, the object editor will pop up for whoever typed in that command. They'll be able to tug on the axes just like in the video. Meanwhile, the callback OnPlayerEditObject is basically on standby. At this point you can do one of two things: either press the save button, or press escape and not save the object in the position you set it to. When you do one of those, OnPlayerEditObject will automatically be called. If you do not already have OnPlayerEditObject in your script, you need to add it somewhere.

Now I would do something like this:
PHP код:
public OnPlayerEditObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz)
{
    if(
response// The player pressed the save button, now we just need to fully set the object in that position so everyone can see it in its new place.
    
{
        new 
landid GetPVarInt(playerid"EditingLandID");
        new 
objid GetPVarInt(playerid"EditingObjectID");
        if(
GetPVarInt(playerid"EditingLandID") != 0)
        {
            
LandData[landid][objid][positionX] = x;
            
LandData[landid][objid][positionY] = y;
            
LandData[landid][objid][positionZ] = z;
            
LandData[landid][objid][rotationX] = rx;
            
LandData[landid][objid][rotationY] = ry;
            
LandData[landid][objid][rotationZ] = rz;
            
SetObjectPos(LandData[landid][objid][globalID], xyz);
            
SetObjectRot(LandData[landid][objid][globalID]], rx,ry,rz);
            
DeletePVar(playerid"EditingLandID");
            
DeletePVar(playerid"EditingObjectID");
            
// Make sure to save the object on the server's end some point here or later before the LandData is reset.
        
}
    }
    else 
// The player exited, didn't save the object. We need to make it appear back to where it was before.
    
{
        new 
landid GetPVarInt(playerid"EditingLandID");
        new 
objid GetPVarInt(playerid"EditingObjectID");
        
SetObjectPos(playeridLandData[landid][objid][globalID], LandData[landid][objid][positionX], LandData[landid][objid][positionY],LandData[landid][objid][positionZ]);
        
SetObjectRot(playeridLandData[landid][objid][globalID], LandData[landid][objid][rotationX], LandData[landid][objid][rotationY], LandData[landid][objid][rotationZ]);
        
DeletePVar(playerid"EditingLandID");
        
DeletePVar(playerid"EditingObjectID");
    } 
Just remember, like Eoussama said, if you are using a streamer to create your objects then just add "Dynamic" before "Object" in every function. -- SetObjectRot --> SetDynamicObjectRot.
Reply


Messages In This Thread
Land Dynamic System - by Arbico - 11.11.2017, 17:30
Re: Land Dynamic System - by adammal - 11.11.2017, 18:05
Re: Land Dynamic System - by Eoussama - 11.11.2017, 18:32
Re: Land Dynamic System - by Arbico - 11.11.2017, 18:46
Re: Land Dynamic System - by Eoussama - 11.11.2017, 19:27
Re: Land Dynamic System - by GTLS - 11.11.2017, 19:41
Re: Land Dynamic System - by adammal - 11.11.2017, 19:45
Re: Land Dynamic System - by Arbico - 11.11.2017, 19:48
Re: Land Dynamic System - by Eoussama - 11.11.2017, 19:49

Forum Jump:


Users browsing this thread: 1 Guest(s)