Jump to content

World.CreatePed keeps Crashing :/


stef538

Recommended Posts

Hey guys,

Everytime when i try to spawn a ped, it keeps crashing and it's driving me nuts.
This is my code

 

I tried this : RCPed = World.CreatePed("f_m_business_01", Player.Character.Position, RelationshipGroup.Player);

 

and

 

This : RCPed = World.CreatePed("f_m_business_01", Player.Character.Position);

 

and they both give an error.

Now the weird part is that it sometimes works perfectly fine, and the other time it gives me an error. it doesn't say which one, and the scripthook doesn't write anything to the scripthookdotnet.log file. i'm kinda lost so, do you guys might know how to solve this ?

Link to comment
Share on other sites

well, the first weird thing i notice is the position where the ped will be created, its the same position of the player char., this is not a good idea because if was another nonMission object game would delete it, this may be the reason of crash or error, i suggest use .around(3) or +direction:

RCPed = World.CreatePed("f_m_business_01", Player.Character.Position.Around(3), RelationshipGroup.Player);

 

or:

 

RCPed = World.CreatePed("f_m_business_01", Player.Character.Position + Player.Character.Direction * 2, RelationshipGroup.Player);

also, im not sure about the RelationshipGroup use, i never used here ^^


also the first param is a Model, not sure how works in C# but in vb.net we can do like you did using string instead of Model variable/object

Link to comment
Share on other sites

I did that because i'm making an Radio Control mode, and i spawn a ped which needs to be at the exact position as the player, The player will be warped in a car, and then you can drive the car and it looks like it's in radio control mode. but anyway thanks for responding (:

Link to comment
Share on other sites

in this case you need to temporary store player position into a variable, then warp player, then create ped using that stored position :)

take cara to dont create too much peds and, if possible, set them as NoLongerNeeded to avoid frozend objects/peds bug :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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.