IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Post mod/code requests in the Mod Requests topic

Post mod releases in the Mod Showroom

Read the Modding Rules BEFORE posting!

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 Scripting issues

 
Braveheartuk  
Posted: Saturday, Jun 2 2012, 19:50
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Jun 2, 2012

XXXXX



Hello

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:

QUOTE

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

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

This post has been edited by Braveheartuk on Saturday, Jun 2 2012, 21:23
PM
  Top
 

 
hardsty1e  
Posted: Thursday, Nov 8 2012, 17:26
Quote Post


Rat
Group Icon
Group: Members
Joined: May 2, 2009

XXXXX



I have the same problem with your script, I finally fixed it by tweaking the tick.


This post has been edited by hardsty1e on Thursday, Nov 8 2012, 18:14
PM
  Top
 

 
julionib  
Posted: Friday, Nov 9 2012, 01:32
Quote Post


Snitch
Group Icon
Group: Members
Joined: Sep 13, 2012

XXXXX



the error that you mentioned happens when an game object dont exists anymore, like when an ped goes too far from the player

this code here:

while (!Person.isInCombat && Person.isAlive)
{
Person.Task.PlayAnimation(new AnimationSet("amb@bum_c"), "walkcycle_drunk_b", 1.0f, animflags);
}

needs an check to see if the person is not null and if person exists, i believe
Users WebsitePM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG