Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help required with scripting issues

Featured Replies

Hello

I initially posted this over on the GTAforums and I figure this is another good place for assistance. These issues (the one pertaining to the script in particular) are prohibiting me from working on the rest of the script, I would really appreciate any help you can provide in fixing them.

I'm attempting to put together a small script to spawn several different events around the player. I've been reading other peoples' code and trying to make sense of how spawning and assigning tasks and all that sort of good stuff works; I'm finally getting the hang of it. However no matter what I do, the script is producing some rather annoying issues (note: I have the latest scripthook, scripthook.net and advanced script hook installed), I've been searching around the internet for answers to these issues for a while and haven't found anything. There doesn't seem to be much documentation out there for GTAIV scripting (I've got the ScriptHook documentation and using the Object viewer, but they lack examples and whilst a good resource, aren't enough for a newb) I simply cannot get these fixed so I'm posting here for some assistance:

The first issue is quite complicated to explain; somehow the script appears to be causing GTA:EFLC (also note it's the most recent version, 1.1.2.0) to intermittently switch between "Not responding" and apparently loading very slowly when starting up. I've always had to close the game when this happens, the furthest I can get it to go is the TBOG/TLAD menu screen, but the intermittent hanging prevents making any selection. This seems to happen only on installations with scripthook installed (I have several backups, clean one still works). A restart fixes it. Sometimes clearing the settings folder from App Data fixes it, sometimes minimizing the game and re-opening whilst it's loading fixes it. Sometimes calling it a swine fixes it. Truth be told I don't know what's causing this and I don't know exactly how to fix it (bar restarting my computer which is just a pain). It would appear to happen after I've had to close the game due to the game freezing because of - I suspect - my script. It's extremely frustrating though, it makes for a hard time just trying to get in-game to test the script. Anyone have any ideas why this would happen?

The second issue is more related to the script (once the game stops messing around and loads up). It will not stop giving me the following error:

Error during Tick in script 'Policing.Policing':

System.NullReferenceException: Object reference not set to an instance of an object.

at Policing.Policing.PolicingTick(Object sender, EventArgs e)

at GTA.Script.TryTick()

at GTA.Script.DoTick()

at GTA.ScriptThread.OnTick()

What causes this error? I've tried everything to fix it, I've tried a straight copy paste of other working scripts to removing everything from my script and ONLY running the following (sometimes the script is fine until I 'reloadscripts' then the error starts appearing):

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

using GTA;



namespace Policing

{

	public class Policing : Script

	{



		Ped Person = null;

		Blip PersonMarker = null;

		AnimationSet Anim1 = new AnimationSet("amb@bum_c");

		AnimationSet Anim2 = new AnimationSet("amb@drunk");

		AnimationFlags animflags = AnimationFlags.Unknown12 | AnimationFlags.Unknown11 | AnimationFlags.Unknown09 | AnimationFlags.Unknown06;



		Blip CreateMarker(Ped person, BlipIcon icon, string name)

		{

			Blip blip = person.AttachBlip();

			blip.Icon = icon;

			blip.Name = name;

			return blip;

		}



		private static void DeleteBlip(Blip blip)

		{

			blip.Delete();

		}



		public int random_num(int min, int max)

		{

			Random random = new Random();

			return random.Next(min, max);

		}





		public Policing()

		{

			Game.DisplayText("					   Running Policing script by Braveheart", 7000);

			Interval = 30000;

			this.Tick += new EventHandler(this.Policing_Tick);

		}





		public void Policing_Tick(object sender, EventArgs e)

		{

			Person = World.GetRandomPed(Player.Character.Position, 8.0f);



			if (Person != null && Person.Exists() && Person.isAlive &&

			  Person.Position.DistanceTo(Player.Character.Position) <= 500.0f)

			{



				Game.DisplayText("Event 1", 999);



				PersonMarker = CreateMarker(Person, BlipIcon.Misc_Revenge, "Suspected D&I");



				while (!Person.isInCombat && Person.isAlive)

				{

					Person.Task.PlayAnimation(new AnimationSet("amb@bum_c"), "walkcycle_drunk_b", 1.0f, animflags);

				}

			}

		}

	}

}

That is only a section of the code there's quite a lot of it, but the error appears to stem from something in there. Sometimes the game will freeze completely and no error is present in the log. I initially thought one of the following was the cause:

Wait()

PlayAnimation

Animation.WaitUntilFinished

World.GetRandomPed

But even after removing all of the above and ONLY having a tick with nothing inside of it, I still get the error.

So then, anyone have any ideas on the first issue? What about the script error, where does it come from and how should I look to fix it? When using World.GetRandomPed, what's the largest float radius I can (or should) use?

Thanks in advance for any assistance you can provide.

Edited by Braveheart

Serving Police Scotland PC.

Creator of Braveheart's Policing Script.

Change 'while' to 'if' and it will stop crashing, but it doesnt seem to play anims properly after that.

while (!Person.isInCombat && Person.isAlive)

Every time I have attempted the 'while' statement the game crashs. dunno if thats the script hook or just my badluck

Edited by Revan

[center][url="http://steamcommunity.com/id/Darth_Revan"][img]http://i1192.photobucket.com/albums/aa340/iconography1/Revan3.jpg[/img][/url] [color=#ff8c00][i][b]Thanks Iconography[/b][/i][/color] OS #1: Windows 7 x64 CPU: AMD Phenom II X4 940 ~3.0Ghz --- GPU: Nvidia GTS 250 (1GB) --- RAM: 4GB Keyboard: Logitech G15 --- Mouse: Logitech G500[/center]

I'm not sure what the issue is, but another support resource you could try (which has worked very well for me) is the IRC channel #gtaivnetscripthook on freenode.

  • Author

Change 'while' to 'if' and it will stop crashing, but it doesnt seem to play anims properly after that.

while (!Person.isInCombat && Person.isAlive)

Every time I have attempted the 'while' statement the game crashs. dunno if thats the script hook or just my badluck

Is there any way to have ped animations loop? I was using the while loop to ensure the drunk animation kept going as without it, the ped returns to normal (or usually just stands still staring into oblivion).

Serving Police Scotland PC.

Creator of Braveheart's Policing Script.

Try using

Person.Task.ClearAll();

GTA.Native.Function.Call("SET_CHAR_KEEP_TASK", Person, 1);


if (!Person.isInCombat && Person.isAlive)

{

Person.Task.ClearAll();

GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Person, 1);

//GTA.Native.Function.Call("SET_ANIM_GROUP_FOR_CHAR", person, "move_m@generic"); //Alter this for bum movement

Person.Task.PlayAnimation(new AnimationSet("amb@bum_c"), "walkcycle_drunk_b", 1.0f, animflags);

GTA.Native.Function.Call("SET_CHAR_KEEP_TASK", Person, 1);

}

else if (Person.isInCombat)

{

Person.Task.ClearAll();

Person.Task.FleeFromChar(Player.Character);

}

In fact it might be better if you just change the walk animation entirely

Edited by Revan

[center][url="http://steamcommunity.com/id/Darth_Revan"][img]http://i1192.photobucket.com/albums/aa340/iconography1/Revan3.jpg[/img][/url] [color=#ff8c00][i][b]Thanks Iconography[/b][/i][/color] OS #1: Windows 7 x64 CPU: AMD Phenom II X4 940 ~3.0Ghz --- GPU: Nvidia GTS 250 (1GB) --- RAM: 4GB Keyboard: Logitech G15 --- Mouse: Logitech G500[/center]

Guys I have just made a account on this site and I really want to get my mod to work I have ran it as admin and reinstalled it twice (running as admin both times) I managed to screenshot the script error which is stopping me from running the mod I am also running version 1.4 of GTA because I have mods like iCEnhacer on here is the link to the screenshot

http://steamcommunit...0260?tab=public its the LCPDFR mod

Edited by CurtEvil Alien

Stick to your own topic dont hijack other threads, as for LCPDFR version 1.0.4.0 is unsupported

[center][url="http://steamcommunity.com/id/Darth_Revan"][img]http://i1192.photobucket.com/albums/aa340/iconography1/Revan3.jpg[/img][/url] [color=#ff8c00][i][b]Thanks Iconography[/b][/i][/color] OS #1: Windows 7 x64 CPU: AMD Phenom II X4 940 ~3.0Ghz --- GPU: Nvidia GTS 250 (1GB) --- RAM: 4GB Keyboard: Logitech G15 --- Mouse: Logitech G500[/center]

  • Author

Try using

Person.Task.ClearAll();

GTA.Native.Function.Call("SET_CHAR_KEEP_TASK", Person, 1);


if (!Person.isInCombat && Person.isAlive)

{

Person.Task.ClearAll();

GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Person, 1);

//GTA.Native.Function.Call("SET_ANIM_GROUP_FOR_CHAR", person, "move_m@generic"); //Alter this for bum movement

Person.Task.PlayAnimation(new AnimationSet("amb@bum_c"), "walkcycle_drunk_b", 1.0f, animflags);

GTA.Native.Function.Call("SET_CHAR_KEEP_TASK", Person, 1);

}

else if (Person.isInCombat)

{

Person.Task.ClearAll();

Person.Task.FleeFromChar(Player.Character);

}

In fact it might be better if you just change the walk animation entirely

Thanks for that. It seems to cause the game to freeze though, I'll keep trying to figure it out. Is there anywhere that explains how to use the GTA.Native.Function.Call()? I keep seeing it used with lots of different parameters but nowhere have I found an explanation of what these parameters can or should be.

When getting a ped around the Player, what is the maximum distance I can use? One last thing, the drunk peds outside of the clubs (and randomly spawned in LCPDFR) are they playing animations or are they using a certain walk style? Or is it euphoria? I can't find the animations/walk styles anywhere.

Serving Police Scotland PC.

Creator of Braveheart's Policing Script.

TBH, I dont play with anims & walkstyles, as for the native functions I use GTAModding for its list, and only a select few have been marked for inputs, It was down yesterday and I was linked this from a fellow forum member: http://code.google.c...ook/Scripting.h

Its in C++ but it gives the native function & inputs it can take, just switch it to C# and your good to go (Its very informative compared to GTAModding native list)

Edit: As for distance of getting a ped around a player, I dont know the 'max' but I use anywhere from 10 to 30

Edited by Revan

[center][url="http://steamcommunity.com/id/Darth_Revan"][img]http://i1192.photobucket.com/albums/aa340/iconography1/Revan3.jpg[/img][/url] [color=#ff8c00][i][b]Thanks Iconography[/b][/i][/color] OS #1: Windows 7 x64 CPU: AMD Phenom II X4 940 ~3.0Ghz --- GPU: Nvidia GTS 250 (1GB) --- RAM: 4GB Keyboard: Logitech G15 --- Mouse: Logitech G500[/center]

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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.