bandi94 Posted August 6, 2011 Share Posted August 6, 2011 i wana make an NPC(self driving) plane the best way is make it server side but setControlState what is server/client side its only working whit real players not work whit a created ped setPedControlState its only clientside i tryed to make it whit trigger function but i get a messup 1 plane controlated by more player and not in sync hmm some ideas how can i make it 1 plane visible and sync for all players flying (whitout set up whit ElementVelocity rotations and more it will take a lot of time for 1m and for 3 airports .. ) Link to comment
NeXTreme Posted August 6, 2011 Share Posted August 6, 2011 I'm also having a similar problem like this. Need a server-sided ped control function.... Well you could use a little hacky way, basically make the server estimate where the ped should be, and keep it syncing that position to all clients. Link to comment
bandi94 Posted August 6, 2011 Author Share Posted August 6, 2011 hmm i got an idea i need to test it when a player join the server side script check's the plane position and when the plane is in landing section then tigger the clients side scrip ( when all players left the server then plane is moved on the landing section) then for all players the clientside script start at 1 place and theoretical then need to be sync for all players add it wil be nice a server side PedControlStat in next version's Link to comment
Wojak Posted August 6, 2011 Share Posted August 6, 2011 You can attach the vehicle to an object and move the object (server side) you may achive a realistic efect, and it will be synced Link to comment
NeXTreme Posted August 6, 2011 Share Posted August 6, 2011 It could work quite well with planes. Unfortunately I am using cars myself, so it would look unreal. Link to comment
bandi94 Posted August 6, 2011 Author Share Posted August 6, 2011 @Wojak that is a good idea to but i get an idea for more realistic bk my plane has the setuped route and not to folow somedoy i will try to create ColShape's on the route and when the plane hit the coolsape then trigger on clients side a moddification like setPedControlState(pilot,"vehicle_left",true) and affter whit setTimer... to make it false and then theoretical the event is triggered at same time for each player ( when the plane hit the ColShape ) and then theoretical it need to be synced (only for each modification need a ColShape) and it will be realistic for cars to Link to comment
NeXTreme Posted August 6, 2011 Share Posted August 6, 2011 You can achieve the smooth effect with function like setElementRotation and setElementVelocity. Also take a look at these two functions, they're really useful with stuff like this. I've been using them for a few projects so far and they turned out great. https://wiki.multitheftauto.com/wiki/GetElementSpeed https://wiki.multitheftauto.com/wiki/SetElementSpeed Link to comment
bandi94 Posted August 6, 2011 Author Share Posted August 6, 2011 @NeXTreme thx for links but i know already that stufs yes you can use rotation and Velocity but if i think on it a litel you have a lot of work whit that for each turn you need to setup rotation Velocity and .... and after turn get it back .... i will try whit the ColShape's and i will post the result (after the plane is coming some bus trafic and it will be more realistic whit the ColShapes theory Link to comment
DiSaMe Posted August 7, 2011 Share Posted August 7, 2011 Server-side setPedControlState isn't necessary at all. It's not hard to use it client-side and keep the ped synced. First of all, you should remember that position is synced. If ped is doing 100 different things on the screen of each client, everyone will still see him in the position where syncer sees him. Also, element data is synced too, unless you choose not to sync it. Element data can be used by the server to set the ped task. So, we have two most important things synced: position and element data. Every client can use it to control the ped on its own, and most of the time they will see the same. A simple example: you want the ped to walk straight to the position where you set. Client can simply calculate rotation from the current position to the destination and set camera rotation and control state. The only thing it needs to know is destination. You can simply set it from the server using element data. If every client has the same primary data, the result will be the same too. Link to comment
bandi94 Posted August 7, 2011 Author Share Posted August 7, 2011 @CrystalMV WOW i understand 50% ok when a player joined the server form server side it get the element curent position and send it for client side after calculate the rotaiton but how the client side script set up /calcualte automaticali the control state (i mean on my idea whit colShapes i set up for every colShapes the changes ex setPedControlState(pilot,"vehicle_left",true) when hit it and whit a timer or when left then make it false) but how i understand you make this setPedControlState setup/calculate automaticali hmm.. ? (or you mean the ped need only to go forward and then only you setup the ped rotation ) Link to comment
DiSaMe Posted August 7, 2011 Share Posted August 7, 2011 Using colshapes isn't very reliable because ped cannot be controlled in perfect accuracy in this way unless there are colshapes on all sides of paths to lead the ped back on the path. When controlled in my way, peds are cycled through every frame (onClientPreRender) the data is processed (like calculating angle from current position and destination) and their control states are set. That means they're always aware of changing conditions. So you can calculate the angle from plane to the destination path point and use it to set control states. On the other hand, this way may need optimizations to be efficient when used on many peds. Controlling the ped using colshapes may work well, but these are things you should take care about: 1. Cover the path with colshapes from all sides. For example, if the ped has turned to the right too much, he must hit the colshape which makes him turn left, so that he gets back on the path. 2. When the ped gets streamed in for the client, it should be checked whether he is in any of the colshapes, and if so, then set the control state to what the colshape should set. Link to comment
Wojak Posted August 7, 2011 Share Posted August 7, 2011 You are missing an important point... peds are synced only if there are at lest within 100 m radius from any player vehicles are synced only if there are at lest within 140 m radius from any player source: https://wiki.multitheftauto.com/wiki/SetElementSyncer if the element is not synced seting the velocity won't have any efect nor the collshape events will be triggered... (setting the element position or attaching element to an object and moving the object will work though) also if the element is synced setPedControlState shuld onnly be used on the syncer client (you may use onElementStartSync, onElementStopSync events or getElementSyncer function to get this client and trigger a proper clientside event) Link to comment
bandi94 Posted August 7, 2011 Author Share Posted August 7, 2011 hmm i maked an NPC taxi on airport whit markers when the car hit the marker then trigger setPedControlState(pilota1,"vehicle_right",true) when leave the marker then setPedControlState(pilota1,"vehicle_right",false) and worked whit 3 players (+/- ) but i will cover the all road edges whit marker/ColShapes if the car leaver +/- the route hit the marker and turn bk on router(like @CrystalMV say) and i think the plane i will make whit attach object and server side (for busses it will be non realistic whit attach object and the road is not flat ...) now my question is can i detect the object/car that hit the marker ? or only whit ColShape can be detected and if only whit colShape then the "ColSphere" is as marker in form and radius bk ColSphere is invisible and can i make a group of markers/ColSphere like in 1 group are the left side markers and in another group the right side markers and then "onMarkerHit",leftgoup,turn right) ? and thx for everyone who helped me (or some function to get the marker what was hited? ex "onMarkerHit" .. getHitedMarker ..... and then whit a in pars function chek in what group is that marker/ColShape) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now