Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

      1. Events
    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. News

    2. Forum Support

    3. Site Suggestions

ClareXoBearrx3R9

Blip Attaching to Random Vehicles

Recommended Posts

ClareXoBearrx3R9

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 :p

Share this post


Link to post
Share on other sites
Fireboyd78

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?

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

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. :p

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

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 by ClareXoBearrx3

Share this post


Link to post
Share on other sites
Fireboyd78

Post the code you have so far so we can keep helping you.

  • Like 1

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

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:

F6Lcy0t.png

Edited by ClareXoBearrx3

Share this post


Link to post
Share on other sites
Fireboyd78
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.

  • Like 1

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

I love you. :D

 

And thanks!

Share this post


Link to post
Share on other sites
Fireboyd78

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 by Fireboyd78

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

Hmm, very interesting. :D

 

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? :p

 

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 :p

 

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.

Share this post


Link to post
Share on other sites
Fireboyd78

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 :p

 

Hopefully you can get this figured out. Good luck!

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

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! :D

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.