28.12.2017, 16:30
I made an experimental include, its working, but object pickup rotation is not too smooth
Code:
/* By adri1 */ //cpickup #if defined _inc_cpickup #endinput #endif #define _inc_cpickup //streamer #if !defined _streamer_included #error "no streamer include" #endif //yhooks #include <YSI-Includes\YSI\y_hooks> // #define CUSTOM_PICKUP_UNIQUE_ID 1000 #define INVALID_CUSTOM_PICKUP_ID INVALID_STREAMER_ID forward OnPlayerEnterCustomPickup(playerid, pickupid); forward OnPlayerLeaveCustomPickup(playerid, pickupid); stock CreateDynamicCustomPickup(model, Float:x, Float:y, Float:z, Float:rx = 0.0, Float:ry = 0.0, worldid = -1, interiorid = -1, playerid = -1) { //create new objectid = CreateDynamicObject(model, x, y, z + 1.0, rx, ry, 0.0, worldid, interiorid, playerid), areaid = CreateDynamicCylinder(x, y, z - 1.0, z + 3.0, 0.5, worldid, interiorid, playerid); //move object SetDynamicObjectPos(objectid, x, y, z - 0.001); MoveDynamicObject(objectid, x, y, z, 0.005, rx, ry, 179.0); //object Streamer_SetIntData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, CUSTOM_PICKUP_UNIQUE_ID); //area new streamer_info[2]; streamer_info[0] = CUSTOM_PICKUP_UNIQUE_ID; streamer_info[1] = objectid; Streamer_SetArrayData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID, streamer_info); return areaid; } stock DestroyDynamicCustomPickup(pickupid) { if(pickupid == INVALID_CUSTOM_PICKUP_ID) return 0; new streamer_info[2]; Streamer_GetArrayData(STREAMER_TYPE_AREA, pickupid, E_STREAMER_EXTRA_ID, streamer_info); if(streamer_info[0] != CUSTOM_PICKUP_UNIQUE_ID) return 0; DestroyDynamicObject(streamer_info[1]); DestroyDynamicArea(pickupid); return 1; } hook OnPlayerEnterDynArea(playerid, areaid) { new streamer_info[2]; Streamer_GetArrayData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID, streamer_info); if(streamer_info[0] == CUSTOM_PICKUP_UNIQUE_ID) CallLocalFunction("OnPlayerEnterCustomPickup", "dd", playerid, areaid); return 1; } hook OnPlayerLeaveDynArea(playerid, areaid) { new streamer_info[2]; Streamer_GetArrayData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID, streamer_info); if(streamer_info[0] == CUSTOM_PICKUP_UNIQUE_ID) CallLocalFunction("OnPlayerLeaveCustomPickup", "dd", playerid, areaid); return 1; } hook OnDynamicObjectMoved(objectid) { if(Streamer_GetIntData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID) == CUSTOM_PICKUP_UNIQUE_ID) { new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz; GetDynamicObjectPos(objectid, x, y, z); GetDynamicObjectRot(objectid, rx, ry, rz); if(rz == 179.0) rz = 359.0; else rz = 179.0; SetDynamicObjectPos(objectid, x, y, z - 0.001); MoveDynamicObject(objectid, x, y, z, 0.001, rx, ry, rz); } return 1; }