Client-side scripting: Difference between revisions
Added an example on reliable client-to-server communication
DrinkyBird (talk | contribs) (Created page with "Client-side scripting is an advanced topic for Zandronum, as you have to be proficient with ACS/decorate/understanding the engine, but also the concept of client/server archit...") |
(Added an example on reliable client-to-server communication) |
||
Line 191: | Line 191: | ||
} | } | ||
Remember that client packets are unreliable which means that there is no guarantee whatsoever that your puked message will ever reach the server. | Remember that client packets are unreliable which means that there is no guarantee whatsoever that your puked message will ever reach the server. To mitigate that, make your serverside script communicate back to the client when they execute successfully (for example, by giving an inventory item) and have double execution protection, and make your clientside script try to repeatedly launch it. | ||
script "DoAction" (void) NET | |||
{ | |||
// cheating protection | |||
if (!MayDoAction()) | |||
terminate; | |||
// double execution protection | |||
if (CheckInventory("ActionDone")) | |||
terminate; | |||
DoServersideStuff(); | |||
GiveInventory("ActionDone", 1); | |||
} | |||
script "RequestAction" (void) CLIENTSIDE | |||
{ | |||
while (ActionStillNeeded() && !CheckInventory("ActionDone", 1)) | |||
{ | |||
NamedRequestScriptPuke("DoAction"); | |||
Delay(10); | |||
} | |||
} | |||
[[category:ACS Functions]] | [[category:ACS Functions]] | ||
[[Category:Level Development]] | [[Category:Level Development]] |