Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #include "\life_server\script_macros.hpp"
  2. /*
  3. File: fn_insertRequest.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Adds a player to the database upon first joining of the server.
  8. Recieves information from core\sesison\fn_insertPlayerInfo.sqf
  9. */
  10. private["_queryResult","_query","_alias"];
  11. params [
  12. "_uid",
  13. "_name",
  14. ["_money",-1,[0]],
  15. ["_bank",-1,[0]],
  16. ["_returnToSender",objNull,[objNull]]
  17. ];
  18.  
  19. //Error checks
  20. if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction'
  21. if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to!
  22.  
  23. _query = format["INSERT INTO players (playerid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, aaf_licenses, aaf_gear, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"')"];
  24.  
  25.  
  26.  
  27. _tickTime = diag_tickTime;
  28. _queryResult = [_query,2] call DB_fnc_asyncCall;
  29.  
  30. if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
  31. diag_log "------------- Insert Query Request -------------";
  32. diag_log format["QUERY: %1",_query];
  33. diag_log format["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
  34. diag_log format["Result: %1",_queryResult];
  35. diag_log "------------------------------------------------";
  36. };
  37.  
  38. //Double check to make sure the client isn't in the database...
  39. if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //There was an entry!
  40. if (count _queryResult != 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];};
  41.  
  42. //Clense and prepare some information.
  43. _name = [_name] call DB_fnc_mresString; //Clense the name of bad chars.
  44. _alias = [[_name]] call DB_fnc_mresArray;
  45. _money = [_money] call DB_fnc_numberSafe;
  46. _bank = [_bank] call DB_fnc_numberSafe;
  47.  
  48. //Prepare the query statement..
  49. _query = format["INSERT INTO players (playerid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"','"[]"')",
  50. _uid,
  51. _name,
  52. _money,
  53. _bank,
  54. _alias
  55. ];
  56.  
  57. [_query,1] call DB_fnc_asyncCall;
  58. [] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement