XML custom menu system.
#1

Hi there. Im pretty new to pawn scripting just started last week to build my rp mod from scratch.
First started with a car import system where you buy the car and then go to the dmv to register it so you can park it somewhere or sell/rent it.
That involved 4 menus for the import system, first select the car type (saloon, sport, industrial/allroad) and then one more for each type of car.
Then started with the DMV and about the same, register, check import taxes...
And then looking at the code i realized that i needed a better way to create menus than just start throwing code @ the main callbacks.

This is my first .inc, a simple system to show 'static' menus loaded from a 'xml' file.

The XML file format.
there are two tags actually
<Menu key="myMenu" title="this is a menu" pos="150,100" columns="200,100" command="myMenuClick_callback" buildMethod="mymenu_builder">
</Menu>
The command attribute is to optionally assign a callback that will handle the menuItem click, look at the demo .xml file for more information.
The buildMethod attribute is used to add items to the menu by yourself. This callback will be called before adding the menuItems in the xml.

And the second tag:
<Menu ...>
<MenuItem col1="Buy shit" col2="here" redirect="buyShitMenu"/> // this one adds a menuitem that redirects to a menu with name 'buyShitMenu'
<MenuItem col1="Handsup bitch!!" col2="<rob>" command="robStore" argument="mystore"/> // And this will call the function robStore passing the argument mystore. Also look at the demo.xml and demo pwn files to check callback headers etc.
</Menu>

Thats all, its pretty simple but i found it useful so posted it.
On next release the columns text will be able to handle parameters like %0 %1 that will be passed as parameters in the ShowMenu() function. But that will be when i need it for my housing system.

Just take a look at test.pwn and you will understand how it works.


Files:
test.pwn => demo gamemod
aralmo_menuSystem.inc => goes into your pawn include folder (you know that offcourse)
menu.xml => goes into your samp server scriptfiles folder. Open it with notepad and check it first.

zip here => http://solidfiles.com/d/6e8
Reply
#2

Wow, very interesting
Reply
#3

WOW!

Nice job man
Reply
#4

can i see a demo page pleases?
Reply
#5

WTF? Demo page of what??
He is just asking if someone can parse commands from a XML file..
And let me say you that this would be a really cool thing.

And original

Cheers,
Web
Reply
#6

There's a sample of it with the download
Reply
#7

nice one. I was wondering if i could make a plyaer stats system with this, of course with your permission to edit this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)