G2A Many GEOs
SHARE
TWEET

duplicate

seventyone Feb 19th, 2020 (edited) 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define     FILTERSCRIPT
  2. #include    <a_samp>
  3. #include    <sqlitei>
  4. #include    <mSelection>
  5. #include    <streamer>
  6. #include    <zcmd>
  7.  
  8.  
  9. #define     MAX_COP_OBJECTS     (300)
  10. #define     COPOBJECTS_DIALOG   (6450)
  11. #define     SPEEDCAM_RANGE      (30.0)
  12.  
  13. enum rInfo
  14. {
  15.     rCreated,
  16.     Float:rX,
  17.     Float:rY,
  18.     Float:rZ,
  19.     rObject,
  20. };
  21. new RoadBlockInfo[MAX_COP_OBJECTS][rInfo];
  22.  
  23. enum    _:e_object_types
  24. {
  25.     OBJECT_TYPE_ROADBLOCK,
  26.     OBJECT_TYPE_SIGN,
  27.     OBJECT_TYPE_POLICELINE,
  28.     OBJECT_TYPE_SPIKE,
  29.     OBJECT_TYPE_SPEEDCAM,
  30.     OBJECT_TYPE_CONE
  31. }
  32.  
  33. enum    e_object_data
  34. {
  35.     Owner[MAX_PLAYER_NAME],
  36.     Type,
  37.     ObjData,
  38.     ObjModel,
  39.     Float: ObjX,
  40.     Float: ObjY,
  41.     Float: ObjZ,
  42.     Float: ObjRX,
  43.     Float: ObjRY,
  44.     Float: ObjRZ,
  45.     ObjInterior,
  46.     ObjVirtualWorld,
  47.     ObjID,
  48.     Text3D: ObjLabel,
  49.     ObjArea,
  50.     bool: ObjCreated
  51. }
  52.  
  53.  
  54. new
  55.     CopObjectData[MAX_COP_OBJECTS][e_object_data],
  56.     EditingCopObjectID[MAX_PLAYERS] = {-1, ...},
  57.     RoadblockList = mS_INVALID_LISTID,
  58.     SignList = mS_INVALID_LISTID;
  59.  
  60. new
  61.     Float: zOffsets[5] = {1.35, 3.25, 0.35, 0.4, 5.35},
  62.     Float: streamDistances[5] = {10.0, 10.0, 5.0, 3.0, SPEEDCAM_RANGE};
  63.  
  64. new
  65.     DB: ObjectDB,
  66.     DBStatement: LoadObjects,
  67.     DBStatement: AddObject,
  68.     DBStatement: UpdateObject,
  69.     DBStatement: RemoveObject;
  70. stock DeleteAllRBS()
  71. {
  72.     for(new i = 0; i < sizeof(RoadBlockInfo); i++)
  73.     {
  74.         if(RoadBlockInfo[i][rCreated] == 1)
  75.         {
  76.             RoadBlockInfo[i][rCreated]=0;
  77.             RoadBlockInfo[i][rX]=0.0;
  78.             RoadBlockInfo[i][rY]=0.0;
  79.             RoadBlockInfo[i][rZ]=0.0;
  80.             DestroyObject(RoadBlockInfo[i][rObject]);
  81.         }
  82.     }
  83.     return 0;
  84. }
  85.  
  86.  
  87. stock CreateRB(Float:x,Float:y,Float:z,Float:Angle)
  88. {
  89.     for(new i = 0; i < sizeof(RoadBlockInfo); i++)
  90.     {
  91.         if(RoadBlockInfo[i][rCreated] == 0)
  92.         {
  93.             RoadBlockInfo[i][rCreated]=1;
  94.             RoadBlockInfo[i][rX]=x;
  95.             RoadBlockInfo[i][rY]=y;
  96.             RoadBlockInfo[i][rZ]=z-0.7;
  97.             RoadBlockInfo[i][rObject] = CreateObject(973, x, y, z-0.9, 0, 0, Angle-90);
  98.             return 1;
  99.         }
  100.     }
  101.     return 0;
  102. }
  103.  
  104.  
  105. /*stock IsACopSkin(skinid)
  106. {
  107.     // cop skins, verified
  108.     switch(skinid)
  109.     {
  110.         case 265..267, 280..288, 300..302, 306, 307, 309..311: return 1;
  111.         default: return 0;
  112.     }
  113.  
  114.     return 0;
  115. }*/
  116.  
  117. stock GetFreeObjectID()
  118. {
  119.     new id = -1;
  120.     for(new i; i < MAX_COP_OBJECTS; i++)
  121.     {
  122.         if(!CopObjectData[i][ObjCreated])
  123.         {
  124.             id = i;
  125.             break;
  126.         }
  127.     }
  128.  
  129.     return id;
  130. }
  131.  
  132. stock GetPlayerSpeed(playerid)
  133. {
  134.     new Float:vx, Float:vy, Float:vz, Float:vel;
  135.     vel = GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
  136.     vel = (floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))* 181.5);
  137.     return floatround(vel);
  138. }
  139.  
  140. stock InsertObjectToDB(id)
  141. {
  142.     stmt_bind_value(AddObject, 0, DB::TYPE_INTEGER, id);
  143.     stmt_bind_value(AddObject, 1, DB::TYPE_STRING, CopObjectData[id][Owner]);
  144.     stmt_bind_value(AddObject, 2, DB::TYPE_INTEGER, CopObjectData[id][Type]);
  145.     stmt_bind_value(AddObject, 3, DB::TYPE_INTEGER, CopObjectData[id][ObjData]);
  146.     stmt_bind_value(AddObject, 4, DB::TYPE_INTEGER, CopObjectData[id][ObjModel]);
  147.     stmt_bind_value(AddObject, 5, DB::TYPE_FLOAT, CopObjectData[id][ObjX]);
  148.     stmt_bind_value(AddObject, 6, DB::TYPE_FLOAT, CopObjectData[id][ObjY]);
  149.     stmt_bind_value(AddObject, 7, DB::TYPE_FLOAT, CopObjectData[id][ObjZ]);
  150.     stmt_bind_value(AddObject, 8, DB::TYPE_FLOAT, CopObjectData[id][ObjRX]);
  151.     stmt_bind_value(AddObject, 9, DB::TYPE_FLOAT, CopObjectData[id][ObjRY]);
  152.     stmt_bind_value(AddObject, 10, DB::TYPE_FLOAT, CopObjectData[id][ObjRZ]);
  153.     stmt_bind_value(AddObject, 11, DB::TYPE_INTEGER, CopObjectData[id][ObjInterior]);
  154.     stmt_bind_value(AddObject, 12, DB::TYPE_INTEGER, CopObjectData[id][ObjVirtualWorld]);
  155.     stmt_execute(AddObject);
  156.     return 1;
  157. }
  158.  
  159. stock SaveObjectToDB(id)
  160. {
  161.     stmt_bind_value(UpdateObject, 0, DB::TYPE_FLOAT, CopObjectData[id][ObjX]);
  162.     stmt_bind_value(UpdateObject, 1, DB::TYPE_FLOAT, CopObjectData[id][ObjY]);
  163.     stmt_bind_value(UpdateObject, 2, DB::TYPE_FLOAT, CopObjectData[id][ObjZ]);
  164.     stmt_bind_value(UpdateObject, 3, DB::TYPE_FLOAT, CopObjectData[id][ObjRX]);
  165.     stmt_bind_value(UpdateObject, 4, DB::TYPE_FLOAT, CopObjectData[id][ObjRY]);
  166.     stmt_bind_value(UpdateObject, 5, DB::TYPE_FLOAT, CopObjectData[id][ObjRZ]);
  167.     stmt_bind_value(UpdateObject, 6, DB::TYPE_INTEGER, id);
  168.     stmt_execute(UpdateObject);
  169.     return 1;
  170. }
  171. stock DeleteClosestRB(playerid)
  172. {
  173.     for(new i = 0; i < sizeof(RoadBlockInfo); i++)
  174.     {
  175.         if(IsPlayerInRangeOfPoint(playerid, 2.0, RoadBlockInfo[i][rX], RoadBlockInfo[i][rY], RoadBlockInfo[i][rZ]))
  176.         {
  177.             if(RoadBlockInfo[i][rCreated] == 1)
  178.             {
  179.                 RoadBlockInfo[i][rCreated]=0;
  180.                 RoadBlockInfo[i][rX]=0.0;
  181.                 RoadBlockInfo[i][rY]=0.0;
  182.                 RoadBlockInfo[i][rZ]=0.0;
  183.                 DestroyObject(RoadBlockInfo[i][rObject]);
  184.                 return 1;
  185.             }
  186.         }
  187.     }
  188.     return 0;
  189. }
  190.  
  191. encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
  192.  
  193. public OnFilterScriptInit()
  194. {
  195.     RoadblockList = LoadModelSelectionMenu("roadblocks.txt");
  196.     SignList = LoadModelSelectionMenu("signs.txt");
  197.    
  198.     ObjectDB = db_open("cop_objects.db");
  199.     db_query(ObjectDB, "CREATE TABLE IF NOT EXISTS objects (id INTEGER, owner TEXT, type INTEGER, data INTEGER, model INTEGER, posx FLOAT, posy FLOAT, posz FLOAT, rotx FLOAT, roty FLOAT, rotz FLOAT, interior INTEGER, virtualworld INTEGER)");
  200.  
  201.     LoadObjects = db_prepare(ObjectDB, "SELECT * FROM objects");
  202.     AddObject = db_prepare(ObjectDB, "INSERT INTO objects (id, owner, type, data, model, posx, posy, posz, rotx, roty, rotz, interior, virtualworld) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  203.     UpdateObject = db_prepare(ObjectDB, "UPDATE objects SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=? WHERE id=?");
  204.     RemoveObject = db_prepare(ObjectDB, "DELETE FROM objects WHERE id=?");
  205.    
  206.     new id, type, data, model, owner[MAX_PLAYER_NAME], Float: pos[3], Float: rot[3], interior, vworld;
  207.     stmt_bind_result_field(LoadObjects, 0, DB::TYPE_INTEGER, id);
  208.     stmt_bind_result_field(LoadObjects, 1, DB::TYPE_STRING, owner, MAX_PLAYER_NAME);
  209.     stmt_bind_result_field(LoadObjects, 2, DB::TYPE_INTEGER, type);
  210.     stmt_bind_result_field(LoadObjects, 3, DB::TYPE_INTEGER, data);
  211.     stmt_bind_result_field(LoadObjects, 4, DB::TYPE_INTEGER, model);
  212.     stmt_bind_result_field(LoadObjects, 5, DB::TYPE_FLOAT, pos[0]);
  213.     stmt_bind_result_field(LoadObjects, 6, DB::TYPE_FLOAT, pos[1]);
  214.     stmt_bind_result_field(LoadObjects, 7, DB::TYPE_FLOAT, pos[2]);
  215.     stmt_bind_result_field(LoadObjects, 8, DB::TYPE_FLOAT, rot[0]);
  216.     stmt_bind_result_field(LoadObjects, 9, DB::TYPE_FLOAT, rot[1]);
  217.     stmt_bind_result_field(LoadObjects, 10, DB::TYPE_FLOAT, rot[2]);
  218.     stmt_bind_result_field(LoadObjects, 11, DB::TYPE_INTEGER, interior);
  219.     stmt_bind_result_field(LoadObjects, 12, DB::TYPE_INTEGER, vworld);
  220.  
  221.     if(stmt_execute(LoadObjects))
  222.     {
  223.         new label[96];
  224.         while(stmt_fetch_row(LoadObjects))
  225.         {
  226.             CopObjectData[id][ObjCreated] = true;
  227.             CopObjectData[id][Owner] = owner;
  228.             CopObjectData[id][Type] = type;
  229.             CopObjectData[id][ObjData] = data;
  230.             CopObjectData[id][ObjModel] = model;
  231.             CopObjectData[id][ObjInterior] = interior;
  232.             CopObjectData[id][ObjVirtualWorld] = vworld;
  233.             CopObjectData[id][ObjX] = pos[0];
  234.             CopObjectData[id][ObjY] = pos[1];
  235.             CopObjectData[id][ObjZ] = pos[2];
  236.             CopObjectData[id][ObjRX] = rot[0];
  237.             CopObjectData[id][ObjRY] = rot[1];
  238.             CopObjectData[id][ObjRZ] = rot[2];
  239.             CopObjectData[id][ObjID] = CreateDynamicObject(model, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2], vworld, interior);
  240.             CopObjectData[id][ObjArea] = -1;
  241.            
  242.             switch(type)
  243.             {
  244.                 case OBJECT_TYPE_ROADBLOCK: format(label, sizeof(label), "Roadblock (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  245.                 case OBJECT_TYPE_SIGN: format(label, sizeof(label), "Sign (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  246.                 case OBJECT_TYPE_POLICELINE: format(label, sizeof(label), "Police Line (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  247.                 case OBJECT_TYPE_SPIKE:
  248.                 {
  249.                     format(label, sizeof(label), "Spike Strip (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  250.                     CopObjectData[id][ObjArea] = CreateDynamicSphere(pos[0], pos[1], pos[2], 2.5, vworld, interior);
  251.                 }
  252.                
  253.                 case OBJECT_TYPE_SPEEDCAM:
  254.                 {
  255.                     format(label, sizeof(label), "Speed Camera (ID: %d)\n{FFFFFF}Speed Limit: {E74C3C}%d\n{FFFFFF}Placed by %s", id, data, CopObjectData[id][Owner]);
  256.                     CopObjectData[id][ObjArea] = CreateDynamicSphere(pos[0], pos[1], pos[2], SPEEDCAM_RANGE, vworld, interior);
  257.                 }
  258.             }
  259.            
  260.             CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(label, 0x3498DBFF, pos[0], pos[1], pos[2] + zOffsets[type], streamDistances[type], _, _, _, vworld, interior);
  261.         }
  262.     }
  263.     //new label[126];
  264.     //case OBJECT_TYPE_CONE: format(label, sizeof(label), "Cone (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  265.     return 1;
  266. }
  267.  
  268. public OnFilterScriptExit()
  269. {
  270.     db_close(ObjectDB);
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerConnect(playerid)
  275. {
  276.     EditingCopObjectID[playerid] = -1;
  277.     return 1;
  278. }
  279.  
  280. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  281. {
  282.     if(dialogid == COPOBJECTS_DIALOG)
  283.     {
  284.         if(!response) return 1;
  285.         if(listitem == 0) ShowModelSelectionMenu(playerid, RoadblockList, "Roadblocks", 0x393939BB, 0x3498DBBB);
  286.         if(listitem == 1) ShowModelSelectionMenu(playerid, SignList, "Signs", 0x393939BB, 0x3498DBBB);
  287.  
  288.         if(listitem == 2)
  289.         {
  290.             new id = GetFreeObjectID();
  291.             if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
  292.             CopObjectData[id][ObjCreated] = true;
  293.             GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  294.             CopObjectData[id][Type] = OBJECT_TYPE_POLICELINE;
  295.             CopObjectData[id][ObjModel] = 19834;
  296.             CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  297.             CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  298.            
  299.             new Float: x, Float: y, Float: z, Float: a;
  300.             GetPlayerPos(playerid, x, y, z);
  301.             GetPlayerFacingAngle(playerid, a);
  302.             x += (2.0 * floatsin(-a, degrees));
  303.             y += (2.0 * floatcos(-a, degrees));
  304.             CopObjectData[id][ObjX] = x;
  305.             CopObjectData[id][ObjY] = y;
  306.             CopObjectData[id][ObjZ] = z;
  307.             CopObjectData[id][ObjRX] = 0.0;
  308.             CopObjectData[id][ObjRY] = 0.0;
  309.             CopObjectData[id][ObjRZ] = a;
  310.             CopObjectData[id][ObjID] = CreateDynamicObject(19834, x, y, z, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  311.             CopObjectData[id][ObjArea] = -1;
  312.            
  313.             new string[96];
  314.             format(string, sizeof(string), "Police Line (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  315.             CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 0.35, 5.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  316.             InsertObjectToDB(id);
  317.         }
  318.        
  319.         if(listitem == 3)
  320.         {
  321.             new id = GetFreeObjectID();
  322.             if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
  323.             CopObjectData[id][ObjCreated] = true;
  324.             GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  325.             CopObjectData[id][Type] = OBJECT_TYPE_SPIKE;
  326.             CopObjectData[id][ObjModel] = 2899;
  327.             CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  328.             CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  329.  
  330.             new Float: x, Float: y, Float: z, Float: a;
  331.             GetPlayerPos(playerid, x, y, z);
  332.             GetPlayerFacingAngle(playerid, a);
  333.             x += (2.0 * floatsin(-a, degrees));
  334.             y += (2.0 * floatcos(-a, degrees));
  335.            
  336.             CopObjectData[id][ObjX] = x;
  337.             CopObjectData[id][ObjY] = y;
  338.             CopObjectData[id][ObjZ] = z - 0.85;
  339.             CopObjectData[id][ObjRX] = 0.0;
  340.             CopObjectData[id][ObjRY] = 0.0;
  341.             CopObjectData[id][ObjRZ] = a + 90.0;
  342.             CopObjectData[id][ObjID] = CreateDynamicObject(2899, x, y, z - 0.85, 0.0, 0.0, a + 90.0, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  343.             CopObjectData[id][ObjArea] = CreateDynamicSphere(x, y, z - 0.85, 2.5, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  344.            
  345.             new string[96];
  346.             format(string, sizeof(string), "Spike Strip (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  347.             CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z - 0.4, 3.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  348.             InsertObjectToDB(id);
  349.         }
  350.        
  351.         if(listitem == 4) ShowPlayerDialog(playerid, COPOBJECTS_DIALOG+1, DIALOG_STYLE_INPUT, "Speed Camera Setup", "Scrie o limita de viteza pentru aceasta speed camera:", "Create", "Cancel");
  352.         return 1;
  353.     }
  354.    
  355.     if(dialogid == COPOBJECTS_DIALOG+1)
  356.     {
  357.         if(!response) return 1;
  358.         if(!strlen(inputtext)) return ShowPlayerDialog(playerid, COPOBJECTS_DIALOG+1, DIALOG_STYLE_INPUT, "Speed Camera Setup", " Limit:", "Create", "Cancel");
  359.         new id = GetFreeObjectID(), limit = strval(inputtext);
  360.         if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
  361.         CopObjectData[id][ObjCreated] = true;
  362.         GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  363.         CopObjectData[id][Type] = OBJECT_TYPE_SPEEDCAM;
  364.         CopObjectData[id][ObjData] = limit;
  365.         CopObjectData[id][ObjModel] = 18880;
  366.         CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  367.         CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  368.  
  369.         new Float: x, Float: y, Float: z, Float: a;
  370.         GetPlayerPos(playerid, x, y, z);
  371.         GetPlayerFacingAngle(playerid, a);
  372.         x += (2.0 * floatsin(-a, degrees));
  373.         y += (2.0 * floatcos(-a, degrees));
  374.         CopObjectData[id][ObjX] = x;
  375.         CopObjectData[id][ObjY] = y;
  376.         CopObjectData[id][ObjZ] = z - 1.5;
  377.         CopObjectData[id][ObjRX] = 0.0;
  378.         CopObjectData[id][ObjRY] = 0.0;
  379.         CopObjectData[id][ObjRZ] = 0.0;
  380.         CopObjectData[id][ObjID] = CreateDynamicObject(18880, x, y, z - 1.5, 0.0, 0.0, 0.0, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  381.         CopObjectData[id][ObjArea] = CreateDynamicSphere(x, y, z - 1.5, SPEEDCAM_RANGE, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  382.        
  383.         new string[128];
  384.         format(string, sizeof(string), "Speed Camera (ID: %d)\n{FFFFFF}Speed Limit: {E74C3C}%d\n{FFFFFF}Placed by %s", id, limit, CopObjectData[id][Owner]);
  385.         CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 3.85, SPEEDCAM_RANGE, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  386.         InsertObjectToDB(id);
  387.         return 1;
  388.     }
  389.    
  390.     return 0;
  391. }
  392.  
  393. public OnPlayerModelSelection(playerid, response, listid, modelid)
  394. {
  395.     if(listid == RoadblockList)
  396.     {
  397.         if(!response) return 1;
  398.         new id = GetFreeObjectID();
  399.         if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
  400.         CopObjectData[id][ObjCreated] = true;
  401.         GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  402.         CopObjectData[id][Type] = OBJECT_TYPE_ROADBLOCK;
  403.         CopObjectData[id][ObjModel] = modelid;
  404.         CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  405.         CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  406.  
  407.         new Float: x, Float: y, Float: z, Float: a;
  408.         GetPlayerPos(playerid, x, y, z);
  409.         GetPlayerFacingAngle(playerid, a);
  410.         x += (2.0 * floatsin(-a, degrees));
  411.         y += (2.0 * floatcos(-a, degrees));
  412.         CopObjectData[id][ObjX] = x;
  413.         CopObjectData[id][ObjY] = y;
  414.         CopObjectData[id][ObjZ] = z;
  415.         CopObjectData[id][ObjRX] = 0.0;
  416.         CopObjectData[id][ObjRY] = 0.0;
  417.         CopObjectData[id][ObjRZ] = a;
  418.         CopObjectData[id][ObjID] = CreateDynamicObject(modelid, x, y, z, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  419.         CopObjectData[id][ObjArea] = -1;
  420.  
  421.         new string[96];
  422.         format(string, sizeof(string), "Roadblock (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  423.         CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 1.35, 10.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  424.         InsertObjectToDB(id);
  425.     }
  426.    
  427.     if(listid == SignList)
  428.     {
  429.         if(!response) return 1;
  430.         new id = GetFreeObjectID();
  431.         if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
  432.         CopObjectData[id][ObjCreated] = true;
  433.         GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  434.         CopObjectData[id][Type] = OBJECT_TYPE_SIGN;
  435.         CopObjectData[id][ObjModel] = modelid;
  436.         CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  437.         CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  438.  
  439.         new Float: x, Float: y, Float: z, Float: a;
  440.         GetPlayerPos(playerid, x, y, z);
  441.         GetPlayerFacingAngle(playerid, a);
  442.         x += (2.0 * floatsin(-a, degrees));
  443.         y += (2.0 * floatcos(-a, degrees));
  444.         CopObjectData[id][ObjX] = x;
  445.         CopObjectData[id][ObjY] = y;
  446.         CopObjectData[id][ObjZ] = z - 1.25;
  447.         CopObjectData[id][ObjRX] = 0.0;
  448.         CopObjectData[id][ObjRY] = 0.0;
  449.         CopObjectData[id][ObjRZ] = a;
  450.         CopObjectData[id][ObjID] = CreateDynamicObject(modelid, x, y, z - 1.25, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  451.         CopObjectData[id][ObjArea] = -1;
  452.  
  453.         new string[96];
  454.         format(string, sizeof(string), "Sign (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  455.         CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 2.0, 10.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  456.         InsertObjectToDB(id);
  457.     }
  458.     return 1;
  459. }
  460.  
  461. public OnPlayerEnterDynamicArea(playerid, areaid)
  462. {
  463.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  464.     {
  465.         for(new i; i < MAX_COP_OBJECTS; i++)
  466.         {
  467.             if(!CopObjectData[i][ObjCreated]) continue;
  468.             if(areaid == CopObjectData[i][ObjArea])
  469.             {
  470.                 switch(CopObjectData[i][Type])
  471.                 {
  472.                     case OBJECT_TYPE_SPIKE:
  473.                     {
  474.                         new panels, doors, lights, tires;
  475.                         GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  476.                         UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, encode_tires(1, 1, 1, 1));
  477.                         PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
  478.                     }
  479.  
  480.                     case OBJECT_TYPE_SPEEDCAM:
  481.                     {
  482.                         new speed = GetPlayerSpeed(playerid);
  483.                         if(speed > CopObjectData[i][ObjData])
  484.                         {
  485.                             // detected by a speed camera
  486.                             PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
  487.                             SendClientMessage(playerid, -1, "You got busted! Slow down.");
  488.                         }
  489.                     }
  490.                 }
  491.  
  492.                 break;
  493.             }
  494.         }
  495.     }
  496.    
  497.     return 1;
  498. }
  499.  
  500. public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
  501. {
  502.     if(EditingCopObjectID[playerid] != -1)
  503.     {
  504.         new id = EditingCopObjectID[playerid];
  505.  
  506.         switch(response)
  507.         {
  508.             case EDIT_RESPONSE_FINAL:
  509.             {
  510.                 CopObjectData[id][ObjX] = x;
  511.                 CopObjectData[id][ObjY] = y;
  512.                 CopObjectData[id][ObjZ] = z;
  513.                 CopObjectData[id][ObjRX] = rx;
  514.                 CopObjectData[id][ObjRY] = ry;
  515.                 CopObjectData[id][ObjRZ] = rz;
  516.                 SetDynamicObjectPos(objectid, x, y, z);
  517.                 SetDynamicObjectRot(objectid, rx, ry, rz);
  518.                
  519.                 Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, CopObjectData[id][ObjLabel], E_STREAMER_X, x);
  520.                 Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, CopObjectData[id][ObjLabel], E_STREAMER_Y, y);
  521.                 Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, CopObjectData[id][ObjLabel], E_STREAMER_Z, z + zOffsets[ CopObjectData[id][Type] ]);
  522.                
  523.                 if(IsValidDynamicArea(CopObjectData[id][ObjArea]))
  524.                 {
  525.                     Streamer_SetFloatData(STREAMER_TYPE_AREA, CopObjectData[id][ObjArea], E_STREAMER_X, x);
  526.                     Streamer_SetFloatData(STREAMER_TYPE_AREA, CopObjectData[id][ObjArea], E_STREAMER_Y, y);
  527.                     Streamer_SetFloatData(STREAMER_TYPE_AREA, CopObjectData[id][ObjArea], E_STREAMER_Z, z + zOffsets[ CopObjectData[id][Type] ]);
  528.                 }
  529.  
  530.                 SaveObjectToDB(id);
  531.                 EditingCopObjectID[playerid] = -1;
  532.             }
  533.            
  534.             case EDIT_RESPONSE_CANCEL:
  535.             {
  536.                 SetDynamicObjectPos(objectid, CopObjectData[id][ObjX], CopObjectData[id][ObjY], CopObjectData[id][ObjZ]);
  537.                 SetDynamicObjectRot(objectid, CopObjectData[id][ObjRX], CopObjectData[id][ObjRY], CopObjectData[id][ObjRZ]);
  538.                 EditingCopObjectID[playerid] = -1;
  539.             }
  540.         }
  541.     }
  542.    
  543.     return 1;
  544. }
  545.  
  546. CMD:rb(playerid, params[])
  547. {
  548.     if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Nu poti utiliza aceasta comanda daca esti in masina.");
  549.     ShowPlayerDialog(playerid, COPOBJECTS_DIALOG, DIALOG_STYLE_LIST, "Roadblocks: Category", "Roadblocks\nSigns\nPolice Line", "Choose", "Cancel");
  550.     return 1;
  551. }
  552.  
  553. CMD:rbedit(playerid, params[])
  554. {
  555.     //if(!IsPlayerAdmin(playerid) && !IsACopSkin(GetPlayerSkin(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only cops.");
  556.     //if(EditingCopObjectID[playerid] != -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You edit a object.");
  557.     if(isnull(params)) return SendClientMessage(playerid, 0xF39C12FF, "USAGE: {FFFFFF}/editobject [id]");
  558.     new id = strval(params[0]);
  559.     if(!(0 <= id <= MAX_COP_OBJECTS - 1)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid object ID.");
  560.     if(!CopObjectData[id][ObjCreated]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Object doesn't exist.");
  561.     if(!IsPlayerInRangeOfPoint(playerid, 16.0, CopObjectData[id][ObjX], CopObjectData[id][ObjY], CopObjectData[id][ObjZ])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Not near.");
  562.     new name[MAX_PLAYER_NAME];
  563.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  564.     if(!IsPlayerAdmin(playerid) && strcmp(CopObjectData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You not placed that object.");
  565.     EditingCopObjectID[playerid] = id;
  566.     EditDynamicObject(playerid, CopObjectData[id][ObjID]);
  567.     return 1;
  568. }
  569.  
  570. CMD:gotoobject(playerid, params[])
  571. {
  572.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Only RCON admins can use this command.");
  573.     if(isnull(params)) return SendClientMessage(playerid, 0xF39C12FF, "USAGE: {FFFFFF}/gotoobject [id]");
  574.     new id = strval(params[0]);
  575.     if(!(0 <= id <= MAX_COP_OBJECTS - 1)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid object ID.");
  576.     if(!CopObjectData[id][ObjCreated]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Object doesn't exist.");
  577.     SetPlayerPos(playerid, CopObjectData[id][ObjX], CopObjectData[id][ObjY], CopObjectData[id][ObjZ] + 1.75);
  578.     SetPlayerInterior(playerid, CopObjectData[id][ObjInterior]);
  579.     SetPlayerVirtualWorld(playerid, CopObjectData[id][ObjVirtualWorld]);
  580.     SendClientMessage(playerid, -1, "Teleported to object.");
  581.     return 1;
  582. }
  583.  
  584. /*CMD:rrb(playerid, params[])
  585. {
  586.     if(isnull(params)) return SendClientMessage(playerid, 0xF39C12FF, "USAGE: {FFFFFF}/editobject [id]");
  587.     new id = strval(params[0]);
  588.     if(!(0 <= id <= MAX_COP_OBJECTS - 1)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid object ID.");
  589.     if(!CopObjectData[id][ObjCreated]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Object doesn't exist.");
  590.     if(EditingCopObjectID[playerid] == id) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't remove an object you're editing.");
  591.     new name[MAX_PLAYER_NAME];
  592.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  593.     CopObjectData[id][ObjCreated] = false;
  594.     DestroyDynamicObject(CopObjectData[id][ObjID]);
  595.     DestroyDynamic3DTextLabel(CopObjectData[id][ObjLabel]);
  596.     if(IsValidDynamicArea(CopObjectData[id][ObjArea])) DestroyDynamicArea(CopObjectData[id][ObjArea]);
  597.     CopObjectData[id][ObjID] = -1;
  598.     CopObjectData[id][ObjLabel] = Text3D: -1;
  599.     CopObjectData[id][ObjArea] = -1;
  600.     stmt_bind_value(RemoveObject, 0, DB::TYPE_INTEGER, id);
  601.     stmt_execute(RemoveObject);
  602.    
  603.     SendClientMessage(playerid, -1, "Object removed.");
  604.     return 1;
  605. }*/
  606. CMD:cone(playerid, params[])
  607. {
  608.         new id = GetFreeObjectID();
  609.         if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited");
  610.         CopObjectData[id][ObjCreated] = true;          
  611.         GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  612.         CopObjectData[id][Type] = OBJECT_TYPE_CONE;
  613.         CopObjectData[id][ObjModel] = 19834;
  614.         CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  615.         CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  616.  
  617.         //new id = GetFreeObjectID();
  618.         new Float: x, Float: y, Float: z, Float: a;
  619.         GetPlayerPos(playerid, x, y, z);
  620.         GetPlayerFacingAngle(playerid, a);
  621.         x += (2.0 * floatsin(-a, degrees));
  622.         y += (2.0 * floatcos(-a, degrees));
  623.         CopObjectData[id][ObjX] = x;
  624.         CopObjectData[id][ObjY] = y;
  625.         CopObjectData[id][ObjZ] = z - 1.25;
  626.         CopObjectData[id][ObjRX] = 0.0;
  627.         CopObjectData[id][ObjRY] = 0.0;
  628.         CopObjectData[id][ObjRZ] = a;
  629.         CopObjectData[id][ObjID] = CreateDynamicObject(1238, x, y, z - 1.25, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  630.         CopObjectData[id][ObjArea] = -1;
  631.  
  632.         new string[96];
  633.         SendClientMessage(playerid, -1, "Ai plasat un 'CONE', tasteaza /rbedit [id] pentru a ii modifica pozitia.");
  634.         format(string, sizeof(string), "Cone (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  635.         CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 2.0, 10.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  636.         InsertObjectToDB(id);
  637.         return 1;
  638. }
  639.         /*if(listitem == 2)
  640.         {
  641.             new id = GetFreeObjectID();
  642.             if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Ai atins limita de obiecte.");
  643.             CopObjectData[id][ObjCreated] = true;
  644.             GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);
  645.             CopObjectData[id][Type] = OBJECT_TYPE_POLICELINE;
  646.             CopObjectData[id][ObjModel] = 19834;
  647.             CopObjectData[id][ObjInterior] = GetPlayerInterior(playerid);
  648.             CopObjectData[id][ObjVirtualWorld] = GetPlayerVirtualWorld(playerid);
  649.            
  650.             new Float: x, Float: y, Float: z, Float: a;
  651.             GetPlayerPos(playerid, x, y, z);
  652.             GetPlayerFacingAngle(playerid, a);
  653.             x += (2.0 * floatsin(-a, degrees));
  654.             y += (2.0 * floatcos(-a, degrees));
  655.             CopObjectData[id][ObjX] = x;
  656.             CopObjectData[id][ObjY] = y;
  657.             CopObjectData[id][ObjZ] = z;
  658.             CopObjectData[id][ObjRX] = 0.0;
  659.             CopObjectData[id][ObjRY] = 0.0;
  660.             CopObjectData[id][ObjRZ] = a;
  661.             CopObjectData[id][ObjID] = CreateDynamicObject(19834, x, y, z, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  662.             CopObjectData[id][ObjArea] = -1;
  663.            
  664.             new string[96];
  665.             format(string, sizeof(string), "Police Line (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
  666.             CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 0.35, 5.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
  667.             InsertObjectToDB(id);
  668.         }*/
  669.  
  670. CMD:rrb(playerid, params[])
  671. {
  672.     if(isnull(params)) return SendClientMessage(playerid, 0xF39C12FF, "USAGE: {FFFFFF}/removeobject(roadblock) [id]");
  673.     new id = strval(params[0]);
  674.     if(!(0 <= id <= MAX_COP_OBJECTS - 1)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid object ID.");
  675.     if(!CopObjectData[id][ObjCreated]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Dont exist.");
  676.     if(EditingCopObjectID[playerid] == id) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}No.");
  677.     new name[MAX_PLAYER_NAME];
  678.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  679.     CopObjectData[id][ObjCreated] = false;
  680.     DestroyDynamicObject(CopObjectData[id][ObjID]);
  681.     DestroyDynamic3DTextLabel(CopObjectData[id][ObjLabel]);
  682.     if(IsValidDynamicArea(CopObjectData[id][ObjArea])) DestroyDynamicArea(CopObjectData[id][ObjArea]);
  683.     CopObjectData[id][ObjID] = -1;
  684.     CopObjectData[id][ObjLabel] = Text3D: -1;
  685.     CopObjectData[id][ObjArea] = -1;
  686.     stmt_bind_value(RemoveObject, 0, DB::TYPE_INTEGER, id);
  687.     stmt_execute(RemoveObject);
  688.     SendClientMessage(playerid, 0xE74C3CFF, "SERVER: {FFFFFF}Deleted succes.");
  689.     return 1;
  690. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top