Quantcast

Jump to content

» «
Photo

Identify Current/Last Vehicle Entered

35 replies to this topic
Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#1

Posted 21 May 2013 - 03:26 PM

Hello,

Basically I am trying to create a script (in C++) whereby the player can easily identify the last car they were in upon exiting the vehicle (running off to do something else). The last vehicle entered will have an arrow above it and will appear as a blip on your map and minimap and will be called "Your Car". If you then go on to enter another vehicle, the previous vehicle will be forgotten and the new vehicle will be classed as your new, current vehicle that you are making use of.

I have made quite a start and I'm nearly there, however I'm stuck and seek some help, the main problems are that my compiler (Visual Studio) doesn't like the GetDriverOfCar function and its' parameters as well as the fact I'm unsure as to how to get the vehicle ID of my current car in order to add a blip to it so it can be identified once i've exited the vehicle regarding the AddBlipToCar function.

Below is the code I have thus far, any help would be appreciated to get this up and running:

CODE
#include "CustomFiberThread.h"
#include "Scripting.h"
#include "../ScriptHook/Log.h"
#include <windows.h>

using namespace Scripting;

CustomFiberThread::CustomFiberThread()
{
SetName("CarOwnership");
}

void CustomFiberThread::RunScript()
{
while(IsThreadAlive())
{
Blip SavedVehicleBlip;
int playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
Ped ped;
GetPlayerChar(playerIndex, &ped);
Blip SavedVehicleBlip;
Vehicle LastVehicle;
Vehicle SavedVehicle;
Vehicle CurrentVehicle;
   
if ((IsCharInAnyCar(GetPlayerPed()) == true) && (GetDriverOfCar(CurrentVehicle, &GetPlayerPed()) == ped))
{
if (SavedVehicle != false)
{
SetCarAsMissionCar(SavedVehicle, false);
SavedVehicleBlip == false;
}
GetCarCharIsUsing(ped, &CurrentVehicle);
StoreCarCharIsInNoSave(playerIndex, &CurrentVehicle);
SetCarAsMissionCar(CurrentVehicle, true);
AddBlipForCar(GetVehicleModel(), &SavedVehicleBlip);
ChangeBlipSprite(SavedVehicleBlip, BLIP_GARAGE);
ChangeBlipScale(SavedVehicleBlip, 0.5f);
ChangeBlipColour(SavedVehicleBlip, 5); //Magenta
SetBlipAsShortRange(SavedVehicleBlip, 1);
ChangeBlipNameFromAscii(SavedVehicleBlip, "Your Car");
}
       
if (SavedVehicle != false)
{
SetCarAsMissionCar(CurrentVehicle, false);;
RemoveBlip(SavedVehicleBlip);
}
 
if ((IsCharInAnyCar(GetPlayerPed()) == true))
{
LastVehicle = CurrentVehicle;
}
}
}


Cheers,

Billsy

jitsuin666
  • jitsuin666

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#2

Posted 21 May 2013 - 04:03 PM

Ped vehicle and blip are scripthookdotnet classes. For the native with errors check scripting.h and u can see how to use

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#3

Posted 21 May 2013 - 04:09 PM

QUOTE (jitsuin666 @ Tuesday, May 21 2013, 16:03)
Ped vehicle and blip are scripthookdotnet classes. For the native with errors check scripting.h and u can see how to use

Yes, I did check scripting.h as some of the native functions I have used had to be added across from scriptingdirty.h but I'm still unsure as to where to go from the code I have and how to go about rectifying the few errors that still remain.

Thanks.

jitsuin666
  • jitsuin666

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#4

Posted 21 May 2013 - 04:15 PM

Post the method from the header file

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#5

Posted 21 May 2013 - 04:20 PM

QUOTE (jitsuin666 @ Tuesday, May 21 2013, 16:15)
Post the method from the header file

What do you mean by this, can you elaborate, do you want me to post some extra information here?

Thanks.

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#6

Posted 21 May 2013 - 09:00 PM Edited by Lord_of_Light, 21 May 2013 - 09:02 PM.

yes i wanted u to post this code:

