Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
MadthatModsareDisabled

Using C++ for modding

Recommended Posts

sjaak327

Wh does it seem like you are ignoring me ?

 

 

    static void PrintStringWithLiteralStringNow(const char* gxt, const char* text, u32 ms, u32 unknown1) { NativeInvoke::Invoke<scriptVoid>("PRINT_STRING_WITH_LITERAL_STRING_NOW", gxt, text, ms, unknown1); }

 

 

So the code you posted isn't going to work, as you're trying to pass floats for positions, where it actually expects a u32 for milliseconds and a bool for the last parm...

 

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

I'm not ignoring you I'm just confused by how GTA IV looks at functions and other things.

 

The next thing I'm trying to tackle is I'm trying to understand what this function does?

 

 

 

void CustomFiberThread::SpawnObject(eModel model){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}LogInfo("request model");Ped ped = GetPlayerPed();Object object;f32 x, y, z; // x = left/right position, y = forward/backward pos, z = height of the object (how long it will be)// Locating x,y coordinates//(p1 = x + x1);//(p2 = y + y1 + 2);//(p3 = z);GetCharCoordinates(ped, &x, &y, &z - 8); // z + 140 y = position relative to player. Neg puts ramp in front of playerCreateObject(model, x, y + 5, z - 8, &object, true); // z - 40, y-80 testing valuesMarkModelAsNoLongerNeeded(model);}

 

 

For example when I called the function SpawnObject(MODEL_COMET):

 

How is the MODEL_COMET read by the compiler? I don't think its a character since I get an error when I try to insert an array inside, like this:

 

 

SpawnObject(mod[ObjectX]);

 

 

Here's how its listed in the CustomFiberThread.h:

 

 

 

private: enum eStateMachine{ StateDefault, count,};eStateMachine m_State;Scripting::Player GetPlayer();Scripting::Ped GetPlayerPed();void SpawnCar(Scripting::eModel model);void ChangePlayerSkin(Scripting::eModel model);   void TeleportToWaypoint(Scripting::Ped &ped);void SpawnObject(Scripting::eModel model);

 

 

So what is an eModel? This is very confusing? dontgetit.gif

 

When I run my program (listed above), I get this error message:

 

2>Main.cpp

3>c:\gta4_script_hookc\103\samplecustomfiber\customfiberthread.cpp(195) : error C2664: 'CustomFiberThread::SpawnObject' : cannot convert parameter 1 from 'char [38]' to 'Scripting::eModel'

3> There is no context in which this conversion is possible

 

Any help would be appreciated guys. smile.gif

 

 

 

 

 

void CustomFiberThread::RunScript(){int ObjectX = 1;char str1[300];char str2[300];char mod[][38] = { "MODEL_CJ_BARRIER_10B", "MODEL_CJ_BARRIER_11","CJ_TREE_TRUNKS","CJ_AB_RITZ_PILLER1" ,"CJ_AB_RIT_S_PILLAR2","CJ_AB_SOPWIN1","CJ_ARROW","CJ_COM_COUCH_1","CJ_BAG_TABLE","CJ_BAGUETTE" };//char str1[20] = "MODEL_CJ_BARRIER_10B"; // This is a fiber thread, so we use an loop to run the contents of this script.// The thread will terminate when we return from this function.// Will create a option to cycle through objects later by repeating an F5 press// Setup an array (enum) to accomplish this task.while(IsThreadAlive()){       if ((GetAsyncKeyState(VK_F5) & 1) != 0)       {           LogInfo("Teleporting player to way point"); 	//PrintStringWithLiteralStringNow("CP_MAX_1", "Spawning the MODEL_CJ_FENCE_1_1", 7500, 1);     	sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]); 	PrintStringWithLiteralStringNow("STRING", str1, 6000, 1); // this will make it appear in the top left part of the screen           //TeleportToWaypoint( GetPlayerPed() ); 	ObjectX +=1; 	if (ObjectX > 9) 	{   ObjectX = 1; 	} 	//sprintf_s(str2,300,"Object X %s", ObjectX); 	//PrintStringWithLiteralStringNow("STRING", str2, 6000, 0.1f); 	SpawnObject(mod[ObjectX]);}

 

Share this post


Link to post
Share on other sites
Hergonan

Ohh I didn't see it was PrintStringWithLiteralStringNow, sorry. I was actually referring to the other function which asked for float positions.

 

Also, MODEL_COMET is the representation of the integer model id (shortly, an eModel).

It's probably in scripting_enums.h

Spawncar gets the enum and places it in the native to create a car at player's position.

Using a string for it will not work. "MODEL_COMET" is just a string, but MODEL_COMET is an integer (as an enum for the eModel list)

Share this post


Link to post
Share on other sites
sjaak327

That function is using enumeration, look in the scriptingenums files in scripthook, they are using model names, that translate to hex model hashes.

 

MODEL_COMET for instance actually translates to hex model hashes, (you can also pass decimal hash by the way), it just makes it easier.

 

to disable the enumeration and be able to pass decimal model hashes, change the emodel to u32, of course you need to pass valid model hashes, or the game will crash smile.gif

 

Edited by sjaak327

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

That function is using enumeration, look in the scriptingenums files in scripthook, they are using model names, that translate to hex model hashes.

 

MODEL_COMET for instance actually translates to hex model hashes, (you can also pass decimal hash by the way), it just makes it easier.

 

to disable the enumeration and be able to pass decimal model hashes, change the emodel to u32, of course you need to pass valid model hashes, or the game will crash

 

 

*********************************************************************************************************************

 

Okay alot of that just went over my head. lol. dontgetit.gif

 

I understand that enumerations increment one value by the next 1,2,3,4,5, etc

 

But if I change the program enumeration list in Scriptingenums (to enum eModel u32) then what did you mean by passing valid model hashes (to prevent the game from crashing)? dontgetit.gif

 

I'm a newbie, but I'm willing to learn. confused.gifsmile.gif

 

 

I'm making progress thanks to your help. biggrin.gifsmile.gif

Share this post


Link to post
Share on other sites
Intosia

A model hash is just hex value like 0x12345 or something... It must be valid (know to the game)...

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Thanks for the feedback. Yet again how do I implement this into the game?

 

Can somebody please provide a code example so I can better understand this and work it into the program, just so I can see different objects when I am repeatedly pressing F5?

 

If possible could you work off my code (shared) please?

 

 

void CustomFiberThread::RunScript(){int ObjectX = 1;char str1[300];char str2[300];char mod[][38] = { "MODEL_CJ_BARRIER_10B", "MODEL_CJ_BARRIER_11","CJ_TREE_TRUNKS","CJ_AB_RITZ_PILLER1" ,"CJ_AB_RIT_S_PILLAR2","CJ_AB_SOPWIN1","CJ_ARROW","CJ_COM_COUCH_1","CJ_BAG_TABLE","CJ_BAGUETTE" };//char str1[20] = "MODEL_CJ_BARRIER_10B"; // This is a fiber thread, so we use an loop to run the contents of this script.// The thread will terminate when we return from this function.// Will create a option to cycle through objects later by repeating an F5 press// Setup an array (enum) to accomplish this task.while(IsThreadAlive()){       if ((GetAsyncKeyState(VK_F5) & 1) != 0)       {           LogInfo("Teleporting player to way point"); 	//PrintStringWithLiteralStringNow("CP_MAX_1", "Spawning the MODEL_CJ_FENCE_1_1", 7500, 1);     	sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]); 	PrintStringWithLiteralStringNow("STRING", str1, 6000, 1); // this will make it appear in the top left part of the screen           //TeleportToWaypoint( GetPlayerPed() ); 	ObjectX +=1; 	if (ObjectX > 9) 	{   ObjectX = 1; 	} 	sprintf_s(str2,300,mod[ObjectX]); 	//PrintStringWithLiteralStringNow("STRING", str2, 6000, 0.1f); 	SpawnObject(str2);

 

 

As listed so far. I just need to know what to do with SpawnObject(str2);

 

In other words what example can I use to get the game to show a different object each time the F5 is pressed?

 

Thanks always guys. You will be included in any credits if I decide to upload this mod later. smile.gif

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Hey guys thanks for all the help and direction. I finally figured out what to do.

 

By looking at the enums list, I found an example. Therefore I changed it to this:

 

 

 	RequestModel( GetModelHash(mod[ObjectX]) ); 	SpawnObject(GetModelHash(mod[ObjectX]));

 

 

Suddenly I was cycling through the objects. Amazing! It was working. However it still crashes if I go through too many objects. dontgetit.gif

 

Oh well progress is happening. smile.gif

Share this post


Link to post
Share on other sites
Hergonan

This reminds me of my young programming days!

To cycle through a list of objects, make an array or vector.

In the vector, hold the actual numbers of the models.

So, when you press a button, increment an integer (starting from zero), and get the array index to the actual ID of the model (yeah, sounds complicated...)

let's say you have an array Arr and it has 50 model ids inside.

 

pseudocodehere:

 

int cur = 0;...void updateFunction(){   if(F5Pressed()){      cur++;      spawn(Arr[cur]);   }}

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

I can't figure out why now the game keeps crashing after I cycle through a few objects. Code as listed: nervous.gifdontgetit.gif

 

 

void CustomFiberThread::RunScript(){int ObjectX = 0;char str1[300];char str2[300];char mod[][38] = { "CJ_BARRIER_10B", "CJ_BARRIER_11","CJ_TREE_TRUNKS","CJ_AB_RIT_S_PILLAR", "CJ_AB_RITZ_PILLER1","CJ_AB_RIT_S_PILLAR2","CJ_AB_SOPWIN1","CJ_ARROW","CJ_COM_COUCH_1" ,"CJ_BAG_TABLE","CJ_BAGUETTE","CJ_AIRCON10","CJ_BEDROOM1_W","CJ_BEER_TABLE_1","CJ_BENCH" ,"CJ_BFAST_J_2"};//char str1[20] = "MODEL_CJ_BARRIER_10B"; // This is a fiber thread, so we use an loop to run the contents of this script.// The thread will terminate when we return from this function.// Will create a option to cycle through objects later by repeating an F5 presswhile(IsThreadAlive()){       if ((GetAsyncKeyState(VK_F5) & 1) != 0)       {           LogInfo("Teleporting player to way point"); 	//PrintStringWithLiteralStringNow("CP_MAX_1", "Spawning the MODEL_CJ_FENCE_1_1", 7500, 1);     	//sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]); 	//PrintStringWithLiteralStringNow("STRING", str1, 6000, 1); // this will make it appear in the top left part of the screen           //TeleportToWaypoint( GetPlayerPed() ); 	ObjectX +=1; 	if (ObjectX > 15) 	{   ObjectX = 1; 	} 	sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]); 	PrintStringWithLiteralStringNow("STRING", str1, 6000, 1); // this will make it appear in the top left part of the screen	 	sprintf_s(str2,300,mod[ObjectX]); 	//PrintStringWithLiteralStringNow("STRING", str2, 6000, 0.1f); 	//SpawnObject(str2); 	RequestModel(GetModelHash(mod[ObjectX])); 	SpawnObject(GetModelHash(mod[ObjectX]));}

 

 

What am I doing wrong?

 

Thanks again for any help. smile.gif

Share this post


Link to post
Share on other sites
Hergonan

yeah, you're using char[][], I never used that. why not use strings?

Share this post


Link to post
Share on other sites
Shadow-Link

You need to check if the model is available after request model.

 

Search for the native and add it like this:

 

 

RequestModel(//model);while(!modelAvailable(//model)) {Wait(100);}SpawnObject(//model);

 

Share this post


Link to post
Share on other sites
Intosia

lol

 

ObjectX +=1;

 

is

 

ObjectX++; // increment by 1

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Yeah I know I'm old school. Keep in mind though I started programming in 1986 on an Atari 65xe computer. Basic was my first love. Then I moved on to assembly language. That is why I still code like that.

 

However I don't believe I need to request if the model is available since that is what the function below does when I use:

 

 

SpawnObject(GetModelHash(mod[ObjectX]));

 

 

The function is listed here:

 

 

 

void CustomFiberThread::SpawnObject(eModel model){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}LogInfo("request model");Ped ped = GetPlayerPed();Object object;f32 x, y, z; // x = left/right position, y = forward/backward pos, z = height of the object (how long it will be)GetCharCoordinates(ped, &x, &y, &z - 8); // z + 140 y = position relative to player. Neg puts ramp in front of playerCreateObject(model, x, y + 5, z - 8, &object, true); // z - 40, y-80 testing valuesMarkModelAsNoLongerNeeded(model);}

 

 

So as a visual example what I am doing is using SpawnObject(GetModelHash(mod[ObjectX])) to search my char array list:

 

 

char mod[][38] = { "CJ_BARRIER_10B", "CJ_BARRIER_11","CJ_TREE_TRUNKS","CJ_AB_RIT_S_PILLAR", "CJ_AB_RITZ_PILLER1","CJ_AB_RIT_S_PILLAR2","CJ_AB_SOPWIN1","CJ_ARROW","CJ_COM_COUCH_1" ,"CJ_BAG_TABLE","CJ_BAGUETTE","CJ_AIRCON10","CJ_BEDROOM1_W","CJ_BEER_TABLE_1","CJ_BENCH" ,"CJ_BFAST_J_2"};

 

 

to see if one of these objects is available already. I know that happens since I can already spawn these objects in order.

However after I reach about the 9th or so object the game freezes. I think there is a deeper problem somewhere else.

 

Any suggestions? Thanks. smile.gif

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Also I'm having another problem. sad.gif

 

I tried testing these mods in Free Mode, but nobody could see them?

 

Anybody know why that is? dontgetit.gif

 

This is getting more and more complicated. confused.gif

Share this post


Link to post
Share on other sites
sjaak327

Ah using the edited scripthook smile.gif

 

you are trying to spawn objects, some objects crash the game, no matter what you do, so I suggest you check each object that you've included into your array.

 

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

If some objects crash the game then why can I still see them? bored.gifdontgetit.gif

Share this post


Link to post
Share on other sites
Intosia

"Mods in Multiplayer are not allowed"

 

So i dont think we should discuss this in the first place catspider.gif

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Hey guys,

 

I got it working perfectly now. biggrin.gif The next thing I am working on is creating an internal loop inside the F5 routine.

 

What are the GetKeys for the arrow keys? Thanks, as always it is very appreciated.

 

As an example here is the function call to check for an F5 key press:

 

 

if ((GetAsyncKeyState(VK_F5) & 1) != 0)

 

 

So how do I change this to check for the up, down, left, and right arrow keys? Does anybody also know where I can get a list of the key codes to implement in this mod?

 

Also with all due respect, please don't respond to this post if you are not helping with the programming. I'm getting some haters here. confused.gif

Please understand it is not beneficial to people who want to learn tips on C++ also. bored.gif

 

 

Thanks again. smile.gif

Edited by MadthatModsareDisabled

Share this post


Link to post
Share on other sites
sjaak327

#define VK_LEFT 0x25

#define VK_UP 0x26

#define VK_RIGHT 0x27

#define VK_DOWN 0x28

 

from winuser.h

 

when you're in visual studio, highlight the vk_f5 and right click, go to definition, and it will bring you in winuser.h, where most keys are defined for you already

 

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Excellent sjaak, biggrin.gif

 

Does this work with the #include <windows> file?

 

Appreciate it much indeed. smile.gif

Share this post


Link to post
Share on other sites
sjaak327

Yep if not already there put this in your includes:

 

#include <windows.h>

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Why is that sometimes other people can't see objects I spawn even though I can.

 

Keep in mind that sometimes they can see them and sometimes they can't.

 

Here's my spawn code below:

 

 

void CustomFiberThread::RunScript(){int ObjectX = 0;int PedObjectX = 0;char str1[300];char str2[300];char str3[300];char str4[300];char mes1[300]; 	// CJ_TREE_TRUNKS - long logs 	// CJ_AB_RIT_S_PILLAR - construction pillar 	// CJ_AB_RITZ_PILLER1 - small historical(greek) pillar 	// CJ_AB_RIT_S_PILLAR2 - small grey pillar 	// CJ_AB_RITZ_PILLER2 - long tall post (size of a small telephone pole) 	// CJ_AB_SOPWIN1 - small window 	// CJ_APPLE_1 - eaten apple core 	// CJ_ARROW - black/grey arrow pointing down (non physical) 	// CJ_B_CAN1 - small can 	// CJ_COM_COUCH_1 - black/grey couch (leather) 	// CJ_BAG_TABLE - table with purses on it 	// CJ_BAGUETTE - long sandwich 	// CJ_BAN - banana peel//char mod[][38] = { "MODEL_CJ_BARRIER_10B", "MODEL_CJ_BARRIER_11","MODEL_CJ_TREE_TRUNKS","MODEL_CJ_AB_RIT_S_PILLAR",//"MODEL_CJ_AB_RITZ_PILLER1","MODEL_CJ_AB_RIT_S_PILLAR2","MODEL_CJ_AB_SOPWIN1","MODEL_CJ_ARROW","CJ_COM_COUCH_1"//,"CJ_BAG_TABLE","CJ_BAGUETTE","CJ_AIRCON10","CJ_BEDROOM1_W","CJ_BEER_TABLE_1","CJ_BENCH"//,"CJ_BFAST_J_2"};char mod[][38] = { "CJ_AB_PANRACK","CJ_AB_RIT_S_PILLAR","CJ_AB_RIT_S_PILLAR2","CJ_AB_SOPWIN1","CJ_AB_SOPWIN2" ,"CJ_AB_SOPWIN3","CJ_ARROW","CJ_COM_COUCH_1" ,"CJ_AB_RITZ_PILLER1","CJ_AB_RITZ_PILLER2","CJ_BAG_TABLE","CJ_AIRCON10","CJ_BEDROOM1_W","CJ_BEER_TABLE_1","CJ_BENCH" ,"CJ_AB_RITZ_PILLER1","CJ_BFAST_J_2","CJ_BARRIER_5","CJ_BILLBRD_1A","CJ_BM_PHONE1","CJ_CHAIR_7","CJ_COMP2_GATE_L" ,"CJ_BILLBRD_1A","CJ_BEDROOM1_W","CJ_BOAT_SURROUND","CJ_CAGE_3","CJ_CARPET_DIRT","CJ_CHINA_GLASS1","CJ_DUMPSTER_1" ,"CJ_FRIDGE_3","CJ_IND_WASHER_5","CJ_IND_WOODPILE_1","CJ_INT_DOOR_12_H","CJ_JOJO_BOX1","CJ_KITCH_1_SINK","CJ_OLD_BOAT_1" ,"CJ_PROC_BRICK3","CJ_SCAFFOLD_03","SCAFFOLD_6","CJ_SHOWER","CJ_CYLINDER","CJ_DM_ARCWAY"};char pedes[][38] = {"CJ_GAME_CUBE_1","CJ_GAME_CUBE_2","CJ_GAME_CUBE_3","CJ_GAME_CUBE_4","CJ_GAME_CUBE_5","CJ_GAME_CUBE_6" ,"CJ_GAME_CUBE_C1","CJ_GAME_CUBE_C2","CJ_GAME_CUBE_C3","CJ_GAME_CUBE_C4","CJ_GAME_CUBE_C5" ,"CJ_GAME_CUBE_C6"};//char str1[20] = "MODEL_CJ_BARRIER_10B"; // This is a fiber thread, so we use an loop to run the contents of this script.// The thread will terminate when we return from this function.// Will create a option to cycle through objects later by repeating an F5 press// Setup an array (enum) to accomplish this task.//***********************************************************************************// Later setup  an option so users can scroll through objects and press a key when they// want to spawn that object alone. (an internal loop inside F5)while(IsThreadAlive()){       if ((GetAsyncKeyState(VK_F5) & 1) != 0)       {           LogInfo("Teleporting player to way point"); 	PrintStringWithLiteralStringNow("STRING", "Press the space bar to spawn object", 7500, 1);     	//sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]); 	//PrintStringWithLiteralStringNow("STRING", str1, 6000, 1); // this will make it appear in the top left part of the screen           //TeleportToWaypoint( GetPlayerPed() ); 	 	//if ((GetAsyncKeyState(VK_SPACE) & 1) !=0) 	//{	   sprintf_s(mes1,300,"Spawning the %s", mod[ObjectX]);   PrintStringWithLiteralStringNow("STRING", mes1, 6000, 1);   ObjectX +=1;   if (ObjectX > 42)   {   	ObjectX = 1;   }   sprintf_s(str1,300,"Spawning the %s", mod[ObjectX]);   PrintStringWithLiteralStringNow("STRING", str1, 6000, 1);   sprintf_s(str2,300,mod[ObjectX]);   SpawnObject(GetModelHash(str2));

 

 

Its not complete, I just wanted you to see how I'm using the spawn function.

 

 

sprintf_s(str2,300,mod[ObjectX]);

SpawnObject(GetModelHash(str2))

 

 

The modObject invokes the character string to point at the present object. I used this since I couldn't figure out how to link to the enumeration list in the ScriptingEnums header file.

 

My next challenge is to figure out how a Ped spawner works. Anybody got an ideas for that one?

 

Thanks smile.gif

Share this post


Link to post
Share on other sites
ceedj
My next challenge is to figure out how a Ped spawner works. Anybody got an ideas for that one?

I'd look at the car spawner code in the example provided. While I needed a bit of help for my particular scenario - scrolling through peds numerically needed my own enum to pass text between aru's enum and my code - most of what I needed was right in the car code.

 

You might also consider looking into how the natives work by looking at some SCO files with MagicIV. The scripting is mostly the same as the III-SA games were, with some extras tossed in. For me, understanding the way the scripting itself worked helped to put it to better use in a different language, in this case C/C++.

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

True because I am trying to balance the scales between how C++ does something and how the game does another. I will look into Native names later. Lol. I'm having too much fun playing the game already.

 

Also does anybody know how to delete objects? I'm getting alot of complaints about this. I want to show an object and delete it later.

 

If possible could you provide a code sample.

 

Again as always it is appreciated. This is open source and also to anyone who wants to see my code vice versa. smile.gif

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

I've been searching Open IV for some time now, but I can't find any SCO files.

 

What folder are they located in?

Share this post


Link to post
Share on other sites
sjaak327

do you ever search in scripting.h or scriptingdirty.h

 

deleteobject(&object);

 

I guess you released what you've made ?

 

sco files are in the scripts.img container.

 

 

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Hi guys. colgate.gif

 

I will release code freely to anyone who asks. I only hope that that person doesn't take advantage of someone else during Multiplayer (since I never do that).

 

My main objective for designing a mod is to have fun with other modders. Bang heads together to get new ideas. As an example I saw someone earlier flying a plane around at the airport. After I connected with this person, I learned that it was really the Annihilator in disguise (clever).

 

Yes I have looked at both Scripting.h and ScriptingDirty.h.

 

I'm just learning things by asking (and also experimenting with different functions, etc).

 

From what I'm learning however, not all the functions perform well.

 

I'm also finally looking at the SCO files. Lol. I fell asleep scanning some of the levels of code. Seems like pretty complicated stuff. There are alot of sub_ type calls. I don't know what these do. Basically I search around and try to find something familiar (as what is in CustomerFiberThread.cpp.

 

 

It would be really awesome if either Aru or somebody put together a large tutorial on how to code for GTA IV. Kinda like, break it down piece by piece. As an example: smile.gif

 

 

Teleportation: code examples. Good comments in the code.

Car spawning: code example, etc

 

You get the picture. For now though I'm left with scanning Gtaforums relentlessly and posting these questions to gain a deeper insight into how alot of things are done. It's exhausting. suicidal.gif

 

The main thing I still am stuck on is I can't find any examples of how to create menus. I've also been reading my C++ book and still haven't run into any good examples (although I am learning plenty).

 

An example of this is there is a mod called ThousandTugs.asi. It uses good menu examples, but I don't know how yet to work these into my code. I imagine it is setup in a switch statement or nested if's.

 

Does anybody know where I can find good examples of how to build menus? This would be alot of help and save me alot of trouble scanning these forums hour after hour. dontgetit.gif

 

Again I appreciate everyone's feedback. Hope I am responding to your questions well enough.

 

If anyone wants to swap code, I am also open for that.

 

Keep modding alive. Thanks guys. smile.gif

Share this post


Link to post
Share on other sites
MadthatModsareDisabled

Okay I've been working on the Delete object spawner and this is as close as I can get it working, but the game still crashes. confused.gif

 

First my function:

 

 

void CustomFiberThread::DeleteObject(eModel model){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}Ped ped = GetPlayerPed();Object obj;f32 x, y, z;GetCharCoordinates(ped, &x, &y, &z + 8);CreateObject(model, x, y + 5, z + 8, &obj, true); // z - 40, y-80 testing valuesMarkModelAsNoLongerNeeded(model); }

 

 

Below is the call in the decision loop:

 

 

 else if ((GetAsyncKeyState(VK_SPACE) & 1) != 0) { 	LogInfo("Deleting last object"); 	PrintStringWithLiteralStringNow("STRING", "Deleting last object",7500,1); 	sprintf_s(str5,300,mod[ObjectX]); 	DeleteObject(GetModelHash(str5)); }

 

 

 

Etc

 

It still seems to be having a problem with the DeleteObject(GetModelHash(str5)); dontgetit.gif

 

 

Below is the actual static function for DeleteObject as listed in Scripting.h

 

 

static void DeleteObject(Object *pObj) { NativeInvoke::Invoke<scriptVoid>("DELETE_OBJECT", pObj); }

 

 

Perhaps I'm just misunderstanding functions again? If not does anybody have any suggestions how I can get this working? The next obstacle to tackle will be deleting every object I spawn. I'm thinking an array might be good to store the x,y,z

positions.

 

What do you guys think? smile.gif

Share this post


Link to post
Share on other sites
sjaak327

you need to delete the object using object id, not model hash !

 

When you do creatobject (blahblahblah, you pass a reference to the object &object). This object should also be used to delete the object, build an array for all objects you spawn, and then you can delete them all, no need to store x,y,z postions, store the object id's to an array.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.