Jump to content
  • 0

Writing to the database, I need some help please.


thenutsoframbo

Question

I've tried many things to try and write to the database including extDB. Maybe i'm not doing it right i'm not sure. I have my own custom scripts that i'm trying to save specific aspects of a player to a seperate table to the database. So maybe if someone could help or give me a tutorial that would be great?

 

This is what i'm aiming for as a basic design so I dont give away my script. But If you could take the "PlayerName" and "PlayerUID" and save it to a BRAND NEW table in the database called "Test" that would help me a lot.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

try a query something like this:

 

SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `Test`;

CREATE TABLE `Test` (
  `PlayerUID` varchar(20) NOT NULL DEFAULT '0',
  `PlayerName` varchar(128) NOT NULL DEFAULT 'Null',
  `LastUpdated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`PlayerUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `character_data` ADD Test int(11) NOT NULL DEFAULT 0 AFTER PlayerUID;

 

Im not 100% sure i just edited the single coin mod query:

 

SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `banking_data`;

CREATE TABLE `banking_data` (
  `PlayerUID` varchar(20) NOT NULL DEFAULT '0',
  `PlayerName` varchar(128) NOT NULL DEFAULT 'Null',
  `BankSaldo` bigint(24) NOT NULL DEFAULT '0',
  `LastUpdated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`PlayerUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `character_data` ADD CashMoney int(11) NOT NULL DEFAULT 0 AFTER PlayerUID;

Link to comment
Share on other sites

  • 0

To me this looks like MYSQL, I need a .sqf script that writes to the database. Something along the lines of this.

 

 

This was meant to be worked with extDB but it didnt work... and I cant seem to get extDB to load anyways... so... any ideas?

private ["_player","_playerName"];
 
_player = _this select 0;
_playerName = name _player;
 
_query = format["INSERT INTO test (name) VALUES ('%1')",_playerName];
 
[_query, 1, true] call fn_asyncCall;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...