Jump to content
MakeWebGames

Gangster Legends V2.4.0 - Pre Release


Dayo

Recommended Posts

Gangster Legends V2.4.0
Pre Release Notes

Over the past few months since the previous release of GL I have been working on the next release of Gangster Legends. This release aims to fill a few gaps in the engine and fix some core issues.

Below is a full list of the major changes in this version:

New Template engine/renderer 
In the past i built the template engine from scratch using HandleBars.js as a concept. Rather then re-inventing the wheel i have just chosen to replace my engine with the real thing. I have implemented HandleBars PHP into GL.

While HandleBars uses double braces  ({{variable}}) I have altered HandleBars it so it uses single braces to keep backwards compatibility with 3rd party modules.

This fixes several bugs when rendering large templates as well as introducing a lot more functionality you can visit the documentation here to see whats possible with the new engine.

New Item System
One of the core limitations of Gangster Legends was its lack of an item/inventory system, before you would define several items that the user could equip and that was it. The new system opens up endless possibilities. You now have a inventory of items and you can pick and choose what items to equip/use.

Items can have several effects and these can be expanded with 3rd party mods using the hook system. Some of the effects shiped with GL include:

  • Modify Attack Power
  • Modify Defence Power
  • Modify User Health
  • Heal HP
  • Modify timer
  • Give an item
  • Add money
  • Add EXP
  • Add Bullets

Premium Membership
Out of the box Gangster Legends will ship with a new Premium Membership feature. Users will be able to buy Premium Membership with points, If the user is a Premium Member they will have access to additional features. By default Gangster Legends ships with the following benefits:

  1. Reduce crime timers by 25%
  2. Increase theft success chance by 10%
  3. 75% off of travel costs

As with most of GL 3rd party mods can hook into this system to expand on this functionality further.

Standardised Money Output

By default Gangster Legends output any monetary value in dollars ($x,xxx,xxx) in this version any monetary value is passed through a function, this means if you want to change it from $ to £ or € you just define a new hook with the format.

This will only work with modules shipped with the GL Core, but 3rd party modules will need to be updated to follow this. It is very easy to update code from the old way to the new way.

//module.inc.php
/* old */ $this->error("You need $" . number_format($cost));
/* new */ $this->error("You need " . $this->money($cost));


