ClareXoBearrx3R9 Posted June 6, 2015 Share Posted June 6, 2015 I have written the following code to save a vehicle (prevent from de-spawning) and to add a blip to it to the map: if (bPlayerExists){ if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0)){ Vehicle e = PED::GET_VEHICLE_PED_IS_USING(playerPed); NETWORK::SET_NETWORK_ID_CAN_MIGRATE(e, 1); for (i = 0; i < 350; i++){ NETWORK::NETWORK_REQUEST_CONTROL_OF_NETWORK_ID(NETWORK::NETWORK_GET_NETWORK_ID_FROM_ENTITY(e)); NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(e); } ENTITY::SET_ENTITY_AS_MISSION_ENTITY(e, true, true); for (i = 0; i < 350; i++)NETWORK::SET_NETWORK_ID_CAN_MIGRATE(e, 0); VEHICLE::SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(e, 1); Blip b; char bname[] = "Saved Vehicle"; b = UI::ADD_BLIP_FOR_ENTITY(e); UI::SET_BLIP_SPRITE(b, 60); UI::SET_BLIP_NAME_FROM_TEXT_FILE(b, bname); set_status_text("[info]: Vehicle registered."); } else{ set_status_text("[Error]: Player is not in a vehicle."); }} It works OK in the sense that it saves my vehicle but after saving a vehicle or two (or after a period of time), the same blip somehow gets duplicated and attaches to various AI cars driving around. Any ideas on why this could be happening? I'm stumped Link to comment Share on other sites More sharing options...
Fireboyd78 Posted June 7, 2015 Share Posted June 7, 2015 I imagine it has something to do with all that network code you got going on there. Have you tried making a non-networked version to see if the same behavior occurs? Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 7, 2015 Author Share Posted June 7, 2015 That actually makes sense. I'll remove the network stuff and see if that solves the problem. Thanks for the suggestion- not sure why I didn't think about that. Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 7, 2015 Author Share Posted June 7, 2015 (edited) I imagine it has something to do with all that network code you got going on there. Have you tried making a non-networked version to see if the same behavior occurs? Hmm. Sadly, even after taking all the network code out, the same behavior occurs . For me, it starts happening after about 5-10 minutes of gameplay. Edited June 7, 2015 by ClareXoBearrx3 Link to comment Share on other sites More sharing options...
Fireboyd78 Posted June 7, 2015 Share Posted June 7, 2015 Post the code you have so far so we can keep helping you. ClareXoBearrx3R9 1 Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 8, 2015 Author Share Posted June 8, 2015 (edited) Thanks. The code is pretty much the same, just without the network code: if (bPlayerExists){ if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0)){ Vehicle e = PED::GET_VEHICLE_PED_IS_USING(playerPed); ENTITY::SET_ENTITY_AS_MISSION_ENTITY(e, true, true); // Testing VEHICLE::SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(e, 1); Blip b; char bname[] = "Saved Vehicle"; b = UI::ADD_BLIP_FOR_ENTITY(e); UI::SET_BLIP_SPRITE(b, 100); // 60: police shield; 100: carwash; ? = vehicle icon UI::SET_BLIP_NAME_FROM_TEXT_FILE(b, bname); set_status_text("[info]: Vehicle registered."); master_vehicles.push_back(e); } else{ set_status_text("[Error]: Player is not in a vehicle."); } } That's the complete code. For reference, the master_vehicles is a vector that I use to hold all vehicles spawned by the player so they can flush/delete them all later on with the press of a button. Its declaration is: vector<Vehicle> master_vehicles; and is initialized once in the beginning of the program as follows: master_vehicles.resize(0); Not that that is of any relevance but I am truly stumped as to why I'm experiencing this behavior. I've looked around to confirm I'm using the native correctly and others seem to have used the same native with no complaints that I've seen. --------------- On a sidenote, is anyone aware of the blip sprites/values? I found the list from OpenIV and counted from the top from 0 (assuming 0 index-based and left-to-right and top-to-bottom) but no avail. I've found the following values: 100 = car wash icon 60 = police shield Image: Edited June 8, 2015 by ClareXoBearrx3 Link to comment Share on other sites More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 public enum class BlipSprite{ Standard = 1, BigBlip = 2, PoliceOfficer = 3, PoliceArea = 4, Square = 5, Player = 6, North = 7, Waypoint = 8, BigCircle = 9, BigCircleOutline = 10, ArrowUpOutlined = 11, ArrowDownOutlined = 12, ArrowUp = 13, ArrowDown = 14, PoliceHelicopterAnimated = 15, Jet = 16, Number1 = 17, Number2 = 18, Number3 = 19, Number4 = 20, Number5 = 21, Number6 = 22, Number7 = 23, Number8 = 24, Number9 = 25, Number10 = 26, GTAOCrew = 27, GTAOFriendly = 28, Lift = 36, RaceFinish = 38, Safehouse = 40, PoliceOfficer2 = 41, PoliceCarDot = 42, PoliceHelicopter = 43, ChatBubble = 47, Garage2 = 50, Drugs = 51, Store = 52, PoliceCar = 56, PolicePlayer = 58, PoliceStation = 60, Hospital = 61, Helicopter = 64, StrangersAndFreaks = 65, ArmoredTruck = 66, TowTruck = 68, Barber = 71, LosSantosCustoms = 72, Clothes = 73, TattooParlor = 75, Simeon = 76, Lester = 77, Michael = 78, Trevor = 79, Rampage = 84, VinewoodTours = 85, Lamar = 86, Franklin = 88, Chinese = 89, Airport = 90, Bar = 93, BaseJump = 94, CarWash = 100, ComedyClub = 102, Dart = 103, FIB = 106, DollarSign = 108, Golf = 109, AmmuNation = 110, Exile = 112, ShootingRange = 119, Solomon = 120, StripClub = 121, Tennis = 122, Triathlon = 126, OffRoadRaceFinish = 127, Key = 134, MovieTheater = 135, Music = 136, Marijuana = 140, Hunting = 141, ArmsTraffickingGround = 147, Nigel = 149, AssaultRifle = 150, Bat = 151, Grenade = 152, Health = 153, Knife = 154, Molotov = 155, Pistol = 156, RPG = 157, Shotgun = 158, SMG = 159, Sniper = 160, SonicWave = 161, PointOfInterest = 162, GTAOPassive = 163, GTAOUsingMenu = 164, Link = 171, Minigun = 173, GrenadeLauncher = 174, Armor = 175, Castle = 176, Camera = 184, Handcuffs = 188, Yoga = 197, Cab = 198, Number11 = 199, Number12 = 200, Number13 = 201, Number14 = 202, Number15 = 203, Number16 = 204, Shrink = 205, Epsilon = 206, PersonalVehicleCar = 225, PersonalVehicleBike = 226, Custody = 237, ArmsTraffickingAir = 251, Fairground = 266, PropertyManagement = 267, Altruist = 269, Enemy = 270, Chop = 273, Dead = 274, Hooker = 279, Friend = 280, BountyHit = 303, GTAOMission = 304, GTAOSurvival = 305, CrateDrop = 306, PlaneDrop = 307, Sub = 308, Race = 309, Deathmatch = 310, ArmWrestling = 311, AmmuNationShootingRange = 313, RaceAir = 314, RaceCar = 315, RaceSea = 316, GarbageTruck = 318, SafehouseForSale = 350, Package = 351, MartinMadrazo = 352, EnemyHelicopter = 353, Boost = 354, Devin = 355, Marina = 356, Garage = 357, GolfFlag = 358, Hangar = 359, Helipad = 360, JerryCan = 361, Masks = 362, HeistSetup = 363, Incapacitated = 364, PickupSpawn = 365, BoilerSuit = 366, Completed = 367, Rockets = 368, GarageForSale = 369, HelipadForSale = 370, MarinaForSale = 371, HangarForSale = 372, Business = 374, BusinessForSale = 375, RaceBike = 376, Parachute = 377, TeamDeathmatch = 378, RaceFoot = 379, VehicleDeathmatch = 380, Barry = 381, Dom = 382, MaryAnn = 383, Cletus = 384, Josh = 385, Minute = 386, Omega = 387, Tonya = 388, Paparazzo = 389, Crosshair = 390, Creator = 398, CreatorDirection = 399, Abigail = 400, Blimp = 401, Repair = 402, Testosterone = 403, Dinghy = 404, Fanatic = 405, Information = 407, CaptureBriefcase = 408, LastTeamStanding = 409, Boat = 410, CaptureHouse = 411, JerryCan2 = 415, RP = 416, GTAOPlayerSafehouse = 417, GTAOPlayerSafehouseDead = 418, CaptureAmericanFlag = 419, CaptureFlag = 420, Tank = 421, HelicopterAnimated = 422, Plane = 423, PlayerNoColor = 425, GunCar = 426, Speedboat = 427, Heist = 428, Stopwatch = 430, DollarSignCircled = 431, Crosshair2 = 432, DollarSignSquared = 434,}; (Source) As for your code, I'll let you know if I figure anything out. ClareXoBearrx3R9 1 Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 8, 2015 Author Share Posted June 8, 2015 I love you. And thanks! Link to comment Share on other sites More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 (edited) After some thorough testing, I can safely say your code works perfectly fine! Whatever your problem is, it is likely caused by how you're calling the methods. In my testing, I check to see if F10 was pressed. Oh, and the method you're using to set the blip name isn't working, just so you know. local savedVehicles = {}function add_current_vehicle() local playerPed = PLAYER.PLAYER_PED_ID() if PED.IS_PED_IN_ANY_VEHICLE(playerPed, false) then local veh = PED.GET_VEHICLE_PED_IS_USING(playerPed) ENTITY.SET_ENTITY_AS_MISSION_ENTITY(veh, true, true) VEHICLE.SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(veh, true) local blip = UI.ADD_BLIP_FOR_ENTITY(veh) UI.SET_BLIP_SPRITE(blip, 225) -- 'PersonalVehicleCar' sprite UI.SET_BLIP_NAME_FROM_TEXT_FILE(blip, "Saved Vehicle") UI._SET_NOTIFICATION_TEXT_ENTRY("STRING") UI._ADD_TEXT_COMPONENT_STRING("Vehicle registered.") UI._DRAW_NOTIFICATION(false, true) table.insert(savedVehicles, veh) else UI._SET_NOTIFICATION_TEXT_ENTRY("STRING") UI._ADD_TEXT_COMPONENT_STRING("Player is not in a vehicle!") UI._DRAW_NOTIFICATION(false, true) endend I also wrote a method to clear the table out, but it doesn't seem to be working so I left that out. How I'm calling the methods (from inside tick function): if get_key_pressed(Keys.F11) then clear_saved_vehicles() -- not workingelseif get_key_pressed(Keys.F10) then add_current_vehicle()end This is really cool, by the way! Screenshots: http://images.akamai.steamusercontent.com/ugc/31870306920555978/B194FAD3AE33028921365D1F5524DE1405E05248/ http://images.akamai.steamusercontent.com/ugc/31870306920556089/8C1EABE30460521FA56E62B69D4BF1904E61078D/ http://images.akamai.steamusercontent.com/ugc/31870306920556174/366A513603E6202C02FBA075E05E2303813137F1/ Edited June 8, 2015 by Fireboyd78 Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 8, 2015 Author Share Posted June 8, 2015 Hmm, very interesting. I did notice the blip name wasn't working and even tested with taking it out - still to no avail. Thanks for the update and code snippets. That looks like some sort of LUA, is it? My current (complete) code minus the licensing stuff: // [ LCtrl + S ] // Save car. SHORT key_vsave = GetAsyncKeyState(VkKeyScan('s')); if ((GetAsyncKeyState(VK_LCONTROL)) && (key_vsave & 0x8000)){ BOOL bPlayerExists = ENTITY::DOES_ENTITY_EXIST(PLAYER::PLAYER_PED_ID()); Player player = PLAYER::PLAYER_ID(); Ped playerPed = PLAYER::PLAYER_PED_ID(); bool success = false, attempt = false; int i; if (bPlayerExists){ if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0)){ //Entity e; Vehicle e = PED::GET_VEHICLE_PED_IS_USING(playerPed); ENTITY::SET_ENTITY_AS_MISSION_ENTITY(e, true, true); VEHICLE::SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(e, 1); Blip b = UI::ADD_BLIP_FOR_ENTITY(e); UI::SET_BLIP_SPRITE(b, 225); UI::SET_BLIP_COLOUR(b, 3); set_status_text("[info]: Vehicle registered."); master_vehicles.push_back(e); } else{ set_status_text("[Error]: Player is not in a vehicle."); } } } I know there are some unused variables there - I have to clean that up later The only thing I can think of is perhaps the type ENTITY vs VEHICLE. I might try the opposite of what I'm using to see if that helps. Link to comment Share on other sites More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 I really don't understand why this isn't working. My next suggestion would be to get rid of the whole 'bPlayerExists' thing, don't bother checking if the player exists. Secondly, the types (Entity, Vehicle, Blip, etc.) are all int types. They just help organize natives better. Lastly, try using a temporary single-key bind to figure out if it has anything to do with pressing ctrl+s. It's all the things you'd least expect to f*ck everything up, lol. Other than that, I'm totally stumped. Your code works perfectly for me in Lua. Who knows, it might be your licensing code Hopefully you can get this figured out. Good luck! Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 8, 2015 Author Share Posted June 8, 2015 Thanks for your suggestions -- I'll definitely give those a shot And thanks for the clarification on types. It might have something to do with the entity disappearing (eg. after being sold or something) but I'm not sure. I'll report back if I find a solution to this. Thanks! Fireboyd78 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now