Author Topic: Looking for advice on integrating WB MP with webpage, data tables  (Read 1142 times)

0 Members and 2 Guests are viewing this topic.

CTCCoco

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #30 on: February 01, 2012, 08:27:48 PM »
Thanks! I suspect that php.ini is in the php5 lib folder, but I'll need the admin to give me access to it, as I currently cannot see its contents.

Assuming mysql_connect () isn't defined, is that likely due to an installation issue? Or could there be some other problem.

I much appreciate this.
I success to get your undefined error bugging the php.ini with an invalid "On" inside it. But I'm nearly sure which that's not your problem.

So, I think your problem is mysql isn't installed or it's not configured on the machine. Check it.
Pawn, LUA, PHP, MySQL programmer ( Squirrel coming soon ) ( SA-MP, MTA, IV-MP ). Learning Python (Warband module system) at the moment.


Bad Idea

  • Sergeant
  • *
    • View Profile
  • Faction: Sarranid
  • MP nick: Bad Idea
  • M&BWBWF&S
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #31 on: February 02, 2012, 05:58:20 PM »
Will keep track of this :mrgreen:


nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #32 on: February 05, 2012, 06:15:59 PM »
Okay -- I have just managed, using Vornne's scripts, to use WB to successfully write data via a .php file into a text file on the server Barny provided and taught me how to use. It's almost like when you see your first-ever Hello World. I'm thrilled.

No reason in theory I can't use PHP's file functions to store data, right? Not as efficient as MySQL, but doable?

« Last Edit: February 05, 2012, 07:03:52 PM by nijis »
silawa.wordpress.com, www.arabist.net.

CTCCoco

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #33 on: February 05, 2012, 07:17:10 PM »
Okay -- I have just managed, using Vornne's scripts, to use WB to successfully write data via a .php file into a text file on the server Barny provided and taught me how to use. It's almost like when you see your first-ever Hello World. I'm thrilled.

No reason in theory I can't use PHP's file functions to store data, right? Not as efficient as MySQL, but doable?

Yes, you can use PHP file functions, but if you wanna manage a big project, in my opinion it will be too slow. MySQL is much better.

You can really use what do you want to store data, if you can do it in PHP or other web-programming language.
Pawn, LUA, PHP, MySQL programmer ( Squirrel coming soon ) ( SA-MP, MTA, IV-MP ). Learning Python (Warband module system) at the moment.


nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #34 on: February 06, 2012, 06:40:03 AM »
Okay -- I'll still try to make MySQL functional, then.

I hadn't thought about the time issues. If I could ask, what's a reasonable number of integers to be sent to and from a server in a single function, as opposed to a MySQL file? And, can I save lots of time if I only send integers back and forth, and avoid strings?

And another question, if I could ask:
In the PHP tutorials, there are instructions on how to append to a file, and how to overwrite it. I cannot find a way to read a line in the middle, or edit that line.

For example, if I had the following province data table:

Gallia Pop 3000000 Fort 5
Burgundia Pop 2000000 Fort 4
Hispania Pop 2500000 Fort 4

Could I read to Burgundia's population, add the population growth, and then overwrite the number? Or would I need to convert the entire file to a string, edit it, and rewrite the file?



« Last Edit: February 06, 2012, 07:02:51 AM by nijis »
silawa.wordpress.com, www.arabist.net.

Swyter

  • Sergeant Knight at Arms
  • *
  • »Star Wars Conquest Dev Team Leader
    • View Profile
    • [Mount&Blade Command Database]
  • Faction: Swadian
  • MP nick: Sareth | Swyter
  • M&BWBWF&S
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #35 on: February 06, 2012, 11:16:21 AM »
Take a look to SQLite for simple data saving, it's extremely easy to use, serverless, included in most part of the PHP installations and the resulting file is saved on the same place than the code.


Just use the PDO wrapper for calling it. It also works for any other compatible database so the code can be easily adapted in case of need.
http://henryranch.net/software/ease-into-sqlite-3-with-php-and-pdo/


For parsing text files, loop over the lines and explode/implode them to convert them back/to an array that you can easily edit, make an OOP class for abstracting it. It's worth it.

Let me know if you've some more questions about PHP, JS or CSS. I'm very keen on it.

CTCCoco

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #36 on: February 06, 2012, 01:13:17 PM »
It's much more difficult to read an specific line of a file than use MySQL or SQLlite.

SQL Lite is better and faster than use normal files, but it's still worse and slower than MySQL.

BTW, is a good choice.
Pawn, LUA, PHP, MySQL programmer ( Squirrel coming soon ) ( SA-MP, MTA, IV-MP ). Learning Python (Warband module system) at the moment.


nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #37 on: February 07, 2012, 02:20:18 PM »
SQLite looks great, but unfortunately it's also not installed, and I won't be able to install anything on the server for a while yet. Thanks for the advice, though!

I've managed to implement some scripts where I can download a .txt file into an array, alter one value in an array, then upload the entire array back up into the file. It's inefficient as all get-out, I'm sure, but as long as I do it infrequently, I think it will work.
silawa.wordpress.com, www.arabist.net.

Jerkuh

  • Squire
  • *
    • View Profile
  • Faction: Nord
  • MP nick: OLL_Jerkuh
  • WBNW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #38 on: February 07, 2012, 09:55:13 PM »
