Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnStart()
- {
- SetEntityPlayerInteractCallback("box", "BeginRecording", true);
- }
- void BeginRecording(string &in asEntity)
- {
- SetLocalVarInt("array_index_" + asEntity, 0);
- SetLocalVarInt("reverse_" + asEntity, 1);
- AddDebugMessage("Starting recording of " + asEntity, false);
- TimerRecord(asEntity);
- }
- void TimerRecord(string &in asEntity)
- {
- int index = GetLocalVarInt("array_index_" + asEntity);
- if (index < 600)
- {
- string name = "placeholder_" + asEntity + "_" + index;
- CreateEntityAtArea(name, "placeholder.ent", "PlaceholderArea", false);
- PlaceEntityAtEntity(name, asEntity, "", true);
- AddTimer(asEntity, 0.0f, "TimerRecord");
- AddLocalVarInt("array_index_" + asEntity, 1);
- }
- else
- {
- AddDebugMessage("Finished recording for " + asEntity, false);
- SetPropStaticPhysics(asEntity, true);
- TimerPlayback(asEntity);
- }
- }
- void TimerPlayback(string &in asEntity)
- {
- int index = GetLocalVarInt("array_index_" + asEntity);
- PlaceEntityAtEntity(asEntity, "placeholder_" + asEntity + "_" + index, "", true);
- if (GetLocalVarInt("reverse_" + asEntity) == 1)
- {
- if (index > 0)
- {
- AddLocalVarInt("array_index_" + asEntity, -1);
- }
- else
- {
- SetLocalVarInt("reverse_" + asEntity, 0);
- }
- }
- else
- {
- if (index < 600)
- {
- AddLocalVarInt("array_index_" + asEntity, 1);
- }
- else
- {
- SetLocalVarInt("reverse_" + asEntity, 1);
- }
- }
- AddTimer(asEntity, 0.0f, "TimerPlayback");
- }
- /*
- class Vec3
- {
- float x;
- float y;
- float z;
- }
- Vec3[] boxes(600);
- void TimerRecordBoxPos(string &in asTimer)
- {
- int index = GetLocalVarInt("array_index");
- Vec3 box = boxes[index];
- box.x = GetEntityPosX("box");
- box.y = GetEntityPosY("box");
- box.z = GetEntityPosZ("box");
- boxes[index] = box;
- if (index < boxes.length() - 1)
- {
- AddLocalVarInt("array_index", 1);
- AddTimer("loop", 0.0f, "TimerRecordBoxPos");
- string log = "Box index " + index + ": X = " + box.x + ", Y = " + box.y + ", Z = " + box.z;
- AddDebugMessage(log, false);
- }
- else
- {
- AddTimer("loop", 0.0f, "TimerSetBoxPos");
- SetPropStaticPhysics("box", true);
- }
- }
- void TimerSetBoxPos(string &in asTimer)
- {
- int index = GetLocalVarInt("array_index");
- Vec3 box = boxes[index];
- SetEntityPos("box", box.x, box.y, box.z);
- if (GetLocalVarInt("reverse") == 1)
- {
- if (index > 0)
- {
- AddLocalVarInt("array_index", -1);
- }
- else
- {
- SetLocalVarInt("reverse", 0);
- }
- }
- else
- {
- if (index < boxes.length() - 1)
- {
- AddLocalVarInt("array_index", 1);
- }
- else
- {
- SetLocalVarInt("reverse", 1);
- }
- }
- AddTimer("loop", 0.0f, "TimerSetBoxPos");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement