Jump to content

race ends hunter reached.


Recommended Posts

What you're doing is definitely not a race server, it's a DM one. Never confuse the two. And seeing you are searching for a map in which to put the functions given to you I'd suggest to hold back with opening your server or even making big things. Download community resources, edit them, fix errors, recreate them, make your own small mods, etc. You need to learn the basics before doing anything at all. 

Link to comment

yeah i meant dm racing. sorry.

its just a server i play on with my brother. he likes oldschool things. the new maps that come out are way to hard for him. thats why i try to make a server for him. im just getting into it. and i cant find the file i need to edit to make the game end when the hunter is reached.

Link to comment

Can't test but try to open "race.zip", then open the file called "race_server.lua" and find the function called "raceTimeout". Now above the function add this

addEvent("timesUpPalServer", true)

and right after the function ends add this

addEventHandler("timesUpPalServer", root, raceTimeout)

Now at the very end of the same file (can be anywhere, just to be easily findable I say this) put this

function onPlayerPickUpRacePickup(pickupID, pickupType, vehicleModel)
	if pickupType == "vehiclechange" then
		if vehicleModel == 425 then
			triggerServerEvent("timesUpPalServer", localPlayer)
		end
	end
end
addEventHandler("onPlayerPickUpRacePickup", root, onPlayerPickUpRacePickup)

Save the "race_server.lua", save/update the "race.zip" and restart it using /restart race command in server.

Now when a player picks up a "vehiclechange" pickup and if the vehicle it changes to is with ID 425 (aka Hunter) it forces the "Time's up pal!" message and the map ends.

Link to comment
10 hours ago, wondersnofna said:

sorry for being a noob.. but i get your code. but for some reason addEvent and addEventhandler wont turn blue. and the script doesnt work.

do you know what causes it? 

Yes it was beyond midnight so i made a mistake xD

Replace triggerServerEvent with triggerEvent and see then. If still nothing replace localPlayer with root inside the event call. About the blue there's no problem. It should be blue if you're using Notepad++ but maybe you're using another program. 

Oh and use /debugscript 3 in chat when you test stuff. It gives you what's wrong and can help you (us) in fixing the problem much easier. You can turn off debug with /debugscript 0 when you're done with it. 

Edited by koragg
Link to comment
44 minutes ago, wondersnofna said:

hello, i am using notepad++ but it still wont turn blue. i found other addEvent's and they werent blue either so dunno if its fine.

and i cant get the code to work :(

sorry for bothering you.

OK, forget about the blue :D Are there any errors in debugscript 3 ?

Edited by koragg
Link to comment
4 hours ago, wondersnofna said:

im not getting any errors in the console. is there a way i could send you the file

Even if you send it i can't test it as i don't have mta installed atm. Should work, by console i hope you mean the /debugscript 3 window as F8 won't show any errors. 

Link to comment

OK then, new approach. Remove the code you put at the end of the file and put this instead:

function onResStart()
	setTimer(function()
		for i, player in ipairs(getElementsByType("player")) do
			local veh = getPedOccupiedVehicle(player)
			if veh then
				if getElementModel(veh) == 425 then
					triggerEvent("timesUpPalServer", root)
				end
			end
		end
	end, 50, 0)
end
addEventHandler("onResourceStart", resourceRoot, onResStart)

When the race resource starts an infinite timer will be started which checks if a player's vehicle is with ID 425 (Hunter) every 50 milliseconds and if it is - ends the race.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...