Meaby this link will help you.

http://stackoverflow.com/questions/804045/preferred-method-to-store-php-arrays-json-encode-vs-serialize

My personal expirience is with the serialize function.
I use it for many things like saving arrays into text files or saving for instance putting some info about permisions in a single collum of a row in Sql.
I think it is the easiest way to save and load information out of files, though i think its not the fasted solution out their.

nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #39 on: February 08, 2012, 09:37:32 AM »
Ah -- that's really good to have.

For the time being, I've figured out a way to use a flat file to 1) store information about provinces, and 2) use a data file stored on a server to determine which map will be played next, and which factions will be involved.

If I have any complications, though, it's excellent to have a back-up way of doing it.

My current system I can make work from the admin panel on my host computer. I have yet to try it with an admin panel on a server, ie, one which is run by config files.

The way it works: as soon as you start the server admin panel, it sends a message to a .php file which echos back four integers. The relevant bit of script in game_receive_url_response is the following:
(assign, ":message_type", reg0), 
   
(try_begin),
  (eq, ":message_type", 1), #type 1 is set map
    (assign, "$g_multiplayer_selected_map", reg1), #this is the second integer I receive
  (store_add, "$g_multiplayer_next_team_1_faction", "fac_empire_0", reg2), #the third integer
  (store_add, "$g_multiplayer_next_team_2_faction", "fac_empire_0", reg3),
 
  (team_set_faction, 0, "$g_multiplayer_next_team_1_faction"),
  (team_set_faction, 1, "$g_multiplayer_next_team_2_faction"),
        (multiplayer_send_2_int_to_server, multiplayer_event_admin_start_map, "$g_multiplayer_selected_map", "$g_multiplayer_game_type"),
 
(try_end), 
The game seems to start automatically from the admin panel, without having to hit the start button, after a second or two. This is what I want to happen.
Does anyone see any pitfalls, if this approach is tried on an automatic server -- ie, where the admin panel is operated by config file, rather than by human? (That is, if I understand the system correctly).
« Last Edit: February 08, 2012, 09:39:55 AM by nijis »
silawa.wordpress.com, www.arabist.net.

nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #40 on: February 10, 2012, 07:17:34 AM »
A pretty basic question, but I can't find it in any of the manuals.

Can I get a client's URL as a string, which will then allow me to determine whether or not the client can upload information to the game -- ie, that a game host which doesn't appear on an "official" list can't log a battle won or lost?

Is this how c-rpg authenticates users from wb.exe's join screen, btw? If not, I presume it's possible to work a password in there for each player account, but that might be a bit cumbersome for the player...
« Last Edit: February 10, 2012, 08:32:58 AM by nijis »
silawa.wordpress.com, www.arabist.net.

Vornne

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Vornne
  • M&BWBNW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #41 on: February 10, 2012, 12:53:39 PM »
Can I get a client's URL as a string, which will then allow me to determine whether or not the client can upload information to the game -- ie, that a game host which doesn't appear on an "official" list can't log a battle won or lost?
Presumably you mean "warband server" either dedicated or running from a client with "Host a Game"? With PHP you can get the IP address of the computer requesting the page (warband server in this case) using:
Code: [Select]
$ip_address = $_SERVER['REMOTE_ADDR'];Which could be checked against a list of valid addresses. Note that this number could change unpredictably for most people with a basic home connection to the internet with a dynamic IP address, as opposed to a more expensive static one normally used for server computers - if you are intending players to host games from their clients rather than connect to dedicated servers. The URLs (strings like forums.taleworlds.com rather than 174.142.90.22) assigned by players' ISPs would probably change dynamically in the same way.

nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #42 on: February 10, 2012, 09:29:28 PM »
Ah, that should do it. And thanks for the warning about IP addresses altering. I'll also be advised on the difference between IP and URL, which I should have known.

Because this is supposed to be a MMORPG -- ie, with a unified, official world -- I don't want people hosting games to be able to make changes to persistant provincial or player stats.

The other purpose to which I'd hoped to put it, to authenticate player log-in automatically with their player name without forcing players to type a password, obviously won't work if the IP varies. Does anyone know how c-rpg.net does it? (I suppose I could just ask there).
silawa.wordpress.com, www.arabist.net.

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #43 on: February 10, 2012, 09:51:49 PM »
Does anyone know how c-rpg.net does it? (I suppose I could just ask there).
If you mean authenticate in-game, we use
Code: [Select]
player_get_unique_id                 = 441 # (player_get_unique_id, <destination>, <player_id>), #can only bew used on server sidewhich basically returns a value tied to the player's cd-key.
Obviously this means that in order to "register", the player will have to join the server at least once (so we can obtain his unique id for the first time and store it).
Warband Script Enhancer v2.7.1 - additional operations, game scripts and triggers for Warband modders

nijis

  • Developer
  • *
    • View Profile
    • Flight of the Silawa
  • Faction: Neutral
  • NW
Re: Looking for advice on integrating WB MP with webpage, data tables
« Reply #44 on: February 11, 2012, 12:00:37 AM »
Excellent! Thank you for that. And congratulations again on pushing the envelope on what could be done with the modding system.
silawa.wordpress.com, www.arabist.net.