Jump to content

OOP - Server & Client Sync


iAxel

Recommended Posts

Hello all!

Is it possible to synchronize server-client or client-server?

Server

  
NPC = {} 
  
function NPC:Create(skin, x, y, z, rotation) 
    local ped = createPed(skin, x, y, z, rotation) 
    return ped 
end 
  

Client

  
NPC = {} 
  
function NPC:Move(X, Y) 
    local x, y = getElementPosition(self) 
    setPedCameraRotation(self, math.deg(math.atan2(X - x, Y - y))) 
    setPedControlState(self, 'forwards', true) 
end 
  

Please help me :roll:

Thx

Link to comment
  • MTA Team

You could trigger an event everytime you create a 'NPC' ped and then add create an instance for that ped.

Note: The ped might not exist clientside when the event arrives at clientside - you should mark the ped as NPC on serverside (e.g. setElementData(ped, "npc", true)) and then loop the event until the ped is valid.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...