Jump to content

Calling Server/Client Functions in OOP


adamix

Recommended Posts

Posted

Objective: To realize the object on the server with which you can call functions of the client.

Example:

client = Client.new (clientElem);
client.setGarageOpen (1, true);

and the object on the client, with which you can call the server functions.

Example:

server.createPed (1, 1024, 1024, 1024);

Waiting for your ideas and examples. Sorry for my english.

Posted

I've fantasized a bit about an OOP-oriented form of scripting as well. I think it would be neat.

Of course, implementing another language (which you'd almost certainly have to do, to get "real OOP") is a hell of a lot of work.

Posted

I think it is quite possible to implement. I looked at the script rule of arc_, there is implemented such a system only for calling the server functions for client. It is possible to adapt it to calling client functions from server.

Posted

It's an intentional part of mta's design that the client can't do too much that will affect other players. Directly exposing server side functions to clients opens things up for cheaters even more. Remember it's not practical really to have server functions being called from the client and returning values due to the latency.

Posted

I'm not sure that making client and server objects is the most useful way an OO interface for MTA could be made.

If you wanted to make that kind of interface, I believe it'd be fairly easy with metatables.

Posted
i remember that somebody already tryed to make something like oop-style with lua but failed, i think.. agree that it will take an ages to make a new full-power and full working oop "language"..

this one

and this

And i'm that one, and yes it is not yet finished. But still im working on it. But im to busy with other stuff.

Posted
I'm not sure that making client and server objects is the most useful way an OO interface for MTA could be made.

If you wanted to make that kind of interface, I believe it'd be fairly easy with metatables.

It would be easy with metatables but there are main 2 situations where you don't want to use OOP.

1. Calling timers fails, if calling a method from an instance of a class.

local a = Class:new();
setTimer( a:method, 100, 1 ); -- this doesn't work
setTimer( Class.method, 100, 1, a ); -- AFAIR, this fails too

2. You can't really export classes from resource and that makes no use of OOP in Lua for MTA. MTA has new calling exported functions system (accessing exported functions from "exports" table).

exports.myresource:Class:new(); -- Class is a table(class) not exported function and that's why it fails

It would be nice. Even though, I use OOP as often as I can since this is good to get used to.

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...