CODE
static void GetDriverOfCar(Vehicle vehicle, Ped *pPed) { NativeInvoke::Invoke<NATIVE_GET_DRIVER_OF_CAR, ScriptVoid>(vehicle, pPed); }


i recommend u write this in c#, c++ scripts dont have any performance benefits really and coding it is more a hassle for someone new...

c#

CODE
Ped driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);//will crash if vehicle does not exist


c++

CODE
Vehicle vehicle;//set your vehicle however u do... GetClosestCar, etc
Ped driver;
GetDriverOfCar(vehicle, &driver);


edit: my bad scripthook has vehicle, ped and blip class like shdn. i thought they were handled differently... i dont use the c++ scripthook wink.gif

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#7

Posted 21 May 2013 - 09:07 PM

QUOTE (Lord_of_Light @ Tuesday, May 21 2013, 21:00)
yes i wanted u to post this code:

CODE
static void GetDriverOfCar(Vehicle vehicle, Ped *pPed) { NativeInvoke::Invoke<NATIVE_GET_DRIVER_OF_CAR, ScriptVoid>(vehicle, pPed); }


i recommend u write this in c#, c++ scripts dont have any performance benefits really and coding it is more a hassle for someone new...

c#

CODE
Ped driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);//will crash if vehicle does not exist


c++

CODE
Vehicle vehicle;//set your vehicle however u do... GetClosestCar, etc
Ped driver;
GetDriverOfCar(vehicle, &driver);


edit: my bad scripthook has vehicle, ped and blip class like shdn. i thought they were handled differently... i dont use the c++ scripthook wink.gif

Hey,

I changed
CODE
if ((IsCharInAnyCar(GetPlayerPed()) == true) && (GetDriverOfCar(CurrentVehicle, &GetPlayerPed()) == ped))
to this
CODE
if ((IsCharInAnyCar(GetPlayerPed()) == true) && (GetDriverOfCar(CurrentVehicle, &ped)))
as it didn't like the "== true". However, now it still doesn't like the GetDriverOfCar part of the if condition as Visual Studio is saying it needs to be a boolean, how do I code the condition (if statement) correctly in this scenario?

Thanks

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#8

Posted 21 May 2013 - 09:17 PM Edited by Lord_of_Light, 21 May 2013 - 09:22 PM.

your syntax is all wrong your asking if a void function is true or false

since your new to programming maybe .net would be better for u to learn and then once u understand .net and how programming works... something like learning c++ will be much easier

also the first way of checking if a void function equals a ped is also bad syntax

both lines u posted are not valid code

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#9

Posted 21 May 2013 - 09:24 PM Edited by Lord_of_Light, 21 May 2013 - 09:27 PM.

CODE
if ((IsCharInAnyCar(GetPlayerPed()) == true) && (GetDriverOfCar(CurrentVehicle, &GetPlayerPed()) == ped))


should be

CODE

Ped ped;
GetDriverOfCar(CurrentVehicle, &ped)
if ((IsCharInAnyCar(GetPlayerPed()) == true) && (GetPlayerPed() == ped))


try that

when u check if values equal each other in an if statement, u need to be comparing same value types and u cant compare functions that return void... since u wont have anything to compare... these functions simply perform a task or process some value

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#10

Posted 22 May 2013 - 06:16 AM

hey what u want the script to do im bored ill write if u want?

will be in .net because i dont believe in wasting time lol

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#11

Posted 22 May 2013 - 06:50 AM Edited by Lord_of_Light, 22 May 2013 - 06:57 AM.

CODE
namespace SaveMyCar
{
   using System;
   using GTA;

   public class Main : Script
   {
       Blip blip;
       Vehicle playerVeh;

       public Main()
       {
           Tick += Main_Tick;
       }

       void Main_Tick(object sender, EventArgs e)
       {
           if (Game.LocalPlayer.Character.isInVehicle())
           {
               if (Game.Exists(playerVeh))
               {
                   if (playerVeh.isRequiredForMission) playerVeh.isRequiredForMission = false;
                   if (playerVeh != Game.LocalPlayer.Character.CurrentVehicle) playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
               }
               else
               {
                   playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
               }

               if (Game.Exists(blip)) blip.Delete();
           }
           else
           {
               if (Game.Exists(playerVeh) && playerVeh.isDriveable && !playerVeh.isRequiredForMission)
               {
                   playerVeh.isRequiredForMission = true;
                   if (!Game.Exists(blip))
                   {
                       blip = playerVeh.AttachBlip();
                       blip.Name = "Your Car";
                       blip.Scale = 0.5f;
                       blip.Color = (BlipColor)5;
                   }
               }
           }
       }
   }
}


.net is much easier to work with, u can see how simple it is to read the script and intellisense is so much better wink.gif

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#12

Posted 22 May 2013 - 01:02 PM

QUOTE (Lord_of_Light @ Wednesday, May 22 2013, 06:50)
CODE
namespace SaveMyCar
{
   using System;
   using GTA;

   public class Main : Script
   {
       Blip blip;
       Vehicle playerVeh;

       public Main()
       {
           Tick += Main_Tick;
       }

       void Main_Tick(object sender, EventArgs e)
       {
           if (Game.LocalPlayer.Character.isInVehicle())
           {
               if (Game.Exists(playerVeh))
               {
                   if (playerVeh.isRequiredForMission) playerVeh.isRequiredForMission = false;
                   if (playerVeh != Game.LocalPlayer.Character.CurrentVehicle) playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
               }
               else
               {
                   playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
               }

               if (Game.Exists(blip)) blip.Delete();
           }
           else
           {
               if (Game.Exists(playerVeh) && playerVeh.isDriveable && !playerVeh.isRequiredForMission)
               {
                   playerVeh.isRequiredForMission = true;
                   if (!Game.Exists(blip))
                   {
                       blip = playerVeh.AttachBlip();
                       blip.Name = "Your Car";
                       blip.Scale = 0.5f;
                       blip.Color = (BlipColor)5;
                   }
               }
           }
       }
   }
}


.net is much easier to work with, u can see how simple it is to read the script and intellisense is so much better wink.gif

Hey,

Thanks for this Lord, however, it doesn't quite do what I want it to do. When I tried your script, the first car I get in, gets a blip (which is good, as intended). However, if I get in another car, the blip for the first car still exists and doesn't get deleted. I want that to be deleted as the current car gets updated with the new car you are now in and for that to get a blip and so on, updating for every new car you enter. If that makes sense? What part of the code would you change in order for that to come into effect?

Cheers.

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#13

Posted 22 May 2013 - 04:33 PM Edited by Lord_of_Light, 22 May 2013 - 05:29 PM.

QUOTE (Billsy93 @ Wednesday, May 22 2013, 13:02)

Hey,

Thanks for this Lord, however, it doesn't quite do what I want it to do. When I tried your script, the first car I get in, gets a blip (which is good, as intended). However, if I get in another car, the blip for the first car still exists and doesn't get deleted. I want that to be deleted as the current car gets updated with the new car you are now in and for that to get a blip and so on, updating for every new car you enter. If that makes sense? What part of the code would you change in order for that to come into effect?

Cheers.

When I tested entering multiple cars it worked, u donthave 2 scripts installed changing if vehicle is a mission vehicle?? Test my script alone to double check

Worked for me but I'll double check later

this may help u understand where the bug is coming from...

CODE
namespace SaveMyCar
{
   using System;
   using GTA;

   public class Main : Script
   {
       Blip blip;
       Vehicle playerVeh;

       public Main()
       {
           Tick += Main_Tick;
       }

       //this script manages two different states the player could be in... in a car or on foot

       void Main_Tick(object sender, EventArgs e)
       {
           if (Game.LocalPlayer.Character.isInVehicle())//Player is in vehicle
           {
               if (Game.Exists(playerVeh))//player car has been saved previously
               {
                   if (playerVeh.isRequiredForMission) playerVeh.isRequiredForMission = false;//removes save flag from previously saved car which may or may not be the current car the player is in, this script uses the ReqForMission vehicle property as a flag and only set true when exiting the car
                   if (playerVeh != Game.LocalPlayer.Character.CurrentVehicle) playerVeh = Game.LocalPlayer.Character.CurrentVehicle;//ensures player's current car is the new car to be saved
               }
               else//player car not previously saved
               {
                   playerVeh = Game.LocalPlayer.Character.CurrentVehicle;//this sets the first car player gets into
               }

               if (Game.Exists(blip)) blip.Delete();//deletes blip this script created so for u to get in another car and this blip not get deleted does not make sense, if in fact your blip isnt being deleted i believe u have a script installed with bad code and f*cking up gta memory, u usually will run into access violation errors that u can see in the console when this happens
           }
           else//Player is on foot
           {
               //removed... && playerVeh.isDriveable as i don't think it is necessary on 2nd thought and may confuse things

               if (Game.Exists(playerVeh) && !playerVeh.isRequiredForMission)//ensures a player car was saved to vehicle variable and it hasn't already been made a mission car, which is the flag this script relies on
               {
                   playerVeh.isRequiredForMission = true;
                   if (!Game.Exists(blip))
                   {
                       blip = playerVeh.AttachBlip();
                       blip.Name = "Your Car";
                       blip.Scale = 0.5f;
                       blip.Color = (BlipColor)5;
                   }
               }
           }
       }
       //so this script just constantly checks for a situation and when it finds it, runs a few lines of code and the following ticks, no code should run
       //just walk through my comments and see if u can determine where my logic breaks because i tested and works fine;)
   }
}


i kinda don't believe you since i tested last night and after reviewing code i see if u r in a vehicle... a blip will not be created by my script, it will only delete the blip it created before, then when ur on foot it can only create the blip once since the blip once and it even has to get through 2 checks to make another blip so this script can't lose track of the blip it creates... so im thinking u have another issue going on... and it did work perfect for me... read my comments in the script and let me know if it makes sense

every single if statement in this script is designed to only be true once for each time a player gets in and out of a vehicle so 99% of the time this script runs it just checks bools that route the script to just constantly return from the tick method

Lord_of_Light
  • Lord_of_Light

    Player Hater

  • BUSTED!
  • Joined: 21 May 2013

#14

Posted 22 May 2013 - 06:25 PM

ok i had someone else test the script and they said it worked fine... i am thinking u have another script installed messing stuff up

user posted image

PacketOVerload_x64Bit
  • PacketOVerload_x64Bit

    AUIRB2U Cinematica Damnum HD War Kitties 4

  • Members
  • Joined: 13 Mar 2010
  • Canada

#15

Posted 22 May 2013 - 10:30 PM

QUOTE (Lord_of_Light @ Wednesday, May 22 2013, 11:25)
ok i had someone else test the script and they said it worked fine... i am thinking u have another script installed messing stuff up

user posted image

Need to be careful with this individual. Just on GTAF this individual has had full conversations with himself (IV Coding Thread & ENB Screenshot Thread) using two or more accounts that were created by him for the sole purpose of spamming and getting his hate on. Someone said a while back that he had put a virus in one of his modifications. Scanning with AV is one part, but watch out for scripts from this individual. My 2˘.

-Packet

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#16

Posted 23 May 2013 - 11:58 AM

QUOTE (Lord_of_Light @ Wednesday, May 22 2013, 16:33)
QUOTE (Billsy93 @ Wednesday, May 22 2013, 13:02)

Hey,

Thanks for this Lord, however, it doesn't quite do what I want it to do. When I tried your script, the first car I get in, gets a blip (which is good, as intended). However, if I get in another car, the blip for the first car still exists and doesn't get deleted. I want that to be deleted as the current car gets updated with the new car you are now in and for that to get a blip and so on, updating for every new car you enter. If that makes sense? What part of the code would you change in order for that to come into effect?

Cheers.

When I tested entering multiple cars it worked, u donthave 2 scripts installed changing if vehicle is a mission vehicle?? Test my script alone to double check

Worked for me but I'll double check later

this may help u understand where the bug is coming from...

CODE
namespace SaveMyCar
{
   using System;
   using GTA;

   public class Main : Script
   {
       Blip blip;
       Vehicle playerVeh;

       public Main()
       {
           Tick += Main_Tick;
       }

       //this script manages two different states the player could be in... in a car or on foot

       void Main_Tick(object sender, EventArgs e)
       {
           if (Game.LocalPlayer.Character.isInVehicle())//Player is in vehicle
           {
               if (Game.Exists(playerVeh))//player car has been saved previously
               {
                   if (playerVeh.isRequiredForMission) playerVeh.isRequiredForMission = false;//removes save flag from previously saved car which may or may not be the current car the player is in, this script uses the ReqForMission vehicle property as a flag and only set true when exiting the car
                   if (playerVeh != Game.LocalPlayer.Character.CurrentVehicle) playerVeh = Game.LocalPlayer.Character.CurrentVehicle;//ensures player's current car is the new car to be saved
               }
               else//player car not previously saved
               {
                   playerVeh = Game.LocalPlayer.Character.CurrentVehicle;//this sets the first car player gets into
               }

               if (Game.Exists(blip)) blip.Delete();//deletes blip this script created so for u to get in another car and this blip not get deleted does not make sense, if in fact your blip isnt being deleted i believe u have a script installed with bad code and f*cking up gta memory, u usually will run into access violation errors that u can see in the console when this happens
           }
           else//Player is on foot
           {
               //removed... && playerVeh.isDriveable as i don't think it is necessary on 2nd thought and may confuse things

               if (Game.Exists(playerVeh) && !playerVeh.isRequiredForMission)//ensures a player car was saved to vehicle variable and it hasn't already been made a mission car, which is the flag this script relies on
               {
                   playerVeh.isRequiredForMission = true;
                   if (!Game.Exists(blip))
                   {
                       blip = playerVeh.AttachBlip();
                       blip.Name = "Your Car";
                       blip.Scale = 0.5f;
                       blip.Color = (BlipColor)5;
                   }
               }
           }
       }
       //so this script just constantly checks for a situation and when it finds it, runs a few lines of code and the following ticks, no code should run
       //just walk through my comments and see if u can determine where my logic breaks because i tested and works fine;)
   }
}


i kinda don't believe you since i tested last night and after reviewing code i see if u r in a vehicle... a blip will not be created by my script, it will only delete the blip it created before, then when ur on foot it can only create the blip once since the blip once and it even has to get through 2 checks to make another blip so this script can't lose track of the blip it creates... so im thinking u have another issue going on... and it did work perfect for me... read my comments in the script and let me know if it makes sense

every single if statement in this script is designed to only be true once for each time a player gets in and out of a vehicle so 99% of the time this script runs it just checks bools that route the script to just constantly return from the tick method

This is very strange indeed. I've tried again and uninstalling some others mods, but to no avail. I still get an error message when I get into a second vehicle upon loading the game. The script works fine for the first car, as when a exit the blip is there etc, but when I get into another car, I get an error and the blip from the first doesn't get deleted and updated to the new car when I exit. Here's what the error message is saying.

Error during Tick in script 'SaveMyCar.Main':
GTA.NonExistingObjectException: Invalid call to an object that doesn't exist anymore!
at GTA.Blip.Delete()
at SaveMyCar.Main.Main_Tick(Object sender, EventArgs e)
at GTA.Script.TryTick()
at GTA.Script.DoTick()
at GTA.ScriptThread.OnTick()

girish_is_gay
  • girish_is_gay

    Player Hater

  • BUSTED!
  • Joined: 23 May 2013

#17

Posted 23 May 2013 - 05:22 PM

i believe u have some type of conflict going on being it from another script or maybe u r using 1.0.4 and something in the 0.4.0 scripthook isnt compatable

this is the line of code that caused the crash btw

CODE
if (Game.Exists(blip)) blip.Delete();


The exists part ensures the object exists in memory so it has something to delete. So for it to say yes it exists and then when it deletes a nanosecond (not actual time) later it doesn't exist means u have a memory issue. I believe your using an old scripthook for an older version gta or ur using a script that is using code wrong and putting wrong value types into memory and making gta confused to what is what. So even though it thinks a blip exists, it might be looking at something completely different... this is my guess just based on what ur saying

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#18

Posted 23 May 2013 - 07:07 PM

QUOTE (girish_is_gay @ Thursday, May 23 2013, 17:22)
i believe u have some type of conflict going on being it from another script or maybe u r using 1.0.4 and something in the 0.4.0 scripthook isnt compatable

this is the line of code that caused the crash btw

CODE
if (Game.Exists(blip)) blip.Delete();


The exists part ensures the object exists in memory so it has something to delete. So for it to say yes it exists and then when it deletes a nanosecond (not actual time) later it doesn't exist means u have a memory issue. I believe your using an old scripthook for an older version gta or ur using a script that is using code wrong and putting wrong value types into memory and making gta confused to what is what. So even though it thinks a blip exists, it might be looking at something completely different... this is my guess just based on what ur saying

Cheers Girish,

I solved the issue now, you're right in identifying that it was to do with the blip deletion, the cause of the problem was where the code to delete the blip had been placed within the script. All is well, thanks for the help all.

girish_is_gay
  • girish_is_gay

    Player Hater

  • BUSTED!
  • Joined: 23 May 2013

#19

Posted 23 May 2013 - 07:09 PM Edited by girish_is_gay, 23 May 2013 - 07:11 PM.

QUOTE (Billsy93 @ Thursday, May 23 2013, 19:07)
QUOTE (girish_is_gay @ Thursday, May 23 2013, 17:22)
i believe u have some type of conflict going on being it from another script or maybe u r using 1.0.4 and something in the 0.4.0 scripthook isnt compatable

this is the line of code that caused the crash btw

CODE
if (Game.Exists(blip)) blip.Delete();


The exists part ensures the object exists in memory so it has something to delete. So for it to say yes it exists and then when it deletes a nanosecond (not actual time) later it doesn't exist means u have a memory issue. I believe your using an old scripthook for an older version gta or ur using a script that is using code wrong and putting wrong value types into memory and making gta confused to what is what. So even though it thinks a blip exists, it might be looking at something completely different... this is my guess just based on what ur saying

Cheers Girish,

I solved the issue now, you're right in identifying that it was to do with the blip deletion, the cause of the problem was where the code to delete the blip had been placed within the script. All is well, thanks for the help all.

so why dont u share what fixed it?

and u have been talking to one person... faggot mods on here ban me over and over, so u can thank jitsuin, not all

girish_is_gay
  • girish_is_gay

    Player Hater

  • BUSTED!
  • Joined: 23 May 2013

#20

Posted 23 May 2013 - 07:59 PM

QUOTE (PacketOVerload_x64Bit @ Wednesday, May 22 2013, 22:30)
QUOTE (Lord_of_Light @ Wednesday, May 22 2013, 11:25)
ok i had someone else test the script and they said it worked fine... i am thinking u have another script installed messing stuff up

user posted image

Need to be careful with this individual. Just on GTAF this individual has had full conversations with himself (IV Coding Thread & ENB Screenshot Thread) using two or more accounts that were created by him for the sole purpose of spamming and getting his hate on. Someone said a while back that he had put a virus in one of his modifications. Scanning with AV is one part, but watch out for scripts from this individual. My 2˘.

-Packet

look at the fear in this one LMAO

gtasadude
  • gtasadude

    Stunter

  • Members
  • Joined: 29 Oct 2005

#21

Posted 24 May 2013 - 01:23 AM

Fear vs common sense icon14.gif

girish_is_gay
  • girish_is_gay

    Player Hater

  • BUSTED!
  • Joined: 23 May 2013

#22

Posted 24 May 2013 - 01:50 AM

QUOTE (gtasadude @ Friday, May 24 2013, 01:23)
Fear vs common sense icon14.gif

more like he is a big fat vagina which is why he is still a virgin at 36 years old... him being a big pussy just repels all pussy away

girish_is_gay
  • girish_is_gay

    Player Hater

  • BUSTED!
  • Joined: 23 May 2013

#23

Posted 24 May 2013 - 03:26 AM

looks like it works to me...


Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#24

Posted 24 May 2013 - 11:46 AM

This is what I changed the script to and it works. Might have been a script conflict, although I did delete my script folder and try it on its own but the case was still the same. It could have been a C++ mod that was the cause of the problem as they are not placed in the scripts folder, just the main directory. Anyway, this is my version and it works perfectly as intended. Similar to the video posted above:

