[SOLVED] C# error with Blip

Hello everyone,

i’m a bit confused , i wanted to add blipsprite on the minimap for the shop i made,
but at my own surprise , this getting me error and i don’t understand why, here is code i used :

Blip b = World.CreateBlip(g.wSeller);
//b.Name = "Ammunition";
b.Sprite = BlipSprite.AmmuNation;

and i get this error :

[     41372] InvokeNative: execution failed: Error executing native 0x5a039bb0bca604b6 at address 0x140a0097a.
[     41372] Failed to instantiate instance of script ClassLibrary2.SHOP.GunStore: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Value does not fall within the expected range.

[     41372]   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <a4e3abdd630b4c98a9d6f31a99197de6>:0 

[     41372]   at (wrapper cominterop) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)

[     41372]   at <0x00000 + 0x00000> <unknown method>

so i tried with the old way with native function :

 int blip = Function.Call<int>((Hash)0x5A039BB0BCA604B6, g.wSeller.X, g.wSeller.Y, g.wSeller.Z);
Function.Call(Hash.SET_BLIP_SPRITE, blip, 110);
Function.Call(Hash.SET_BLIP_DISPLAY, blip, 2);

and i still got the exact same error so i’m really confused on this , because even with the simple native that everyone use i got this error , what could cause this ?

no one wanna help me with that probleme ? are you really willing to let me on this horrible world wihout any blip ?

I got it to work with this. Instead of it returning an int, I set blip. I also changed the hash there. Maybe it could also be an issue with your g.wSeller object not setting coordinates properly?

Blip blip = Function.Call<Blip>(Hash.ADD_BLIP_FOR_COORD, 0.0, 0.0, 0.0);
Function.Call(Hash.SET_BLIP_SPRITE, blip, 110);
Function.Call(Hash.SET_BLIP_DISPLAY, blip, 2);
1 Like

my object is clean , i use it for make spawn my seller in my shop , so i’m gonna try your way right now ^^

I also got this to work, too

Vector3 blipCoords = new Vector3(0.0f, 0.0f, 0.0f);
Blip myBlip = World.CreateBlip(blipCoords);
myBlip.Sprite = BlipSprite.AmmuNation;
2 Likes

ok i figure it out why is wasn’t working , cause you told me it work for you , i look for another problem .

i was init my sprites too early (the map was loading in the meantime ), so the function was unknow .
i init my sprite after the map loaded and everything fine ^^ , thanks for your help buddy

1 Like