Quantcast

Jump to content

» «
Photo

Draw Lights

2 replies to this topic
icecube3456
  • icecube3456

    Player Hater

  • Members
  • Joined: 10 May 2013

#1

Posted 11 May 2013 - 06:31 AM

CODE


if (Keys.Q == e.Key)
{
   Vector3 player = Player.Character.Position;
    float intensity = 10.0f;
    float range = 10.0f;
    DrawLight(player.X, player.Y, player.Z, 255, 255, 255, intensity, range);
}

private void DrawLight(float x, float y, float z, int r, int g, int b, float intensity, float range)
{
    GTA.Native.Function.Call("NATIVE_DRAW_LIGHT_WITH_RANGE", x, y, z, r, g, b, intensity, range);
}


I use this code, but no light is created. I also get no errors.

motorsport71
  • motorsport71

    newbie modder

  • Members
  • Joined: 20 Oct 2009

#2

Posted 11 May 2013 - 07:57 PM Edited by motorsport71, 11 May 2013 - 08:02 PM.

you are going to need to declare the xyz vectors for your players position independently, not as a single vector3 "player.character.position". Try using:
CODE
Player.Character.Position.X
Player.Character.Position.Y
Player.Character.Position.Z

or if you want to set a place for the light to stay permanently, say in front of a door, you can place a permanent set of x,y,and z coordinates. Also, the light will not "stay on." It will only last as long as you hold the key OR you keep it on a tick without any type of timer / delay or it will only pop on for only one ms. Also, the R, G, B are all used to alter the color of the light.

CODE
Native.Function.Call("DRAW_LIGHT_WITH_RANGE", 459.51, 323.2, 8.57, 250, 0, 10, 20.0F, 95.0F)

this one makes a tombstone in the graveyard in the middle of the map glow bright red when left to run continuously, used it in my Jenny's Soul mission/Mod.

Here is a link to a pic if you want:Jenny's Soul

Nevitro
  • Nevitro

    Modder

  • Members
  • Joined: 31 Mar 2009

#3

Posted 11 May 2013 - 08:51 PM Edited by Nevitro, 11 May 2013 - 08:54 PM.

Man... Vector3 got X,Y and Z.
CODE

Vector3 player = Player.Character.Position;

This is GOOD.

For icetube:
on top of file add
CODE

using System.Drawing;


Also, why You use function to call native function? ;o
This is not good.
Also, you use "player.X", THIS IS BAD - WARNING!!!
Do not name variables like in dll! Example:
Vector3 myPlayer = Player.Character.Position; - that is ok
Vector3 player = Player.Character.Position; - NOT OKEY!!!
Why? Because in instructions for ScriptHook You will see, player is reseved to some functions. [if he is local etc]


So, change "player" to "myPlayer" and do not make next function, just call native function:
CODE

GTA.Native.Function.Call("DRAW_LIGHT_WITH_RANGE", myPlayer.X, myPlayer.Y, myPlayer.Z, 255, 255, 255, 10.0F, 10.0F);

Mayby change small 'f' to big 'F', because in C# small and big letter have difference.

At the end You must remeber to call EVERY DRAWING OPTION in:
CODE


...
// in public in script
this.PerFrameDrawing += new GraphicsEventHandler(this.BodyMenu);
...
private void BodyMenu(object sender, GraphicsEventArgs abc)
{
// draw draw draw
}




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users