Quantcast

Jump to content

» «
Photo

Need Help Making Client Side Mods [FiveM]

No replies to this topic
kuhny1
  • kuhny1

    Player Hater

  • New Members
  • Joined: 19 Dec 2017
  • United-States

#1

Posted 19 December 2017 - 02:56 PM Edited by kuhny1, 19 December 2017 - 03:02 PM.

Hi all. I have recently gotten into scripting for GTA, and i play on my own FiveM server with my brother. Ive been coding for quite sometime but the only modding to GTA i have ever done was changing meta files. Now i want to try script hook scripting, After having spent 7 hours straight trying to get visual studio to work with script hook i finally made a simple script that finds the nearest vehical to the player and blows it up. Scripthook.NET worked almost instantly when setting it up. However, FiveM doesnt work with .Net mods anymore, and thats what i want to mod, to add some things to do in the server. Currently, im only interested in client side mods. I have gotten some mods to work that are only scripthook and they are vehicalJetpack, lambda menu, and simple trainer. However when i put my mod in FiveM it only seems to find work when i disconnect.

 

Now those mods i have said are obviously not designed to work with fiveM, but something they did with their code, makes them work. And thats what im trying to figure out.

 

Basically, i think ive narrowed it down to having a problem of finding the player. See the mod works just fine in single player. I have no idea how the jet pack mod works in FiveM. I mean it would need to keep track of the vehicle and edit its rotation and position. And thats what i need is position of either either the player itself, or the vehicle the player is in. Here is my code, ill comment what i can.

 

I know posting the entire code wasnt really necessary, but i know from other forums some people want to see it all.

 

Edit: just realized that this is in the wrong section, im trying to find a way to delete this and move it to coding

#include "script.h"
#include "keyboard.h"

void update_features()
{
	

	

	
}
//the draw text function doesnt work as i expect, i cant figure out how to set notifications with regular script hook yet
void draw_text(char* text, float x, float y, int scale) {
	UI::SET_TEXT_FONT(1);
	UI::SET_TEXT_SCALE(scale, scale);
	UI::SET_TEXT_COLOUR(255, 255, 255, 255);
	UI::SET_TEXT_WRAP(0.0, 1.0);
	UI::SET_TEXT_CENTRE(false);
	UI::SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0);
	UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);
	UI::_SET_TEXT_ENTRY("STRING");
	UI::_ADD_TEXT_COMPONENT_STRING(text);
	UI::_DRAW_TEXT(y, x);
}

//booleans for toggling the mod
BOOL toggle = false;
bool hasReleased = true;
void main()
{

	while (true)

	{


		if (IsKeyDown(VK_DELETE) && hasReleased) { //when delete is pressed set toggle equal to the opposite of the current state if the key has been released before

			toggle = !toggle;
			hasReleased = false;
			
		}

		if (IsKeyJustUp(VK_DELETE) && hasReleased == false) { //set released equal to true so the mod can be turned back on

			hasReleased = true;
			


		}
		if (toggle) { //if mod (toggle=true) is active

			draw_text("1", 1000, 1000, 10);//draw text to the UI, doesnt work in single player or fiveM...

			Ped playerPed = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(playerPed); //get the players Ped
			
			if (PED::IS_PED_SITTING_IN_ANY_VEHICLE(playerPed)) { //detect if we are in a vehical

				Vector3 vehiclePosition = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PED::GET_VEHICLE_PED_IS_IN(playerPed, true), 0.0, 0.0, 0.0); //get the position of the vehicle the player is in. This was to test if getting the postion of the vehicle would change anything. It didn't, nothing changed

				Vehicle closestVehical = VEHICLE::GET_CLOSEST_VEHICLE(vehiclePosition.x, vehiclePosition.y, vehiclePosition.z, 15, 0, 70); //find the closest vehicle within a radius of 15 centered around the vehicle position
				VEHICLE::EXPLODE_VEHICLE(closestVehical, true, false); //blow it up
			}
			

		}
		else
		{
			draw_text("0", 1000, 1000, 10); // again, doesnt work
		}
		
		WAIT(1); 


		



			
		}
	}


void ScriptMain()
{
	srand(GetTickCount());
	main();
}




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users