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. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    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

nrv74

Last help request to complete a mod... PLEASE !

Recommended Posts

nrv74

 

It seems to me that at least one of the bikes has to remain in the shop otherwise the whole lot of them respawn.

That is kind of strange....

Share this post


Link to post
Share on other sites
Erem

...and very annoying.

 

Having one bike left isn't ideal, but I'm running out of ideas.

 

Ignore what I said about there sometimes being nine bikes. It just happened again and I can see what happened: my code detected and moved the same bike twice! I think I've fixed that now.

Share this post


Link to post
Share on other sites
nrv74

Yes, wouldn' t be perfect, but would be good enough if the one is the closest to the shop door. So the seven remaining spawn on the top of the carpark?

Share this post


Link to post
Share on other sites
Erem

I don't know anymore. Now they respawn even when I leave one behind. Maybe it occasionally takes longer to respawn and I just didn't wait long enough the time I thought it had worked?

 

What you really need, I think, is a way to turn off or delete that spawn point. If you could do that, you could delete the bikes with CLEAR_AREA_OF_CARS and they'd stay deleted. It might be worth you starting another thread asking how to remove a spawn point.

 

I'll keep trying to see if I can find something that works, but I probably need to take a break from it for now and come at it again afresh.

Share this post


Link to post
Share on other sites
nrv74

okay thanks again for trying.

have a good break wink.gif

Share this post


Link to post
Share on other sites
nrv74

I' m wondering if creating a loop wouldn' t be a good solution.....

I' ve just remembered, when I was inside the shop, with my 30 bikes spawned, and the other 7 or 8 still inside to, I was using the 5.3 native trainer to delete cars iside the radius I defined, and it deleted only the old bikes(well, they respawned immediately, but it didn't removed anyone of mines even for a second......

Tell me what do you think about that, so I will search how to create a loop with that function wink.gif

Share this post


Link to post
Share on other sites
Erem

 

I' ve just remembered, when I was inside the shop, with my 30 bikes spawned, and the other 7 or 8 still inside to, I was using the 5.3 native trainer to delete cars iside the radius I defined,  and it deleted only the old bikes(well, they respawned immediately, but it didn't removed  anyone of mines even for a second......

Hmm... that's interesting. A loop may be a solution then.

 

I've been working on a different approach. I don't want to raise false hope again, but I may be on to something...

 

If I manually move all of the bikes just outside the shop (i.e. by stealing each one), they don't respawn. I'm now trying to do the same thing in the script but finding the correct parameters for GET_RANDOM_CAR_IN_SPHERE is taking a lot of trial and error.

 

This is showing promise:

function RemoveBikes() local bike = {} for i = 1, 8 do   GET_RANDOM_CAR_IN_SPHERE(itof(-1078), itof(1466), itof(24.31), itof(13), itof(4), itof(2), bike)   if (DOES_VEHICLE_EXIST(bike.a) == 1) then     SET_CAR_COORDINATES(bike.a, itof(-1090 + (i * 2)), itof(1458), itof(24.31))     SET_CAR_HEADING(bike.a, itof(190 + math.random(10)))     SET_VEH_ALARM(bike.a, 1)   end   Wait(10) endend

The idea is to move each bike just outside the south window of Westdyke Autos and align them along the pavement (the one where the hotdog vendor is). Currently it re-detects the 5th bike it moves and shifts it along the pavement, leaving 3 still inside the shop, but I'm hoping I can find the right values to stop that happening.

 

By the way, I gave you some duff information on SET_CAR_HEADING before. The angle is measured anticlockwise from north, so an angle of 90 would face the vehicle west not east.

Share this post


Link to post
Share on other sites
nrv74

Wow, there is too many things I don' t understand in this function mercie_blink.gif but I hope you' ll make it !

Share this post


Link to post
Share on other sites
Erem

 

Wow, there is too many things I don' t understand in this function mercie_blink.gif but I hope you' ll make it !

for i = 1, 8 do

because we want to search for eight bikes

GET_RANDOM_CAR_IN_SPHERE

I now think the first three parameters are the centre of the sphere and the 4th is the radius. I haven't figured out what the 5th and 6th are. All I know is that if the 6th is 1.0, it doesn't find anything which makes no sense if it's the z radius and we're giving it the actual z coordinate to two decimal places. dontgetit.gif

if (DOES_VEHICLE_EXIST(bike.a) == 1) then

if a bike was found, execute the following lines (between if and end)

SET_CAR_COORDINATES

moves the bike outside the shop. 1st parameter is the vehicle handle for the bike. 2nd parameter is the x co-ordinate we want to move it to and is calculated by adding twice the bike number (1 - 8) to a base value of -1090. In other words, it spaces them evenly from west to east. 2nd and 3rd parameters are the y and z co-ordinates of the destination.

