AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   BlockMaker Framework (https://forums.alliedmods.net/showthread.php?t=112589)

joropito 12-20-2009 00:16

BlockMaker Framework
 
3 Attachment(s)
BlockMaker FrameWork

Description:
First of all, this is not a single plugin.
This plugin is intended to help people build blocks without changing the original code.

* What is this?
It's a multi-plugin framework to allow developers build their own type of blocks for maps.

* Why you made this?
Because I see too many people asking for support to modify some other plugins for blocks and I think it's very annoying to modify.

* What's change with this plugin framework?
You can make your own block without any needs to modify the core plugin.

* I can do anything with my block?
Yes, you can do anything but I suggest try to limit to function calls available in this framework to avoid high cpu usage in your own block.

* Are you sure this is the best way to manage blocks cpu and resources?
No I don't, but I'm sure it's an approach.

* Can I ask you to make some blocks for me?
No. Read the api, it's very simple. Anything else is up to you.
Features:
  • Auto snap on blocks
  • Grab blocks
  • Save/Restore blocks from files
  • Menu arquitechture (plugin extension) (Pending)
  • Extensible... You can create your own blocks!!!
  • Support for non-standard blocks (wtf is it?). You can setup custom 3D sizes for blocks.

Cvars:
Currently there no cvars
Usage:
This plugin have some commands to let you put blocks in maps.

bm_save
Saves all blocks in current map to a file.

bm_load
Load previous saved blocks for the current map.

bm_cleanup
Remove all blocks from the current map.

bm_list
Lists all registered blocks in framework.

bm_add [blockname] [size]
Create a block where you're aiming.
Code:

blockname: the nickname of the block you can see with bm_list
size: d = default size, s = small, l = large

example:
for generic large blocks: bm_add default l
for autobhop standard blocks: bm_add autobhop d

bm_del
Deletes the block you're aiming.

bm_rotate
Rotates the block you're aiming.

+bm_grab
Use this bind to grab the blocks with aim.

API Documentation:
I'll be updating this information to make it clear to understand how to use the api

The framework is responsible to call block handlers (Spawn, Touch, Think, etc).
Currently there only 5 handlers working.
Those handlers where called from the original engine function (pfn_Touch, client_PreThink, etc)
  • This is intended to use to modify properties of blocks (ej: make breakable)
    PHP Code:

    block_Spawn(ent): Called only at block creation 

  • This function may be used to trigger actions when some player touches the block.
    PHP Code:

    block_Touch(touchedtoucher): Called from pfn_Touch with some cache cooldown control

  • You can use this function instead client_PreThink / FM_PlayerPreThink
    PHP Code:

    block_PlayerPreThink(id): Called from client_PreThinkYou have to setup this handler on a player to enable the call

  • You can use this function instead client_PostThink / FM_PlayerPostThink
    PHP Code:

    block_PlayerPostThink(id): Called from client_PostThinkYou have to setup this handler on a player to enable the call

  • This is where your block thinks.
    PHP Code:

    block_Think(ent): Called from the register_think function. This is called every think a block needs to think (EV_FL_nextthink). 

  • Pending.
    PHP Code:

    block_AddToFullPack(): Pending

  • Pending.
    PHP Code:

    block_UpdateClientData(): Pending

For the blocks plugins side, you have 2 natives

This is used to register the new block in the framework.
You can setup the name of the block, the base name for the model, the type of touch, cooldown time for touch and 3 different sizes (default, small, large). This native returns the ID of the registered block.
PHP Code:

native _reg_block(const name[], const ver[], const model[], const touch, const Float:cdown, const Float:size[], const Float:sizesmall[], const Float:sizelarge[]) 

touch takes one of the following options
PHP Code:

#define TOUCH_NONE      1<<0
#define TOUCH_ALL       1<<1
#define TOUCH_BOTH      1<<2
#define TOUCH_HEAD      1<<3
#define TOUCH_FOOT      1<<4
#define TOUCH_OTHER     1<<5 

The other native is _set_handler is used to setup which handlers could be called from framework plugin to block plugin.
PHP Code:

native _set_handler(const id, const blockid, const value, const Handlers:handler

Remember you can use this handlers
PHP Code:

enum Handlers {
      
hSpawn,                  // called automaticaly
      
hTouch,                  // called automaticaly with cooldown control
      
hThink,                  // called only when block/plugin enable this handler
      
hAddToFullPack,          // not yet finished
      
hPlayerPreThink,         // called only when block/plugin enable this handler
      
hPlayerPostThink,        // called only when block/plugin enable this handler
      
hUpdateClientData        // not yet finished


Changelog:
PHP Code:

0.1 initial release 

Credits:
- Necro - Models from BlockMaker 4.01. Some ideas and code from BlockMaker 4.01
- Frk_14 - for tests
- Asd' - for tests & Flash block plugin
Extra info:
  • I'm uploading .zip files because of includes needed.
  • This one is fully usable but maybe someone needs a handler that is not yet finished.
  • The plugins of blocks here are only examples. I'm sure most of them could be optimized.
  • I suggest to read the block/plugin examples to understand how it works.
  • All comments and recomendations are welcome.
  • I'm posting the full source code without any amxx. I suggest you to compile yourself the plugins.
  • You need to maintain models directory and filename format.
  • Remember to put the include file in your includes folder.

Zombiezzz 12-20-2009 00:25

Re: BlockMaker Framework
 
wow ncie! +K

Asd' 12-20-2009 00:30

Re: BlockMaker Framework
 
Good job, and thanks for the credits.

Raddish 12-20-2009 01:37

Re: BlockMaker Framework
 
Nice job.

cikjam 12-20-2009 02:19

Re: BlockMaker Framework
 
Woudln't it be easier with a menu? Instead of always going to console or binding like 10 keys.

EDIT: Suggestion: Change +bm_grab to +bmgrab so people dont have to rebind keys.

#8 SickneSS 12-20-2009 02:35

Re: BlockMaker Framework
 
Nice!!! i will test it later:)!

xPaw 12-20-2009 04:45

Re: BlockMaker Framework
 
Damn :( I was working on the same thing. But as i see your API is not so finished, it doesnt have params, renderings, and such crap :D

KadiR 12-20-2009 04:47

Re: BlockMaker Framework
 
Nice plugin, I also agree with cikjam's post :wink:

Quote:

Originally Posted by cikjam (Post 1023478)
Woudln't it be easier with a menu? Instead of always going to console or binding like 10 keys.

EDIT: Suggestion: Change +bm_grab to +bmgrab so people dont have to rebind keys.


KiimpaN 12-20-2009 07:03

Re: BlockMaker Framework
 
Great idea, this plugin rocks! But as the other guys above me, I agree that a menu might be a good idea ;)

grimvh2 12-20-2009 07:11

Re: BlockMaker Framework
 
Quote:

Originally Posted by xPaw (Post 1023548)
Damn :( I was working on the same thing. But as i see your API is not so finished, it doesnt have params, renderings, and such crap :D

A little competition cant harm right?


All times are GMT -4. The time now is 05:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.