// module.tpl.php
/* old */ Cost: ${number_format cost}
/* new */ Cost: {#money cost}

 

 

Links

Edited by Dayo
  • Like 4
  • Thanks 2
Link to comment
Share on other sites

  • Dayo pinned and featured this topic

I like. It's about time nested loops in GL template is added. Things get complicated at times trying to work around that. And this are much simpler with it.

Looking forward to seeing item system as well.

Edited by Sim
Link to comment
Share on other sites

Ive not updated the demo site to 2.4.0 yet and the 2.3.0 demo was moved to https://demo.glscript.net

48 minutes ago, Sim said:

It's about time nested loops in GL template is added.

You can do alot more too like:

{#if something}
	do something
{else}
	dont do something
{/if}

{>userName}
{>userName player1}
{>userName player2}

{#each array}
  {@index}: {../parent}
{/each}

 

Edited by Dayo
  • Like 2
Link to comment
Share on other sites

I love this announcement and not long in between since the last one.

Love memberships this is a handy feature that opens up a few doors for players to help keep them committed. 

Standard money is great. 

Love the news of the new item system. Just need to get this part of attack system (turn based) and GL takes the cake big time (update for 2.5 perhaps? With BS 4+?)

Looking forward to full release and any further updates in particular to bug fixes with premium mods. ++1 from me. 

  • Like 1
Link to comment
Share on other sites

very nice work did just try a fresh install to test my modules with it but keep getting

File: pageElement.php
Line: 64
Error: Uncaught Error: Class "Handlebars\Handlebars" not found in pageElement.php:64

havent tried fixing it yet but tried reinstalling a couple times and same thing

  • Like 2
Link to comment
Share on other sites

1 hour ago, Dayo said:

yeah its a capitalization issue, it will be fixed in the full release

i did think so i was just looking at remaking the autoload feature of the main core to allow for classes and namespaces as might be worth looking at giving GL namespaces also then will stop this from happening in the future 

  • Like 1
Link to comment
Share on other sites

18 hours ago, Dayo said:

yeah its a capitalization issue, it will be fixed in the full release

give this a go 

in pageElement.php replace

require __DIR__ . '/handlebars/Autoloader.php';
Handlebars\Autoloader::register();

use Handlebars\Handlebars;
use Handlebars\Loader\FilesystemLoader;

with 

require __DIR__ . '/handlebars/Autoloader.php';
use Handlebars\Handlebars;
use Handlebars\Loader\FilesystemLoader

replace all code in Autoloader.php with

<?php
spl_autoload_register(
    function ($class) {
        $prefix = 'Handlebars\\';
        $base_dir = __DIR__;
        $len = strlen($prefix);
        if (strncmp($prefix, $class, $len) !== 0) {
            return;
        }
		
        $relative_class = substr($class, $len);

        $file = $base_dir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php';
		
        if (file_exists($file)) {
            require $file;
        }
    }
);

note this method hasnt been fully tested but it does not display errors anymore.

Edited by URBANZ
  • Like 1
Link to comment
Share on other sites

1 hour ago, Sim said:

DIRECTORY_SEPARATOR is a long const.

Can name be changed to DIR_SEPARATOR or DIR_SEP

Note: According to the documentation, only DIRECTORY_SEPARATOR is a valid constant. The others you listed would require defining first.
 

define('DIR_SEPARATOR', DIRECTORY_SEPARATOR);
define('DIR_SEP', DIRECTORY_SEPARATOR);

Personal opinion: Seems a little lazy to define a constant for an already-existing constant

1 hour ago, Sim said:

Any coder should know DIR stands for directory. If not, they...

.. should read the documentation 😉

  • Like 1
  • Haha 2
Link to comment
Share on other sites

1 hour ago, Sim said:

DIRECTORY_SEPARATOR is a long const.

Can name be changed to DIR_SEPARATOR or DIR_SEP

Any coder should know DIR stands for directory. If not, they...

You should also read official documentation 

The main use of DIRECTORY_SEPARATOR is as the code could be running on different OS which some use forward and other use back slash some no slashes at all and in my experience this way always returns the correct path delimiter.

exactly same reason PHP_EOL exists, platform support.

 

Back on topic anyway 

@Dayo might it be worth overriding the default $enableDataVariables in Handlebars to be true as this feature would definitely be helpful for alot of users 

@first, @last, @index etc they would save alot of time if you just wanted to find first or last in the loop.

 

Edited by URBANZ
  • Like 2
Link to comment
Share on other sites

Thought I would test out 2.4.0 so did a fresh install but for some reason I am getting a syntax error:

There was an error!
File: /home/galactic/public_html/class/nbbc.php
Line: 801
Error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
Type: E_RECOVERABLE_ERROR

 

Link to comment
Share on other sites

9 hours ago, AinzOoalGown said:

Thought I would test out 2.4.0 so did a fresh install but for some reason I am getting a syntax error:

There was an error! File: /home/galactic/public_html/class/nbbc.php Line: 801 Error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) Type: E_RECOVERABLE_ERROR


There was an error!
File: /home/galactic/public_html/class/nbbc.php
Line: 801
Error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
Type: E_RECOVERABLE_ERROR

 

What PHP version are you using? I think @Dayo mentioned there is a problem with that and PHP 8

Link to comment
Share on other sites

17 hours ago, KyleMassacre said:

What PHP version are you using? I think @Dayo mentioned there is a problem with that and PHP 8

yes there was an error with the original bbcodes class with PHP8 but is now using a newer version which has PHP8 support was pulled from a request i made.

@AinzOoalGown i have tested the class myself and is used in active games, try changing your PHP version to 8 or replace the file with a fresh copy.

 

also sometimes this error might popup if you are trying to parse invalid tags within the class so could be cause by a different file.

Edited by URBANZ
Link to comment
Share on other sites

1 hour ago, URBANZ said:

yes there was an error with the original bbcodes class with PHP8 but is now using a newer version which has PHP8 support was pulled from a request i made.

@AinzOoalGown i have tested the class myself and is used in active games, try changing your PHP version to 8 or replace the file with a fresh copy.

 

also sometimes this error might popup if you are trying to parse invalid tags within the class so could be cause by a different file.

I will have to go and check the backwards compatibility with php 7 as that is more mainstream atm, not everyone is able to upgrade php so easily

  • Like 1
Link to comment
Share on other sites

Just now, athena26 said:

Hey I'm thinking of buying this engine if that's okay and I might need help on it ☺️ just for me to start understanding how it works .

Im always about to offer help, you can easily get hold of me on the GL discord server

Link to comment
Share on other sites

33 minutes ago, Dayo said:

I will have to go and check the backwards compatibility with php 7 as that is more mainstream atm, not everyone is able to upgrade php so easily

Awesome 🙂

30 minutes ago, athena26 said:

Hey I'm thinking of buying this engine if that's okay and I might need help on it ☺️ just for me to start understanding how it works .

This is a cool community with very helpful people. Engine is worth every penny as well.

1 hour ago, URBANZ said:

yes there was an error with the original bbcodes class with PHP8 but is now using a newer version which has PHP8 support was pulled from a request i made.

@AinzOoalGown i have tested the class myself and is used in active games, try changing your PHP version to 8 or replace the file with a fresh copy.

 

also sometimes this error might popup if you are trying to parse invalid tags within the class so could be cause by a different file.

Thanks URBANZ but didn't work. Tried to replace file with a fresh copy and upgrade PHP to version 8. After upgrading PHP I get a new error:

There was an error!
File: /home/galactic/public_html/class/pageElement.php
Line: 64
Error: Uncaught Error: Class "Handlebars\Handlebars" not found in /home/galactic/public_html/class/pageElement.php:64 Stack trace: #0 /home/galactic/public_html/class/pageElement.php(141): pageElement->templateToHTML('\n ...', Array) #1 /home/galactic/public_html/class/page.php(343): pageElement->parse() #2 /home/galactic/public_html/modules/installed/login/login.inc.php(21): page->buildElement('loginForm') #3 /home/galactic/public_html/class/module.php(30): login->constructModule() #4 /home/galactic/public_html/class/page.php(144): module->__construct() #5 /home/galactic/public_html/class/page.php(58): page->load('login') #6 /home/galactic/public_html/init.php(93): page->loadPage('login') #7 /home/galactic/public_html/index.php(5): require('/home/galactic/...') #8 {main} thrown
Type: E_RECOVERABLE_ERROR

 

EDIT: Seen your fix above for  "Handlebars\Handlebars" and after doing that looks like everything is working 😄 thanks. Will do more testing and report any bugs.

Edited by AinzOoalGown
Link to comment
Share on other sites

  • Dayo locked, unpinned, unfeatured and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...