Quantcast

Jump to content

» «
Photo

Help with door

2 replies to this topic
Xdozorce
  • Xdozorce

    Player Hater

  • Members
  • Joined: 23 Jul 2013

#1

Posted 23 July 2013 - 01:14 PM Edited by Xdozorce, 23 July 2013 - 02:55 PM.

Hi,

I have problem with this code:

CODE

using System;
using System.Text;
using System.Windows.Forms;
using GTA;

namespace GateScriptCS {

  public class OpenGateScript : Script
  {

      bool bGate = false;

      public OpenGateScript()
      {
          BindKey(Keys.I, new KeyPressDelegate(OpenGate));
      }

      private void OpenGate()
      {
          bGate = !bGate;
          if (bGate)
          {
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x47eed4d0, -1140.936f, -371.516f, 3.8f, 1, 1.0f);
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x99ccf88f, -1140.936f, -378.051f, 3.8f, 1, 1.0f);

              Game.DisplayText("Gate CLOSE");
          }
          else
          {
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x47eed4d0, -1140.936f, -371.516f, 3.8f, 0, 1.0f);
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x99ccf88f, -1140.936f, -378.051f, 3.8f, 0, 1.0f);

              Game.DisplayText("Gate OPEN");
          }
      }
  }

}



   


If I press I, ScriptHook give me this error:

CODE
Error during NetHook.Tick:
                     System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
                        at Scripting.NativeContext2.Invoke(SByte* name, NativeContext2* cxt)
                        at GTA.Native.Function.BaseCall(String Name, Parameter[] Arguments)
                        at GTA.Native.Function.Call(String Name, Parameter[] Arguments)
                        at GTA.Native.Template.Invoke()
                        at GTA.ScriptDomain.RemoteEvent(RemoteEventArgs ev)
                        at GTA.ScriptDomain.ProcessRemoteEvents()
                        at GTA.ScriptDomain.Tick()
                        at GTA.NetHook.Tick()



What might be wrong?


Thank for replies

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#2

Posted 23 July 2013 - 02:34 PM Edited by pedro2555, 23 July 2013 - 02:37 PM.

I think the integration service is converting your literal hexadecimals into Int32, rather than UInt32. Just force the type cast. And also, even zeros, if they should be treated as floating point numbers, you should specify that.

CODE

GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0xa96f0f0f, -985.7f, -445.1f, 3.3f, 1, 0.0f);

GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x99ccf88f, -1140.936f, -378.051f, 3.8f, 0, 0.0f);


Let me know if it fixes it, I've also experienced that exact same error message.

PS: the x, y and z values aren't the same, is that correct ?

Xdozorce
  • Xdozorce

    Player Hater

  • Members
  • Joined: 23 Jul 2013

#3

Posted 23 July 2013 - 02:46 PM Edited by Xdozorce, 23 July 2013 - 03:02 PM.

The same error...

CODE

using System;
using System.Text;
using System.Windows.Forms;
using GTA;

namespace GateScriptCS {
   
  public class OpenGateScript : Script
  {

      bool bGate = false;

      public OpenGateScript()
      {
          BindKey(Keys.I, new KeyPressDelegate(OpenGate));
      }

      private void OpenGate()
      {
          bGate = !bGate;
          if (bGate)
          {
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x99ccf88f, -1140.936f, -378.051f, 3.8f, 1, 1.0f);

              Game.DisplayText("Gate CLOSE");
          }
          else
          {
              GTA.Native.Function.Call("SET_STATE_OF_CLOSEST_DOOR_OF_TYPE", (uint)0x47eed4d0, -1140.936f, -371.516f, 3.8f, 0, 1.0f);

              Game.DisplayText("Gate OPEN");
          }
      }
  }

}




//EDIT: Values of positions was bad.. I don't know why.. :-O




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users