ShadowCoderKing Posted November 21, 2015 Share Posted November 21, 2015 (edited) im making a script that places objects and peds and cars at coords but nothing shows up at all what did i do wrong ? using GTA;using System;using System.Collections.Generic;using System.Threading.Tasks;using GTA.Native;using System.Windows.Forms;using GTA.Math;public class Armybase : Script{ public Armybase() { Tick += OnTick; KeyDown += OnKeyDown; KeyUp += OnKeyUp; Interval = 10; } void OnTick(object sender, EventArgs e) { } void OnKeyDown(object sender, KeyEventArgs e) { } void OnKeyUp(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.F11) { GTA.World.CreateProp(new Model(276224379), new GTA.Math.Vector3(2033.644f, 2830.369f, 49.30626f), new GTA.Math.Vector3(0f, 0f, -16.99992f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(1988.923f, 2852.714f, 49.27079f), new GTA.Math.Vector3(0f, 0f, 25f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2000.575f, 2858.135f, 49.28042f), new GTA.Math.Vector3(0f, 0f, 8.000007f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2013.178f, 2859.965f, 49.23547f), new GTA.Math.Vector3(0f, 0f, 7.999998f), false, false); GTA.World.CreateVehicle(new Model(-82626025) new GTA.Math.Vector3(2058.021f, 2765.874f, 50.80261f), -59.5616f); GTA.World.CreatePed(new Model(307287994), new GTA.Math.Vector3(2031.123f, 2859.301f, 49.64544f), 55.04015f); } }} Edited November 21, 2015 by SpiderMight Link to comment Share on other sites More sharing options...
ISOFX Posted November 21, 2015 Share Posted November 21, 2015 What exactly do you need help with? Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted November 21, 2015 Author Share Posted November 21, 2015 (edited) nothing is showing up in game that i try to spawn in the script Edited November 21, 2015 by SpiderMight Link to comment Share on other sites More sharing options...
ISOFX Posted November 21, 2015 Share Posted November 21, 2015 Well, do you get any errors? if not try spawning the props using a button i.e: using GTA;using System;using System.Collections.Generic;using System.Threading.Tasks;using GTA.Native;using System.Windows.Forms;public class Armybase : Script{ public Armybase() { Tick += OnTick; KeyDown += OnKeyDown; KeyUp += OnKeyUp; Interval = 10; } void OnTick(object sender, EventArgs e) { } void OnKeyDown(object sender, KeyEventArgs e) { } void OnKeyUp(object sender, KeyEventArgs e) { if (e.Keycode == Keys.F12) { GTA.World.CreateProp(new Model(276224379), new GTA.Math.Vector3(2033.644f, 2830.369f, 49.30626f), new GTA.Math.Vector3(0f, 0f, -16.99992f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(1988.923f, 2852.714f, 49.27079f), new GTA.Math.Vector3(0f, 0f, 25f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2000.575f, 2858.135f, 49.28042f), new GTA.Math.Vector3(0f, 0f, 8.000007f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2013.178f, 2859.965f, 49.23547f), new GTA.Math.Vector3(0f, 0f, 7.999998f), false, false); GTA.World.CreateVehicle(new Model(-82626025) new GTA.Math.Vector3(2058.021f, 2765.874f, 50.80261f), -59.5616f); GTA.World.CreatePed(new Model(307287994), new GTA.Math.Vector3(2031.123f, 2859.301f, 49.64544f), 55.04015f); } }} If F12 is pressed it will spawn your objects at the position you set. Tell me what happens when you do this. It should work. Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted November 21, 2015 Author Share Posted November 21, 2015 i tryied it using a button but nothing shows up and no errors just nothing witch is strange it should work Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted November 22, 2015 Author Share Posted November 22, 2015 (edited) is anyone able to help please i dont understand why no props or peds are spawning Edited November 22, 2015 by SpiderMight Link to comment Share on other sites More sharing options...
Colata Posted November 22, 2015 Share Posted November 22, 2015 (edited) im making a script that places objects and peds and cars at coords but nothing shows up at all what did i do wrong ? using GTA;using System;using System.Collections.Generic;using System.Threading.Tasks;using GTA.Native;using System.Windows.Forms;using GTA.Math;public class Armybase : Script{ public Armybase() { Tick += OnTick; KeyDown += OnKeyDown; KeyUp += OnKeyUp; Interval = 10; } void OnTick(object sender, EventArgs e) { } void OnKeyDown(object sender, KeyEventArgs e) { } void OnKeyUp(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.F11) { GTA.World.CreateProp(new Model(276224379), new GTA.Math.Vector3(2033.644f, 2830.369f, 49.30626f), new GTA.Math.Vector3(0f, 0f, -16.99992f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(1988.923f, 2852.714f, 49.27079f), new GTA.Math.Vector3(0f, 0f, 25f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2000.575f, 2858.135f, 49.28042f), new GTA.Math.Vector3(0f, 0f, 8.000007f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2013.178f, 2859.965f, 49.23547f), new GTA.Math.Vector3(0f, 0f, 7.999998f), false, false); GTA.World.CreateVehicle(new Model(-82626025) new GTA.Math.Vector3(2058.021f, 2765.874f, 50.80261f), -59.5616f); GTA.World.CreatePed(new Model(307287994), new GTA.Math.Vector3(2031.123f, 2859.301f, 49.64544f), 55.04015f); } }} You need patience, but regardless. I see one problem. your interval is set to 10ms. So that may not detect that you are pressing F11. (set that to 1;) To help others in future, you may want to split your code up so it is more readable (this may help you in future when you have long code too) if (e.Keycode == Keys.F12) { GTA.World.CreateProp(new Model(276224379), new GTA.Math.Vector3(2033.644f, 2830.369f, 49.30626f), new GTA.Math.Vector3(0f, 0f, -16.99992f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(1988.923f, 2852.714f, 49.27079f), new GTA.Math.Vector3(0f, 0f, 25f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2000.575f, 2858.135f, 49.28042f), new GTA.Math.Vector3(0f, 0f, 8.000007f), false, false); GTA.World.CreateProp(new Model(2122387284), new GTA.Math.Vector3(2013.178f, 2859.965f, 49.23547f), new GTA.Math.Vector3(0f, 0f, 7.999998f), false, false); GTA.World.CreateVehicle(new Model(-82626025) new GTA.Math.Vector3(2058.021f, 2765.874f, 50.80261f), -59.5616f); GTA.World.CreatePed(new Model(307287994), new GTA.Math.Vector3(2031.123f, 2859.301f, 49.64544f), 55.04015f); } Can be written as if(e.KeyCode == Keys.F11) { //Cars //Props //Peds //C++ Function //Spawn Ped //Ped Type //Ped Model //X,Y,Z //Heading Dir //Handles Function.Call (Hash.CREATE_PED, 1, new Model(PedHash.Pilot01SMM), 2031.123f, 2859.301f, 49.64544f, 0, true, true); } I've only done one Ped example, but the Vehicles and Props follow the same pattern. If problems persist with spawning props, you may need to load the prop model before spawning it. EDIT, you might also want to remove void OnKeyDown() you're probably not going to use it, but of course keep your void OnTick() for tick events Edited November 22, 2015 by Colata Link to comment Share on other sites More sharing options...
qiangqiang101 Posted November 22, 2015 Share Posted November 22, 2015 GTA.World.CreateProp(new Model(276224379), new GTA.Math.Vector3(2033.644f, 2830.369f, 49.30626f), new GTA.Math.Vector3(0f, 0f, -16.99992f), false, false); you cannot spawn model with hash, you need to spawn with model name Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted November 22, 2015 Author Share Posted November 22, 2015 (edited) thanks for your help, where in the scipt do i load the models ? // Creates the model var model = new Model("prop_fnclink_09e"); model.Request(250); // Check the model is valid if (model.IsInCdImage && model.IsValid) { // Ensure the model is loaded before we try to create it in the world while (!model.IsLoaded) Script.Wait(50); } // Mark the model as no longer needed to remove it from memory. //model.MarkAsNoLongerNeeded(); qiangqiang101 does that mean i dont need all this code to load it ? Edited November 22, 2015 by SpiderMight Link to comment Share on other sites More sharing options...
Colata Posted November 23, 2015 Share Posted November 23, 2015 thanks for your help, where in the scipt do i load the models ? // Creates the model var model = new Model("prop_fnclink_09e"); model.Request(250); // Check the model is valid if (model.IsInCdImage && model.IsValid) { // Ensure the model is loaded before we try to create it in the world while (!model.IsLoaded) Script.Wait(50); } // Mark the model as no longer needed to remove it from memory. //model.MarkAsNoLongerNeeded(); qiangqiang101 does that mean i dont need all this code to load it ? Yes, to spawn a prop you need to use all of that (which simply loads the model and spawns it) because models are more complex than cars and peds, i presume. you can use a foreach (models in list) var model = new Model("prop_fnclink_09e"); model.Request(250); // Check the model is valid if (model.IsInCdImage && model.IsValid) { // Ensure the model is loaded before we try to create it in the world while (!model.IsLoaded) Script.Wait(50); } except of course you wouldn't make individual variables (var) you would make a list seperated from this and spawn each variable in that list, rather than in the foreach loop. ShadowCoderKing 1 Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted November 23, 2015 Author Share Posted November 23, 2015 thanks Link to comment Share on other sites More sharing options...
AHK1221 Posted December 20, 2015 Share Posted December 20, 2015 (edited) You need patience, but regardless. I see one problem. your interval is set to 10ms. So that may not detect that you are pressing F11. (set that to 1;) To help others in future, you may want to split your code up so it is more readable (this may help you in future when you have long code too) I think that interval only effects the Tick event, not the keyDown handler Edited December 20, 2015 by AHK1221 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