-
Notifications
You must be signed in to change notification settings - Fork 1
/
mmosavecharacter.php
131 lines (72 loc) · 3.03 KB
/
mmosavecharacter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
include_once "mmoconnection.php";
$mydata = json_decode(file_get_contents('php://input'));
//error_log("hello", 0);
$charid = $mydata ->charid;
$health = $mydata ->health;
$energy = $mydata ->energy;
$level = $mydata ->level;
$experience = $mydata ->experience;
$dialogues = $mydata ->dialogues;
$quests = $mydata ->quests;
$quest_nodes = $mydata ->quest_nodes;
$current_port = $mydata ->current_port;
$posx = $mydata ->posx;
$posy = $mydata ->posy;
$posz = $mydata ->posz;
$in_instance = $mydata ->in_instance;
$has_entered = $mydata ->has_entered;
$yaw = $mydata ->yaw;
$stmt = $conn->prepare("UPDATE characters SET health = ?, energy = ?, experience = ?, level = ?, current_port = ?, posx = ?, posy = ?, posz = ?, yaw = ?, in_instance = ?, has_entered = ? WHERE id = ? ");
$stmt->bind_param("iiiiiiiiiiii", $health, $energy, $experience, $level, $current_port, $posx, $posy, $posz, $yaw, $in_instance, $has_entered, $charid); // "s" means the database expects a string
$stmt->execute();
$stmt->close();
if ($in_instance == 1) {
$previous_port = $mydata ->previous_port;
$pp_posx = $mydata ->pp_posx;
$pp_posy = $mydata ->pp_posy;
$pp_posz = $mydata ->pp_posz;
$pp_yaw = $mydata ->pp_yaw;
$stmt = $conn->prepare("UPDATE characters SET health = ?, energy = ?, experience = ?, level = ?, previous_port = ?, pp_posx = ?, pp_posy = ?, pp_posz = ?, pp_yaw = ?, in_instance = ?, has_entered = ? WHERE id = ? ");
$stmt->bind_param("iiiiiiiiiiii", $health, $energy, $experience, $level, $previous_port, $pp_posx, $pp_posy, $pp_posz, $pp_yaw, $in_instance, $has_entered, $charid); // "s" means the database expects a string
$stmt->execute();
$stmt->close();
}
$stmt = $conn->prepare("DELETE FROM dialogues WHERE character_id = ? ");
$stmt->bind_param("i", $charid);
$stmt->execute();
$stmt->close();
$stmt = $conn->prepare("DELETE FROM quests WHERE character_id = ? ");
$stmt->bind_param("i", $charid);
$stmt->execute();
$stmt->close();
$stmt = $conn->prepare("DELETE FROM quest_nodes WHERE character_id = ? ");
$stmt->bind_param("i", $charid);
$stmt->execute();
$stmt->close();
foreach ($dialogues as &$entry) {
$fragment_name = $entry->fragment_name;
$fragment_state = $entry->fragment_state;
$stmt = $conn->prepare("INSERT INTO dialogues VALUES (NULL, ?, ?, ? )");
$stmt->bind_param("isi", $charid, $fragment_name, $fragment_state);
$stmt->execute();
$stmt->close();
}
foreach ($quests as &$entry) {
$quest_name = $entry->quest_name;
$quest_state = $entry->quest_state;
$stmt = $conn->prepare("INSERT INTO quests VALUES (NULL, ?, ?, ? )");
$stmt->bind_param("isi", $charid, $quest_name, $quest_state);
$stmt->execute();
$stmt->close();
}
foreach ($quest_nodes as &$entry) {
$quest_node_name = $entry->quest_node_name;
$quest_node_state = $entry->quest_node_state;
$stmt = $conn->prepare("INSERT INTO quest_nodes VALUES (NULL, ?, ?, ? )");
$stmt->bind_param("isi", $charid, $quest_node_name, $quest_node_state);
$stmt->execute();
$stmt->close();
}
echo json_encode(array('status'=>'OK' ));
?>