Termycraft Posted November 13, 2012 Share Posted November 13, 2012 Hi, scripters! I just want to spawn some enemies in map. I know how to synchronize peds movements between client and server, but I don't know what is the better syncer! I thought that the better syncer can be the player with the lowest ping, but if he's too far from the enemy, he doesn't synchronize. So the problem is the syncer: should I remain the syncer chosen from the server? And how can I make the peds choose their targets? Give me some ideas and I'll do a great work, thanks P.S.: If you can, tell me how you would synchronize peds' actions between clients, thank you very much if you answer to this too Link to comment
uhm Posted November 16, 2012 Share Posted November 16, 2012 That's a really good question and if this works it would be really cool. I think going with best ping is clever, but indeed the streaming is a big deal. If the peds aren't all over SA, then I would just suggest assigning medium sized areas. If the distance between player and the center of the area is too large, a new syncer gets chosen or all peds get destroyed. When someone joins the area, he's the new syncer. If someone else joins with a better ping, he could become the syncer. I would first try it without swapping syncers, so the first one to join is the syncer. I assume it's not a great deal performance wise. Also check out SetPedAimTarget. As for the sync of action goes, I think the best thing you can do is create an array of peds with what they are currently doing. When it changes, the client notifies the server, which then notifies all clients in range. When a client joins in (the area or server), then he gets the current server cached current action. Link to comment
Baseplate Posted November 16, 2012 Share Posted November 16, 2012 you can use this: setElementSyncer Wiki page Link to comment
DiSaMe Posted November 16, 2012 Share Posted November 16, 2012 I don't know if it's useful to try to mess with the sync. At least for now, I'd recommend you to leave it for the server to handle and only do something if it turns out to be necessary. As for controlling, use the server to assign the tasks and client to perform them. Element data is an easy way to sync the information. For example, you can set the data under key "target" to some player on the server, get this data in the client-side script and use it to make the ped attack the player. You may want to try NPC high-level control resource which does the client job for you, all you need to do is set the walking destination point or attack target on the server. It's still in beta though, there aren't many things you could do with it and I don't have any plans to update it soon. Link to comment
Moderators IIYAMA Posted November 16, 2012 Moderators Share Posted November 16, 2012 I won't recommend Element data, it is laggy. I only use it for slow data. Link to comment
Termycraft Posted November 20, 2012 Author Share Posted November 20, 2012 Thanks to everyone. I'll try with tables, now. I hope it won't lag. Link to comment
DiSaMe Posted November 20, 2012 Share Posted November 20, 2012 You can't do this with tables. Table is a data type, not a way for the server and client to communicate. There are only two ways to transfer abstract data between client and server: element data and event triggering. Element data is simpler, but it can be either synced for everybody or nobody. Event triggering allows you to only send data to some players, so you can make the script which sends the data about the ped to the players who are near enough, reducing the bandwidth usage. I'd recommend you to use element data for simplicity and when the script works properly, you can switch to event triggering if you want to optimize the bandwidth usage. Link to comment
Termycraft Posted December 9, 2012 Author Share Posted December 9, 2012 with element data it's LAGGY peds teleport anywhere! Link to comment
Moderators IIYAMA Posted December 19, 2012 Moderators Share Posted December 19, 2012 triggerserverevent triggerclientevent In my opinion element data is useless, why? server to client = trigger event client to client = global table(g_) or trigger event and yes global tables do exist between client and client. But server to client, I don't know. I use Elementdata only for flashbang and tab score. Link to comment
Anderl Posted December 19, 2012 Share Posted December 19, 2012 triggerservereventtriggerclientevent In my opinion element data is useless, why? server to client = trigger event client to client = global table(g_) or trigger event and yes global tables do exist between client and client. But server to client, I don't know. I use Elementdata only for flashbang and tab score. There's no global table between clients, the code is executed for both clients so it will be the same but if you do something like this: if ( localPlayer == somePlayerElement ) then myVar = true; end This will create a "myVar" variable only for that player since the statement will be false for others. Link to comment
Moderators IIYAMA Posted December 19, 2012 Moderators Share Posted December 19, 2012 by 50p on Sun Nov 25, 2012 1:50 pmIs the event even triggered? Where did you get characterID from? Don't make global variables to store IDs, strings, etc. unless it's client-side script. You can make a global table to store that information for every player or simply use setElementData instead. Also, why don't you trigger the "openBriefcase" event only for 1 player? It'd save you some bandwidth and lower the chance of a lag. http://forum.mtavc.com/viewtopic.php?f=91&t=50682 local g_50p sure, Link to comment
Anderl Posted December 19, 2012 Share Posted December 19, 2012 by 50p on Sun Nov 25, 2012 1:50 pmIs the event even triggered? Where did you get characterID from? Don't make global variables to store IDs, strings, etc. unless it's client-side script. You can make a global table to store that information for every player or simply use setElementData instead. Also, why don't you trigger the "openBriefcase" event only for 1 player? It'd save you some bandwidth and lower the chance of a lag. http://forum.mtavc.com/viewtopic.php?f=91&t=50682 local g_50p sure, Was that an answer to me? if it was, then what? Are you talking about "You can make a global table to store that information for every player..."? If so then sure, you can do it but it isn't a global table between clients. The whole script is executed for both clients in the same way so if you create a table, it will be created for all clients. If you add any value there, it will add in all clients too. Link to comment
Moderators IIYAMA Posted December 19, 2012 Moderators Share Posted December 19, 2012 It means I don't wanna argument about it. To prevent fights and tears. 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