SET_CAR_HEADING

rotates the bikes to face slightly east of south. math.random(10) generates a number from 1 to 10 which is added to 190 to give the heading in degrees anti-clockwise from north. The slight randomness is just to make the placement of the bikes look more natural.

SET_VEH_ALARM

was intended to set the bike's alarm so that it goes off if you try to steal it, but it doesn't appear to be working. Do bikes have alarms?

end

The first one closes the if, the second ends the for loop, and the third marks the end of the function definition.

 

I've got 7 of the 8 bikes now, but testing has slowed down because Simple Native Trainer has stopped working for some reason and I can't teleport straight to the shop anymore.

Share this post


Link to post
Share on other sites
Erem

Eureka! One empty shop with a row of bikes outside:

user posted image

 

function RemoveBikes() local bike = {} for i = 1, 8 do   GET_RANDOM_CAR_IN_SPHERE(itof(-1069 - (i * 2)), itof(1466), itof(24.31), itof(6), itof(2), itof(2), bike)   if (DOES_VEHICLE_EXIST(bike.a) == 1) then     SET_CAR_COORDINATES(bike.a, itof(-1090 + (i * 2)), itof(1458), itof(24.31))     SET_CAR_HEADING(bike.a, itof(190 + math.random(10)))   end   Wait(10) endend

 

Share this post


Link to post
Share on other sites
nrv74

icon14.gif yeah, congratulations smile.gificon14.gif

 

So that won' t work if you move them too far from the shop, is that right?

 

Share this post


Link to post
Share on other sites
Erem

 

So that won' t work if you move them too far from the shop, is that right?

Seems that way.

 

Also if you move too far away from the area, everything will revert to how it was with those 8 bikes back in the shop and (most likely) none of your bikes to be seen.

 

What you'll need is some way to check when the player is a certain distance from the shop and then call the function to move the bikes out and restock it.

 