CODE
namespace SaveMyCar
{
using System;
using System.Windows.Forms;
using GTA;

public class Main : Script
{
 Blip blip;
 Vehicle playerVeh;

 public Main()
 {
  Tick += Main_Tick;
 }

 void Main_Tick(object sender, EventArgs e)
 {
  if (Game.LocalPlayer.Character.isInVehicle())
  {
   if (Game.Exists(playerVeh))
   {
    playerVeh.isRequiredForMission = false;
    GTA.Native.Function.Call("MARK_CAR_AS_NO_LONGER_NEEDED", playerVeh);    
    playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
    if (Game.Exists(blip))
    {
     GTA.Native.Function.Call("REMOVE_BLIP", blip);  
    }  
   }
   else
   {
    playerVeh = Game.LocalPlayer.Character.CurrentVehicle;
   }
  }
  else
  {
   if ((Game.Exists(playerVeh)) && (!playerVeh.isRequiredForMission))
   {
    playerVeh.isRequiredForMission = true;
    if (!Game.Exists(blip))
    {
     blip = playerVeh.AttachBlip();
     blip.Scale = 0.75f;    
     GTA.Native.Function.Call("CHANGE_BLIP_SPRITE", blip, 79);
     blip.Name = "Your Car";
     blip.Color = (BlipColor)5;  
    }
   }
  }


I will try deleting all mods and trying the original again, just seems very strange.

Imbaaaaaaaackniggers
  • Imbaaaaaaaackniggers

    Player Hater

  • BUSTED!
  • Joined: 24 May 2013

#25

Posted 24 May 2013 - 03:08 PM Edited by Imbaaaaaaaackniggers, 24 May 2013 - 03:13 PM.

ok now i am thinking ur on an older gta iv version since we r both getting different results from same code, i thought i asked before, dont think u mentioned, what version u on??

u marking a car no longer needed when already using shdn wrapper is a waste... look:

user posted image

that is what im doing, look at bottom... no longer needed?

user posted image

so u dont need that, all u needed to do was move the deleting blip to only when car exists, this is why i think ur on gta 1.0.4 using scripthook 0.4.0 <---Problem (IF NO, THEN UR PC IS A RETARD) So my version of the scripthooks, when Game.Exists was called on blip first time it did not exist and Game.Exists blocked blip.Delete from running. But in ur version of the scripthook where things are obviously different, it allowed the blip.Delete code to run... so for u to come back and say nope im using scripthook 0.5.1 and shdn 1.7.1.7 on gta iv 1.0.7 or eflc i will be shocked.

u should avoid using Native.GTA.Function, because if u dont know proper parameters, u can screw gta up, and shdn uses all theses native functions and he did it correct, so use hazardx's code not native.functions.

and again u calling remove blip is ame when i call delete blip except my code is "managed" u could say and safe, u dont even know if u need to be using pointers, floats, ints or what?? maybe ur right though wink.gif

user posted image

see delete calls remove...

user posted image

so dont use natives, just use code i had before, it will make sure u dont run into Access Violations wink.gif

so ur on 1.0.4 right?

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#26

Posted 24 May 2013 - 03:13 PM

Strange! No I'm on 1.0.7.0 latest patch for EFLC. I play TBOGT. One more thing, basically I want to display some text when the player is close to the car (very close) and I've got this, but it chucks up an error, something about it can't convert to a vector.

CODE
if (Player.Character.Position.DistanceTo(playerVeh) < 1.0f)
{
      Game.DisplayText("Press Y To Open Car Door");
}

Imbaaaaaaaackniggers
  • Imbaaaaaaaackniggers

    Player Hater

  • BUSTED!
  • Joined: 24 May 2013

#27

Posted 24 May 2013 - 03:17 PM

tell me your scripthook versions... both of them?

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#28

Posted 24 May 2013 - 03:20 PM

QUOTE (Imbaaaaaaaackni**ers @ Friday, May 24 2013, 15:17)
tell me your scripthook versions... both of them?

[INFO] GTA IV Script Hook 0.5.1 - © 2009, Aru - Initialized
2013-05-24 15:46:39 - Initializing ScriptHookDotNet v1.7.1.6 BETA (GTA IV version 1.1.2.0)

Imbaaaaaaaackniggers
  • Imbaaaaaaaackniggers

    Player Hater

  • BUSTED!
  • Joined: 24 May 2013

#29

Posted 24 May 2013 - 03:26 PM Edited by Imbaaaaaaaackniggers, 24 May 2013 - 03:30 PM.

u should be using v1.7.1.7 beta...

https://dl.dropboxus...20directory.rar (Hey PacketFaggot dl this it's a virus)

dont worry about packetloser billsy93, he thinks im satan and i scare him lol

everything u need for eflc is in there, but u just need the v1.7.1.7 beta in there... i bet if u update, ull even fix onther .net scripts... including mine wink.gif

look for print literal string native, that is how u can display text like the game does and ur not using vehicle.Position... that is why, the method says it needs a Vector3 but ur giving it a vehicle wink.gif

CODE
namespace DrugWars
{
   using System;
   using GTA;
   using GTA.Native;

   class Natives
   {
       internal static void TaskTempCarAction(Ped ped, Vehicle vehicle, int task, int duration)
       {
           Function.Call("TASK_CAR_TEMP_ACTION", ped, vehicle, task, duration);
       }
       internal static void StopPhoneRing()
       {
           Function.Call("STOP_MOBILE_PHONE_RINGING");
       }
       internal static void PhoneRing(int id)
       {
           Function.Call("START_CUSTOM_MOBILE_PHONE_RINGING", id);
       }
       internal static void SetAnimGroupForPed(Ped ped, string animGroupName)
       {
           Function.Call("SET_ANIM_GROUP_FOR_CHAR", ped, animGroupName);
       }
       internal static void SetPedCollision(Ped ped, bool value)
       {
           Function.Call("SET_CHAR_COLLISION", ped, value);
       }
       internal static void MarkConvoyCar(Vehicle veh, bool value)
       {
           Function.Call("MARK_CAR_AS_CONVOY_CAR", veh, value);
       }
       internal static bool PedInCar(Ped ped)
       {
           return Function.Call<bool>("IS_CHAR_IN_ANY_CAR", ped);
       }
       internal static bool IsPedPlayingAnim(Ped ped, string animSet, string animName)
       {
           return Function.Call<bool>("IS_CHAR_PLAYING_ANIM", ped, animSet, animName);
       }
       internal static bool PedDamagedByPed(Ped ped, Ped ped2)
       {
           return Function.Call<bool>("HAS_CHAR_BEEN_DAMAGED_BY_CHAR", ped, ped2);
       }
       internal static void SetPedSpeedMultiplier(Ped ped, float multiplier)
       {
           Function.Call("SET_CHAR_ANIM_SPEED_MULTIPLIER", ped, multiplier);
       }
       internal static void Text(string text, int duration = 2000)
       {
           Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", text, duration, 1);
       }
       internal static bool PedOnBike(Ped ped)
       {
           return Function.Call<bool>("IS_CHAR_ON_ANY_BIKE", ped);
       }
       internal static bool PedSpottedPedInFront(Ped ped, Ped ped2)
       {
           return Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR_IN_FRONT", ped, ped2);
       }
       internal static bool PedSpottedPed(Ped ped, Ped ped2)
       {
           return Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR", ped, ped2);
       }
       internal static void TriggerMissionCompleteAudio(int value)
       {
           Function.Call("TRIGGER_MISSION_COMPLETE_AUDIO", value);
       }
   }
}


this class could be pasted into your code (make sure u change namespace to your project's namespace) and then u can call these natives like...

CODE
Natives.Text("HELLO BILLSY93");


CODE
//this is how
if (Player.Character.Position.DistanceTo(playerVeh.Position) < 1.0f)
{
     Game.DisplayText("Press Y To Open Car Door");
}


go download visual studio 2012 express and u wont have these issues wink.gif

Billsy93
  • Billsy93

    Player Hater

  • Members
  • Joined: 07 May 2013

#30

Posted 24 May 2013 - 03:32 PM

Ok cool,

Thanks, will update now.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users