Land Dynamic System
#1

Hello guys, if you have played limitless script before, you probably noticed how you can buy clothing and attach them in your skin, and also the way you build your lands, you have 3 lines going in the X and Y and Z direction and you can pull and push them where ever you want.

How did Emmet and Josh Einstein(The GM creators) do it, i wanna know to make one for my server, too.
Reply
#2

I haven't seen the way limitless works, but I assume its through one of these three functions and following callbacks:

https://sampwiki.blast.hk/wiki/EditObject or https://sampwiki.blast.hk/wiki/EditPlayerObject & https://sampwiki.blast.hk/wiki/OnPlayerEditObject

or

https://sampwiki.blast.hk/wiki/EditAttachedObject & https://sampwiki.blast.hk/wiki/OnPlayerEditAttachedObject

Which one you use depends on which type of object you are editing. So for example if you wanted to edit an object that you attach to your player(glasses, hair, etc.), you would use this function:
PHP код:
 EditAttachedObject(playeridobjectid); 
and this callback:
PHP код:
public OnPlayerEditAttachedObject(playeridresponseindexmodelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ)
{
    if(
response// What happens when they save the position
    
{
      
// code here
    
}
    else 
// What happens when they cancel
    
{
      
// code here
    
}
    return 
1;

Reply
#3

If you're using streamer, use this function EditDynamicObject, and this callback OnPlayerEditDynamicObject
Reply
#4

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
If you're using streamer, use this function EditDynamicObject, and this callback OnPlayerEditDynamicObject
I want something like this.
https://www.youtube.com/watch?v=YCMGnZdClSk
Reply
#5

PHP код:
new object_id CreateDynamicObject(......);
EditDyanmicObject(playeridobject_id); 
How hard is that?
Reply
#6

Its Just like you create Toys or Accessories System you create in your server. the difference is that Toys are attached to Player's body and Furniture is attached to a piece of land.

What you can do is, you can use IsPlayerInArea() function to create lands(North,West,,South,East Coords) and check if ISPlayerOnLand using IsPlayerInArea(). and allow him to Spawn objects there and edit them as long as they are returning true on IsPlayerOnLand.

Just think about a nice unique idea. just don't make it exactly like Lawless cuz no one's gonna play if you have something exactly same the other is providing. try to add some new variations. Try to make a system Lawless wanna copy from you. Good Luck.
Reply
#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
#8

Quote:
Originally Posted by adammal
Посмотреть сообщение
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.
Does that include the custom X, Y and Z lines that i can pull and push like here?
https://www.youtube.com/watch?v=YCMGnZdClSk
Reply
#9

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Does that include the custom X, Y and Z lines that i can pull and push like here?
https://www.youtube.com/watch?v=YCMGnZdClSk
Yes, they are supported natively, those are called axis.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)