02.10.2010, 02:24
Smooth object rotation
RotateObject(objectid, axis, Float:extent, Float:rspeed)
Top:RotateObject(objectid, axis, Float:extent, Float:rspeed)
Код:
#define rotx 1 #define roty 2 #define rotz 3 forward RotateObject(objectid, axis, Float:extent, Float:rspeed);
Код:
public RotateObject(objectid, axis, Float:extent, Float:rspeed) { if (rspeed <= 0.0) return 1; if ((extent > 0.0) && (extent < rspeed/10)) rspeed = extent*10; if ((extent < 0.0) && (extent > -rspeed/10)) rspeed = -extent*10; if (extent == 0.0) return 1; new Float:rx, Float:ry, Float:rz; GetObjectRot(objectid, rx, ry, rz); switch (axis) { case rotx: SetObjectRot(objectid, rx + ((extent > 0.0) ? (rspeed/10) : (-rspeed/10)), ry, rz); case roty: SetObjectRot(objectid, rx, ry + ((extent > 0.0) ? (rspeed/10) : (-rspeed/10)), rz); case rotz: SetObjectRot(objectid, rx, ry, rz + ((extent > 0.0) ? (rspeed/10) : (-rspeed/10))); } SetTimerEx("RotateObject", 10, 0, "ddff", objectid, axis, ((extent > 0.0) ? (extent - rspeed/10) : (extent + rspeed/10)), rspeed); return 1; }
How to use this?:
Example:Top:
Код:
new policebar;
Код:
policebar = CreateObject(...);
Код:
if (!strcmp(cmdtext, "/openbar", true)) { RotateObject(policebar, rotx, 90.0, 0.5); // Just an example, not sure this values will work for the object u putted, you need to find out the correct values depending on where you placed the object. return 1; }
Possibilities of usage:
- It's possible to use negative values for the degrees if you want to rotate the object clockwise (positive values will rotate the object anticlockwise).Example:
Код:
if (!strcmp(cmdtext, "/rot", true)) { RotateObject(objectid, rotz, -90.0, 1.0); return 1; }
Example:
Код:
if (!strcmp(cmdtext, "/rot", true)) { RotateObject(objectid, rotz, -90.0, 1.0); RotateObject(objectid, rotx, 270.0, 5.0); RotateObject(objectid, roty, -180.0, 3.5); return 1; }
Example:
Код:
if (!strcmp(cmdtext, "/rot", true)) { RotateObject(objectid, rotz, 1440.0, 5.0); // Object will spin 4 times and then stop (1440/360 = 4) return 1; }
Known bugs:
- No one so far.-----------------
Hope you apprecciate