If the O in the following diagram represents the shop, you'll need to call the function whenever Niko enters the shaded area. I don't know how far from the shop the shaded area needs to be (a radar's width perhaps?) or how wide.

   ##### ##   ####     ###   O   ###     ## ##   ##  #####

 

I imagine you could see if the player was within the area by comparing the current x and y co-ordinates with the x and y cordinates in the middle of the shop. No need to worry about the z co-ordinate.

Edited by Erem

Share this post


Link to post
Share on other sites
nrv74

In fact, the thirty bikes I' ve placed are each times there, and MY bikes don' t let the other 8 spawn correctly, besides, those 8 nrg never spawns at the exact same coords, so that' s why sometimes there is 8 of them, sometimes only three.

 

The function you' ve made is to be placed under

 

function main()

 

or upper?

 

Share this post


Link to post
Share on other sites
Erem

That function should move the bikes wherever they spawn. Without going into too much detail, it was the fact that there were more on the left of the shop than on the right which was giving me headaches.

 

Call the function with RemoveBikes() in your main() function, immediately before you spawn anything of your own. Place the function itself before your main() function.

Share this post


Link to post
Share on other sites
nrv74

I really appreciate your work Erem, and I feel sorry for your headaches, I should have them lol.gif

Now I' ll have a good shop with plenty of pretty bikes well parked, thanks to you

Share this post


Link to post
Share on other sites
Erem

 

I really appreciate your work Erem, and I feel sorry for your headaches, I should have them  lol.gif

It was a good learning experience for me. And knowing someone was waiting for answers kept me focused on testing rather than playing! lol.gif

 

I've taken a look at your full script now, and you can make it much smaller by using a reusable function to create a single car/bike.

 

Your script should look something like this:

function SpawnVehicle(CarName, x, y, z, heading)  -- code to spawn a specific vehicle at the given co-ordinates with a given heading  local hash = GET_HASH_KEY(CarName)  REQUEST_MODEL(hash)  while HAS_MODEL_LOADED(hash) == 0 do Wait(100) end  local CarVar = {}  Wait(500)  CREATE_CAR(hash, itof(x), itof(y), itof(z), CarVar, true)  SET_CAR_HEADING(CarVar.a, itof(heading))  MARK_MODEL_AS_NO_LONGER_NEEDED(hash)  Wait(100)endfunction RemoveBikes()  -- my function as in the above postendfunction Bikeshop() -- no parameters needed  RemoveBikes()  -- multiple calls to SpawnVehicle  -- e.g. SpawnVehicle("YZRM1", 1091.31, 1462.23, 24.34, 315.01)endfunction main()  Wait(1000)   while true do  -- check how far player is from Westdyke Autos  -- if within certain distance, call Bikeshop()   Wait(1000)  endendmain();

 

You won't need the CLEAR_AREA_OF_CARS line nor my earlier RemoveBike function (but you will need RemoveBikes!)

 

I've not included it above, but your Grottishop function could take the same form as Bikeshop, calling SpawnVehicle a number of times with different parameters.

Edited by Erem

Share this post


Link to post
Share on other sites
nrv74

Okay, It will take time, but I think I can do it, and that will make me understand better how it works.

I will try not to harass you biggrin.gif

 

  -- check how far player is from Westdyke Autos -- if within certain distance, call Bikeshop() 

 

That I really don' t understand why. Can' t I do without?

Edited by nrv74

Share this post


Link to post
Share on other sites
Erem

 

  -- check how far player is from Westdyke Autos -- if within certain distance, call Bikeshop() 

 

That I really don' t understand why. Can' t I do without?

I'm not sure. If you don't include that check, you will be calling the Bikeshop function all the time - when the player is too far away from the shop to care what is in it, and when the shop is in sight and the player can see the vehicles being moved. Ideally, you only want to call it each time the player approaches the shop but while it is still far enough away for you not to notice the vehicles moving.

 

But the main reason for that check is if the function has already been called and the original 8 bikes are outside with yours inside, calling it again will most likely move eight of your vehicles outside, placing them on top of the bikes which, in effect, will be deleted, causing them to respawn back in the shop!

 

You could use CLEAR_AREA_OF_CARS in Bikeshop before RemoveBikes. That way (in theory) every vehicle in the shop (the original bikes and yours) would be deleted, the original 8 would respawn, RemoveBikes would teleport them outside, and then your own bikes would spawn again.

 

Having the shop constantly update like that would look odd, to say the least, but you could lessen the effect by increasing the Wait in your main function. Another option would be to check Niko's heading and only update the shop when he's looking the other way. It all depends what you're happy to live with and how much effort you want to put into making it look right.

Share this post


Link to post
Share on other sites
nrv74

Hummm... that' s too much for me... I don't even know which natives i 'd have to use. And my brain restarts smokin', I didn' t manage to add your RemoveBikes function correctly, nothing works anymore, I think I' m dumb, or at least extremly ignorant suicidal.gif

Share this post


Link to post
Share on other sites
Erem
I didn' t manage to add your RemoveBikes function correctly, nothing works anymore, I think I' m dumb, or at least extremly ignorant suicidal.gif

lol.gif Ok, PM me what you have again and I'll take another look at it.

Share this post


Link to post
Share on other sites
Erem

 

Hummm... that' s too much for me... I don't even know which natives i 'd have to use.

Another alternative is that you activate the function with a keypress - which is what I was doing while testing it:

function main()  Wait(1000)  while true do   if (IsKeyPressed(18) == 1) and (IsKeyPressed(32) == 1) then -- Alt + Space     Bikeshop()   end   Wait(500)  endend

 

See Virtual Key Codes.rtf in your Alice\Dev\common files folder to change the key combination from Alt-Space to something else. Or there's a more complete list here:

http://www.gta-modding.it/iv/tut_en/iskeypressed.html

Edited by Erem

Share this post


Link to post
Share on other sites
nrv74

That way works fine once.

But when you get too far from the shop and then come back, you can see those nightmare' s NRG have respawned inside, so you re-press alt+space, but this time it will remove some of NRG and some of my bikes to, and my bikes won' t be deleted to be respawned inside if you go too far and then come back a second time, so if, at this point, you re-press a third time alt+space, you can imagine what happens... And maybe you have already checked it.

cryani.gif

I guess there isn' t a perfect solution except opening the game' s full script and find where the function that spawns these bikes is and delete it

suicidal.gif .

Must wait for a tool like a sanny builder for gta IV. I hope Mr Blade the great is working on...

 

Share this post


Link to post
Share on other sites
Erem

 

That way works fine once.

But when you get too far from the shop and then come back, you can see those nightmare' s NRG have respawned inside, so you re-press alt+space, but this time it will remove some of NRG and some of my bikes to, and my bikes won' t be deleted to be respawned inside if you go too far and then come back a second time, so if, at this point, you re-press a third time alt+space, you can imagine what happens... And maybe you have already checked it.

I'm not able to check anything at the moment. I'm having a few problems with my game such as really bad lag, repeating audio and SecureRom errors. sad.gif I'm hoping that's just because I'm running low on disk space.

 

Did you try this:

You could use CLEAR_AREA_OF_CARS in Bikeshop before RemoveBikes. That way (in theory) every vehicle in the shop (the original bikes and yours) would be deleted, the original 8 would respawn, RemoveBikes would teleport them outside, and then your own bikes would spawn again.

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.


  • 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.