Moin liebe Community,
da ich das die letzten Tage mal gefragt wurde, teile ich euch hiermit eine Anleitung für das Trennen von Bankkonten.
Getestet auf der AltisLife 5.0 aber Altis Life Version != SQF "Version".
Sachen die auf der Altis Life 5.0 funktionieren, gehen auch auf jeder anderen Version.
Hierbei ist dann aber ggf. mehr zu bearbeiten.
Zudem verbiete ich das TUT ohne mein Einverständnis zu verbreiten.
Viel Spaß
Schritt 1:
Im ersten Schritt fügen wir in die Datenbank in die Player Tabelle 3 neue Spalten ein.
Hierfür gehen wir in ein SQL Programm unserer Wahl, gehen in die Players Tabelle und führen dort folgenden Code aus.
ALTER TABLE players ADD `civbank` int(100) NOT NULL DEFAULT '0';
ALTER TABLE players ADD `copbank` int(100) NOT NULL DEFAULT '0';
ALTER TABLE players ADD `medbank` int(100) NOT NULL DEFAULT '0';
Damit erstellen wir 3 neue Spalten in der DB, in denen wir den Bank Geldbetrag speichern.
Zur weitern Erklärung zum Thema Datenbanken, ExtDB verweise ich gerne hier rauf -->[TUTORIAL] DER UMGANG MIT EXTDB3 & MYSQL<--
Schritt 2:
Im 2ten Schritt kümmern wir uns um die Implementierung Ingame.
Dafür entpacken und öffnen wir den Life_Server.
Dort gehen wir zu Functions\MySQL\fn_queryRequest.sqf und öffnen diese.
Dort ändern wir
_query = switch (_side) do {
// West - 11 entries returned
case west: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];};
// Civilian - 12 entries returned
case civilian: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime, Jail_Time, Coins FROM players WHERE pid='%1'",_uid];};
// Independent - 10 entries returned
case independent: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];};
};
zu
_query = switch (_side) do {
// West - 11 entries returned
case west: {format ["SELECT pid, name, cash, copbank, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];};
// Civilian - 12 entries returned
case civilian: {format ["SELECT pid, name, cash, civbank, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];};
// Independent - 10 entries returned
case independent: {format ["SELECT pid, name, cash, medbank, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];};
};
Was haben wir getan? Nun wir haben ganz einfach Pro Seite die Abfrage von bankacc auf die jeweilige Spalte verwiesen.
Sprich im Case West: copbank im Case Civilian: civbank und im Case Independent: medbank eingesetzt.
Schritt 3:
Im 3ten Schritt verändern wir die Functions\MYSQL\fn_updatePartial.sqf.
In dieser ändern wir den Case 1 zu:
case 1: {
switch (_side) do {
case west:{
_value = [_this,2,0,[0]] call BIS_fnc_param;
_value = [_value] call DB_fnc_numberSafe;
_query = format ["UPDATE players SET copbank='%1' WHERE pid='%2'",_value,_uid];
};
case civilian: {
_value = [_this,2,0,[0]] call BIS_fnc_param;
_value = [_value] call DB_fnc_numberSafe;
_query = format ["UPDATE players SET civbank='%1' WHERE pid='%2'",_value,_uid];
};
case independent: {
_value = [_this,2,0,[0]] call BIS_fnc_param;
_value = [_value] call DB_fnc_numberSafe;
_query = format ["UPDATE players SET medbank='%1' WHERE pid='%2'",_value,_uid];
};
};
};
Alles anzeigen
Schritt 4:
Im 4ten Schritt ändern wir die Functions\MYSQL\fn_UpdateRequest.sqf.
Dort ändern wir bankacc zur jeweiligen Spalte.
switch (_side) do {
case west: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];};
case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call DB_fnc_bool,_stats,[_alive] call DB_fnc_bool,_position,_playtime_update,_uid];};
case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];};
};
wird zu
switch (_side) do {
case west: {_query = format ["UPDATE players SET name='%1', cash='%2', copbank='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];};
case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', civbank='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call DB_fnc_bool,_stats,[_alive] call DB_fnc_bool,_position,_playtime_update,_uid];};
case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', medbank='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];};
};
Schritt 5:
Gleich geschafft.
Jetzt ändern wir noch die Functions\MYSQL\fn_InsertRequest.sqf zu:
#include "\life_server\script_macros.hpp"
/*
File: fn_insertRequest.sqf
Author: Bryan "Tonic" Boardwine
Description:
Adds a player to the database upon first joining of the server.
Recieves information from core\sesison\fn_insertPlayerInfo.sqf
*/
private ["_queryResult","_query","_alias"];
params [
"_uid",
"_name",
["_money",-1,[0]],
["_bank",-1,[0]],
["_returnToSender",objNull,[objNull]]
];
//Error checks
if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction'
if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to!
_query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid];
_tickTime = diag_tickTime;
_queryResult = [_query,2] call DB_fnc_asyncCall;
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log "------------- Insert Query Request -------------";
diag_log format ["QUERY: %1",_query];
diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
diag_log format ["Result: %1",_queryResult];
diag_log "------------------------------------------------";
};
//Double check to make sure the client isn't in the database...
if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //There was an entry!
if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];};
//Clense and prepare some information.
_name = [_name] call DB_fnc_mresString; //Clense the name of bad chars.
_alias = [[_name]] call DB_fnc_mresArray;
_money = [_money] call DB_fnc_numberSafe;
_bank = [_bank] call DB_fnc_numberSafe;
//Prepare the query statement..
_query = format ["INSERT INTO players (pid, name, cash, copbank, civbank, medbank, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5', '%6', '%7','""[]""','""[]""','""[]""','""[]""','""[]""','""[]""')",
_uid,
_name,
_money,
_bank,
_bank,
_bank,
_alias
];
[_query,1] call DB_fnc_asyncCall;
[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];
Alles anzeigen
Schritt 6:
Schritt 5:
Als letztes packen wir noch den Life_Server zurück in eine PBO.
Das wars auch schon
Wie bereits gesagt alles sehr Simpel.
Sollten dennoch Probleme auftreten, bin ich gerne bereit Support zu leisten.
Edit: Danke an Deathman der mir meine Schusseligkeit aufgezeigt hat.
Hier noch ein kleiner Zusatz von Deathman für getrenntes Cash ~NICHT VON MIR GETESTET~ Support übernimmt Deathman
Alles anzeigenWie immer BACKUP MACHEN VOLL LIFE_SERVER UND MISSION!!
So ich bin dann Fertig mit dem Cash für jede Seite kann ja Joe noch Hinzufügen
Es ist alles so wie mit dem Bank sehr Simpel wie ganz oben schon gesagt
Dan fangen wir mal an näDa gehen wir erstmal in die fn_queryRequest.sqf
und sucht folgendes
fn_queryRequest.sqf
CSS_query = switch (_side) do { // West - 11 entries returned case west: {format ["SELECT pid, name, cash, copbank, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];}; // Civilian - 12 entries returned case civilian: {format ["SELECT pid, name, cash, civbank, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];}; // Independent - 10 entries returned case independent: {format ["SELECT pid, name, cash, medbank, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];}; };
mit dem hier
fn_queryRequest.sqf
CSS_query = switch (_side) do { // West - 11 entries returned case west: {format ["SELECT pid, name, copcash, copbank, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];}; // Civilian - 12 entries returned case civilian: {format ["SELECT pid, name, civcash, civbank, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];}; // Independent - 10 entries returned case independent: {format ["SELECT pid, name, medcash, medbank, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];}; };
Dan gehen wir in die fn_updateRequest.sqf
dort ersetzt das hier
fn_updateRequest.sqf
CSSswitch (_side) do { case west: {_query = format ["UPDATE players SET name='%1', cash='%2', copbank='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];}; case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', civbank='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call DB_fnc_bool,_stats,[_alive] call DB_fnc_bool,_position,_playtime_update,_uid];}; case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', medbank='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];}; };
mit dem hier
fn_updateRequest.sqf
CSSswitch (_side) do { case west: {_query = format ["UPDATE players SET name='%1', copcash='%2', copbank='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];}; case civilian: {_query = format ["UPDATE players SET name='%1', civcash='%2', civbank='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call DB_fnc_bool,_stats,[_alive] call DB_fnc_bool,_position,_playtime_update,_uid];}; case independent: {_query = format ["UPDATE players SET name='%1', medcash='%2', medbank='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];}; };
Dann geht es in die fn_insertRequest.sqf und ersetzt alles mit dem hier
fn_insertRequest.sqf
CSS Alles anzeigen#include "\life_server\script_macros.hpp" /* File: fn_insertRequest.sqf Author: Bryan "Tonic" Boardwine Description: Adds a player to the database upon first joining of the server. Recieves information from core\sesison\fn_insertPlayerInfo.sqf */ private ["_queryResult","_query","_alias"]; params [ "_uid", "_name", ["_money",-1,[0]], ["_bank",-1,[0]], ["_returnToSender",objNull,[objNull]] ]; //Error checks if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction' if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to! _query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid]; _tickTime = diag_tickTime; _queryResult = [_query,2] call DB_fnc_asyncCall; if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then { diag_log "------------- Insert Query Request -------------"; diag_log format ["QUERY: %1",_query]; diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; diag_log format ["Result: %1",_queryResult]; diag_log "------------------------------------------------"; }; //Double check to make sure the client isn't in the database... if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //There was an entry! if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //Clense and prepare some information. _name = [_name] call DB_fnc_mresString; //Clense the name of bad chars. _alias = [[_name]] call DB_fnc_mresArray; _money = [_money] call DB_fnc_numberSafe; _bank = [_bank] call DB_fnc_numberSafe; //Prepare the query statement.. _query = format ["INSERT INTO players (pid, name, copcash, civcash, medcash, copbank, civbank, medbank, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5', '%6', '%7','""[]""','""[]""','""[]""','""[]""','""[]""','""[]""')", _uid, _name, _money, _bank, _bank, _bank, _alias ]; [_query,1] call DB_fnc_asyncCall; [] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];
Zu guter letzt gehen wir in die fn_updatePartial.sqf
und ersetzt das hier
fn_updatePartial.sqf
mit dem hier
fn_updatePartial.sqf
CSS Alles anzeigencase 0: { switch (_side) do { case west: { _value = [_this,2,0,[0]] call BIS_fnc_param; _value = [_value] call DB_fnc_numberSafe; _query = format ["UPDATE players SET copcash='%1' WHERE pid='%2'",_value,_uid]; }; case civilian: { _value = [_this,2,0,[0]] call BIS_fnc_param; _value = [_value] call DB_fnc_numberSafe; _query = format ["UPDATE players SET civcash='%1' WHERE pid='%2'",_value,_uid]; }; case independent: { _value = [_this,2,0,[0]] call BIS_fnc_param; _value = [_value] call DB_fnc_numberSafe; _query = format ["UPDATE players SET medcash='%1' WHERE pid='%2'",_value,_uid]; }; }; };
Und als alertezer schritt geht ihr wieder in die datenbank und auf erue Tabelle Player und fügt dort das hier ein
Spoiler anzeigen
So Bite Joe kein ding musst dich net noch so anstrengen heheh
trozdem Super gemacht
Mit freundlichen Grüßen
Joe Barbaro