· 6 years ago · Jul 22, 2019, 08:34 PM
1<?php
2
3$current_mob = 0;
4
5$conn = new mysqli("localhost", "", "", "diku" );
6
7
8foreach( $areas->Resets as $reset ) :
9 if( $reset->Command == "M" ) {
10 $current_mob = $reset->arg1;
11 $reset_insert = "INSERT INTO mob_resets (mob_id, room_id, number_to_respawn) VALUES ('$mob_id', '$room_id', '$number_to_spawn');"
12 }
13
14 if( $reset->Command == "G" || $reset->Command == "E" )
15 $reset_insert = "INSERT INTO mob_equipment (mob_id, object_id, spawn_chance, wear_location) VALUES ('$mob_id', '$object_id', '$chance_to_spawn', '$wear_location')"
16
17 if( $reset->Command == "D" ) {
18 $closed = ($door_status >= 0) ? TRUE : FALSE;
19 $locked = ($door_status == 2) ? TRUE : FALSE;
20 $directions = [ "north", "east", "south", "west", "up", "down" ];
21 $direction = $directions[$direction];
22
23 $reset_insert = "INSERT INTO door_reset (room_id, direction, closed, locked) VALUES ('$room_id', '$direction', '$closed', '$locked')"
24 }
25
26
27 if( $reset->Command == "O" )
28 $reset_insert = "INSERT INTO items_in_room (room_id, object_id) VALUES ('$room_id', '$object_id')"
29
30 if( $reset->Command == "P" )
31 $reset_insert = "INSERT INTO items_in_container(object_id, container_id) VALUES ('$object_id', '$container_id')"
32
33 // Run the actual query
34 mysqli_query( $conn, $reset_insert );
35
36endforeach;
37
38/**
39CREATE TABLE IF NOT EXISTS `door_reset` (
40`id` bigint(20) NOT NULL AUTO_INCREMENT,
41 `room_id` bigint(20) NOT NULL,
42 `direction` varchar(5) NOT NULL,
43 `closed` varchar(5) NOT NULL,
44 `locked` varchar(5) NOT NULL,
45 PRIMARY KEY (`id`),
46 KEY `room.id` (`room_id`)
47) ENGINE=InnoDB DEFAULT CHARSET=latin1;
48
49CREATE TABLE IF NOT EXISTS `items_in_container` (
50`id` bigint(20) NOT NULL AUTO_INCREMENT,
51 `object_id` bigint(20) NOT NULL,
52 `container_id` bigint(20) NOT NULL,
53 PRIMARY KEY (`id`),
54 KEY `object.id` (`object_id`),
55 KEY `container.id` (`container_id`)
56) ENGINE=InnoDB DEFAULT CHARSET=latin1;
57
58CREATE TABLE IF NOT EXISTS `items_in_room` (
59`id` bigint(20) NOT NULL AUTO_INCREMENT,
60 `room_id` bigint(20) NOT NULL,
61 `object_id` bigint(20) NOT NULL,
62 PRIMARY KEY (`id`),
63 KEY `room.id` (`room_id`),
64 KEY `object.id` (`object_id`)
65) ENGINE=InnoDB DEFAULT CHARSET=latin1;
66
67
68CREATE TABLE IF NOT EXISTS `mob_equipment` (
69`id` int(11) NOT NULL AUTO_INCREMENT,
70 `mob_id` bigint(20) NOT NULL,
71 `object_id` bigint(20) NOT NULL,
72 `spawn_chance` varchar(5) NOT NULL,
73 `wear_location` varchar(64) NOT NULL,
74 PRIMARY KEY (`id`),
75 KEY `mob.id` (`mob_id`),
76 KEY `object.id` (`object_id`)
77) ENGINE=InnoDB DEFAULT CHARSET=latin1;
78
79
80CREATE TABLE IF NOT EXISTS `mob_resets` (
81`id` bigint(20) NOT NULL AUTO_INCREMENT,
82 `mob_id` bigint(20) NOT NULL,
83 `room_id` bigint(20) NOT NULL,
84 `number_to_spawn` bigint(20) NOT NULL,
85 PRIMARY KEY (`id`),
86 KEY `mob.id` (`mob_id`),
87 KEY `room.id` (`room_id`)
88) ENGINE=InnoDB DEFAULT CHARSET=latin1;
89COMMIT;
90*/