Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_va>
- #include <YSI\y_timers>
- #include <formatex>
- #include <foreach>
- #include "../scripts/System/PlayerFunctions.pwn"
- #include <zcmd>
- #include <streamer>
- #include <colours>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 16
- #define MAX_ITEMS (8)
- #define ITM_ATTACH_INDEX (0)
- #define ITM_ATTACH_BONE (6)
- enum E_BOTTLE_DATA
- {
- itm_objId,
- itm_area,
- itm_model,
- Float:itm_posX,
- Float:itm_posY,
- Float:itm_posZ,
- }
- new
- itm_Data [MAX_ITEMS][E_BOTTLE_DATA],
- itm_Models [5] = {1486, 1543, 1544, 1950, 1951},
- Iterator: itm_Index<MAX_ITEMS>;
- new
- itm_Holding [MAX_PLAYERS],
- Timer: itm_InteractTimer [MAX_PLAYERS],
- bool: itm_Interacting [MAX_PLAYERS];
- AddItem(model, Float:x, Float:y, Float:z, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0)
- {
- new id = Iter_Free(itm_Index);
- itm_Data[id][itm_model] = model;
- itm_Data[id][itm_posX] = x;
- itm_Data[id][itm_posY] = y;
- itm_Data[id][itm_posZ] = z;
- itm_Data[id][itm_objId] = CreateDynamicObject(itm_Data[id][itm_model], x, y, z, rx, ry, rz);
- itm_Data[id][itm_area] = CreateDynamicSphere(x, y, z+0.8568, 1.0);
- Iter_Add(itm_Index, id);
- return id;
- }
- RemoveItem(id)
- {
- DestroyDynamicObject(itm_Data[id][itm_objId]);
- DestroyDynamicArea(itm_Data[id][itm_area]);
- itm_Data[id][itm_posX] = 0.0;
- itm_Data[id][itm_posY] = 0.0;
- itm_Data[id][itm_posZ] = 0.0;
- Iter_Remove(itm_Index, id);
- }
- public OnFilterScriptInit()
- {
- AddItem(itm_Models[random(sizeof(itm_Models))], 2108.67, -1875.41, 12.69);
- for(new i;i<MAX_PLAYERS;i++)
- {
- itm_Holding[i] = -1;
- }
- }
- public OnPlayerEnterDynamicArea(playerid, areaid)
- {
- foreach(new i : itm_Index)
- {
- if(areaid == itm_Data[i][itm_area])
- {
- CallRemoteFunction("sffa_msgbox", "dsdd", playerid, "Hold F to pick up", 1000, 130);
- }
- }
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(itm_Interacting[playerid])
- {
- ClearAnimations(playerid);
- stop itm_InteractTimer[playerid];
- }
- if(newkeys & 16 && GetPlayerAnimationIndex(playerid) == 1189)
- {
- if(itm_Holding[playerid] != -1)
- {
- ApplyAnimation(playerid, "BOMBER", "BOM_PLANT_IN", 5.0, 1, 0, 0, 0, 400);
- itm_InteractTimer[playerid] = defer PutDownItem(playerid);
- }
- else
- {
- foreach(new i : itm_Index)
- {
- if(IsPlayerInDynamicArea(playerid, itm_Data[i][itm_area]))
- {
- ApplyAnimation(playerid, "BOMBER", "BOM_PLANT_IN", 5.0, 0, 0, 0, 0, 400);
- itm_InteractTimer[playerid] = defer PickUpItem(playerid, i);
- itm_Interacting[playerid] = true;
- }
- }
- }
- }
- }
- timer PickUpItem[400](playerid, id)
- {
- RemoveItem(id);
- ApplyAnimation(playerid, "BOMBER", "BOM_PLANT_2IDLE", 4.0, 0, 0, 0, 0, 0);
- SetPlayerAttachedObject(
- playerid, ITM_ATTACH_INDEX, itm_Data[id][itm_model], ITM_ATTACH_BONE,
- 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0);
- itm_Holding[playerid] = id;
- itm_Interacting[playerid] = false;
- }
- timer PutDownItem[400](playerid)
- {
- new
- Float:x,
- Float:y,
- Float:z,
- Float:r;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, r);
- AddItem(itm_Data[itm_Holding[playerid]][itm_model],
- x + (0.5 * floatsin(-r, degrees)),
- y + (0.5 * floatcos(-r, degrees)), z-0.8568);
- ApplyAnimation(playerid, "BOMBER", "BOM_PLANT_2IDLE", 4.0, 0, 0, 0, 0, 0);
- RemovePlayerAttachedObject(playerid, ITM_ATTACH_INDEX);
- itm_Holding[playerid] = -1;
- itm_Interacting[playerid] = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement