Jump to content

[WIP/REL] OpenFrame 2.0 / of-gungame | OOP framework and GM


Orange

Recommended Posts

Hey!

Today, I decided to put my WIP version of OpenFrame 2.0 to github and create a gamemode based on it. So, here it comes!

OpenFrame 2.0

http://github.com/pzduniak/openframe

Sorry for not including credits for var_dump function AND gui classes by 50p, but I forgot to do it. I will put them in next commit.

As of 12 December 2011, you can:

  • Create OOP classes, which may be extended (inheritance)
  • Shorten ur code - Source:Vehicle():Position() looks awesome
  • Be proud that players download loads of useless files! (it will change, I'm working on a compressor :3)
  • btw. it smells like an orange!

You can pull it and help me finishing it ;)

of-gungame

http://github.com/pzduniak/of-gungame

Some freaking gungame gamemode which will show how to use OpenFrame.

New weapon is every 3 kills (theoretically configurable, 0.1.1 coming soon). Headshots are enabled. It uses builtin mta maps system (compatible with Deathmatch maps). Using basic ideas of OpenFrame. Simple, but powerful and clearly-written (except logo.lua, which looks like spaghetti code :D - can someone help me with making it readable?). Currently it's not documented, but I'll do it soon. You can see it on Andromeda GunGame server. Few functionalities planned as of the 3rd January.

I will update the topic while I will progress.

Edited by Guest
Link to comment
Can I ask you something?

WHAT IS THIS?!?! I just can't get it.

http://en.wikipedia.org/wiki/Object-ori ... rogramming

You'll know what is it when you see gungame gamemode. All I can provide from now are few lines of code from race scripts on Andromeda Race/DD/DM, which is completely written using OpenFrame.

So, these are two main reasons why have I created it:

function onShop(Source)  
    onReturnShop:ClientTrigger(Source, Items:Get(false, Source:Level(), (Source:Team() == vip_team))) 
end 
  
onRequestShop:Handle(onShop) 

in fact, the same code without openframe will be

function onShop() 
triggerClientEvent(source, getItems(false, getPlayerLevel(source), (getPlayerTeam(source) == vip_team))) 
end 
addEvent("onRequestShop", true) 
addEventHandler("onRequestShop", getRootElement(), onShop) 

Code is shortened and cleaner. Isn't it? (unfortunately, you have to create Event objects somewhere before, like in an additional file - I'm working on a fix for it)

The second reason why I wrote it is this code:

function Player:SkillPoints(value) 
    if tonumber(value) then 
        if not Stats:RowExists({["name"] = self:Account():Name()}) then 
            self:Insert() --shortcut, here comes another function 
        end 
        return Stats:Update({"skillpoints = " .. tostring(value)}, {["name"] = self:Account():Name()}) 
    end 
  
    local t = Stats:Select({["name"] = self:Account():Name()}):itTable() 
     
    if #t == 0 then 
        return 0; 
    end 
     
    return t[1].skillpoints or 0; 
end 

Skillpoints are points on my race server which (as the name suggests) show how high is player's skill. Look at the "Stats" object. It's a query generator for a table in MySQL database. Isn't it easier to create queries like that? Script generates everything. Unfortunately, it's not so useful as it could be, because it should look like this:

local result = Stats:Select():Where("orange", "=", "purple"):andWhere("yellow", "!=", "green"):Order("time", "DESC"):Query():asTable() 

Also, you can see that nothing except core classes really access LUA functions. That means, if I would like to move to SQLite, then I just have to modify MySQL class, so it will use other functions, while providing same output. Guess what? Query generator will still work!

Great job once again Orange.

Thanks. It's not finished though.

Code that I provided here won't work with current github version, mainly because of :Account() and :ClientTrigger() methods. I'm working on fixing that

Link to comment

As of 29 December 2011, you don't even need to create classes (only clientside right now, I will port it to serverside in few minutes).

Example usage:

  
Event:Create("onClientResourceStart"):Handle(onStart) 
-- is now 
onClientResourceStart:Handle(onStart) 
  

Link to comment
I still cannot get it at all (I haven't been coding enough on C++), but all what is a see is a good work.

So keep it up :P

This... has nothing to do with C++, brah.

Anyways I support the OOPification of MTA. This is actually what MTA:Orange was supposed to have, too bad you won't see that any time soon though...

I'd love to see this integrated into the MTA Lua VM, that would be awesome.

Link to comment
I give up.

The only object-oriented programming language I know is C++

Excuse me, MR.

Have you heard of PHP, Object Pascal, Java and Python? They're just basic examples of what languages are capable of being OOP.

OpenFrame is basically based on the idea of Kohana PHP framework (which I'm always using for my PHP projects). In future, I will take few more things from it, but first, I want a small interface to all MTA functions.

Link to comment
Have you heard of PHP, Object Pascal, Java and Python? They're just basic examples of what languages are capable of being OOP.

What!?!? WHY DIDN'T ANYONE TELL ME ABOUT THIS? Damn you guys (not talking to anyone in this forum)!!!

Yes, in fact I knew about all of those programming languages (I knew Pascal, not Object Pascal), but didn't know they were OOP just like C++ is.

Well, seems like this is very useful.

Happy developing!

Link to comment
Good Job here Orange ! :D

But why not use getters and setters in method names?

like GetPosition() and SetPosition() instead of Position() ?

Waste of using my poor keyboard :P What's the purpose on writing 2x more functions. And other thing: openframe should make code shorter.

Main topic updated, GunGame 0.1 finished.

Link to comment
  • 2 weeks later...

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