[FilterScript] [FS] Yagu's Race filterscript [v0.4a - Aug 5th]
#1

Yagu's Race Filterscript
Main features:
  • Filterscript - Easy to add to your existing gamemode
  • Race builder - Relatively easy way to build races "on the fly"
  • Unlimited races - There's no limit on amount of races you can create
  • Unlimited racers - Everyone in your server can join in the same race for some true racing carnage
  • Unlimited racing - Race by foot, cars, boats or planes*
  • Record keeping - Top 5 lap times and top 5 track times are stored in the race, who's the fastest?
* = Vehicles not included


Current version: v0.4a

Files:
- Source + compiled .amx + 2 example races (annoying & fastlane)

In-depth information: (old v0.3 command list available here as they still work in v0.4)
Building a Race
- /buildrace enters you to the race building mode
- /cp creates a new checkpoint
- /scp [number] selects an existing checkpoint
- /rcp replaces the current checkpoint with a new one
- /mcp [x/y/z] [amount] moves the selected checkpoint desired amount in desired direction
- /dcp deletes the checkpoint
- /buildmenu allows you to change the racemode, amount of laps, CP size and race type, and abort building
- /saverace [name] saves the race
- /editrace [name] opens an existing race for editing
- /deleterace [name deletes an existing race

Starting a race & racing
- /loadrace [name] loads the selected race, and opens the race menu
- When in Race Menu, you can change the amount of laps, racemode, checkpoint size and race type, abort and start the race. Note: if you change laps, racemode or CP size, the best lap/track info will not be saved!
- /join once the race has started
- /ready once you are ready to start (it's recommended that you get as close as possible to the start CP first!)
- /leave if you want to leave the race

Admin menu
- /raceadmin opens the admin menu, here you can:
  • Change the prizemode
  • Change the fixed prize amount
  • Change the dynamic prize multiplier
  • Change the entry fee
  • Change the "Majority Start"-settings
  • End the currently going on race
  • Set if admin-privileges are required for starting races
  • Set if admin-privileges are required for race building
  • Set the automatic race rotation on
Racemodes: From the menus you can select 'Default', 'Ring', 'Yoyo and 'Mirror' modes. Default is the original from start to end-type of race, whereas Ring is the racetrack version where you drive the same circuit around multiple times. Yoyo goes from start to the end, and backwards to start again. Mirror mode is same as Default, but it goes from last CP to the first instead.

Prizemodes: 'Fixed' prizemode gives a lump sum (default: 30000$) which is shared amongst first 3, 'Dynamic' prize sets the prize amount depending on the lenght of the race (default: 1$ per 1 meter of track), 'Entry Fee' requires players to pay up certain sum of money to join the race, and these join fees are then split amongst the first 3. 'Entry Fee + Fixed' and 'Entry Fee + Dynamic' are combinations of the aforementioned. NOTE: If only 1 player is racing, the prizes don't apply; the entry fees will be returned when the player completes the race. Also, if only 2 players are racing, the winner will get 4/6ths of the total, and 2nd will get the 2/6ths they normally get (ie. the 3rd's 1/6th is given to the winner)

Race Rotation: This is rather simple feature currently, in scriptfiles folder is a file called 'yrace.rr' which has the race names that are in the rotation. When the rotation is enabled, the script tries to start a race every now and then. The main reason for this was if Race Admin is enabled, so that the server is "alive" even if there isn't any admins starting races.

Majority Delay/Start: It's a bit dumb name maybe, but the settings related to this apply to when half of the racers are ready. If the delay is set to 0 (disabled), it won't work at all, otherwise the race will automatically start in X seconds. Should prevent people from waiting at the start while other people who joined are afk / doing something else entirely.

Future additions: Squashing v0.4 bugs if any. And whatever new ideas come along, currently none.

About saving/loading: the files will be placed into the scriptfiles directory in your SA-MP server directory, and have file extension of ".yr", as of v0.2, the files store various other bits of information as well, but you can import other races by simply placing the checkpoint coordinates in a space limited textfile, one CP per line, renaming it to <race>.yr and then opening it with editrace ingame and set the lap/mode settings.

Some credit where the credit is due: Jax & Sintax for LVDM ~MG-LG_DM, which has been the base for the gamemod we are playing with my buddies and being pretty much my cheatbook on how to make things work (there are few bits in this script from there still, like the colors/strtok), and mabako for the Simple Map Editor since tossing around ramps gave me the idea of tossing around checkpoints instead, and the big help for file function usage I got from the script (since I've always hated file functions).

Changelog if someone is interested:
Код:
v0.4a
 -Fixed a crash bug related to menus and restarting the gamemode via gmx

v0.4
-Added menus for setting most of race specific settings: /buildmenu & /raceadmin. /loadrace [race] also pops open a menu.
-Complete overhaul on the prizes system
 -Winner gets 3/6ths of the pot, second 2/6ths and the 3rd 1/6th.
 -Different prize systems:
 - Fixed: Prize money is a set sum
 - Dynamic: Prize money is 1$ per 1m of whole race's lenght (ie. drive 20km, prize will be 20,000$)
 - Entry fee: All racers have to pay a set sum of money, the entry fees are shared among the top 3.
 - Entry fee + Fixed:  All racers pay to join the race, prize: the fees + fixed sum of money
 - Entry fee + Dynamic: All racers pay to join the race, prize: the fees + dynamic sum (1$ for 1m)
-Added a race rotation system that switches between races automatically
-Fixed a minor bug with setting /racemode 2 in race builder, thanks to Rush_iam for the report.
-Prevented giving negative values to various commands, and added few missing feedbacks

v0.3
-You don't have to be in the starting checkpoint to /ready anymore, should allow more racers now, as well as larger vehicles.
-Once half of the /joined players are /ready, the race will start after 2 minutes (time adjustable, can also be turned off).
-/ready players won't be locked until countdown starts
-Added /deleterace for deleting races (if either RACEADMIN or BUILDADMIN are defined, this command requires admin access)
-Added racemode 3 "Mirror Mode". The races start from the last CP, and work their way to the first.
-Added /airrace, which changes the checkpoints to air CP rings and back.
-Added /cpsize for setting the checkpoint size for the race (default: 8.0)
-Added #define MAX_BUILDERS, which determines how many players can build a race at once (default: 4, ~3 times smaller compile size than before)
-Readded /racestart. You can change cpsize, mode and laps between loadrace and racestart (or via using editrace)
-/racemode now accepts [default/ring/yoyo/mirror] as parameters, in addition to numbers
-/bestlap doesn't show best laps, nor are the laptimes are saved for racemode 0 races (since they don't have laps anyways)
-/bestlap [race] and /bestrace [race] now display the topscores for the specific race
-/bestlap and /bestrace will display the scores for the previous race until new one is loaded.
-Improved the readability of time
-Multiple small bug fixes

v0.2d [d for dcmd]
-Code cleaning. All commands now use dcmd instead, new function for setting checkpoints during race
-Fixed a bug that caused the automatic endrace to stop functioning in certain situations.
-Added /racemode and /setlaps to /buildhelp
-Fixed a bug with /racemode and /setlaps in building mode, now they should be saved properly for all builders.

v0.2
-Removed /startrace, doing /loadrace now loads the race, and starts it.
-Added /setlaps for setting how many laps are to be driven. Doing this in buildrace mode saves the amount of laps, doing this while a race is active overrides the race's laps setting.
-Added /racemode for setting the racemode. See OP for details
-Added /bestlap and /bestrace for viewing the top-5 lap times and track times.
-Modified the racefile format slightly, it now stores the top-5 times, along with racemode/laps information and race creator's name, as well as version number for future compatibility.

v0.1a
-Prevented passengers from getting /ready
-Prevented using /ready to unready once countdown has started
-Prevented /buildrace when the wannabe builder is participating in a race
-Trying to /ready outside the starting checkpoint now returns the correct error message
-Fixed few situations where race wouldn't start even if everyone was /ready
-Added #defines RACEADMIN and BUILDADMIN which disables some commands from non-admins, uncomment from source to enable
-Players have their builder/racer status removed on disconnect
-Some code cleaning, new functions and such


v0.1
-Prevented /joining races that have already started (ie. countdown had started)
-Added/rcp for replacing current checkpoint with a new one
-Added /editrace for editing previously created tracks.
-Using OnPlayerEnterRaceCheckpoint() instead of timer, should work even better than before (thanks to switch for letting me know about the option! :P)
-Added sounds to countdown and checkpoints.


v0.01
-Fixed a bug with /scp when selecting CP 0 when no CPs have been created yet.
-Prevented players from /joining the race multiple times (thanks to switch for noticing this)
-Now multiple people can be building races at the same time
-Cleaned up the code a bit, using multidimensional arrays now.
-Added /mcp for moving checkpoints. Usage: /mcp [x/y/z] [amount]
-Added /dcp for deleting checkpoints. Usage: /dcp

v0.001
-Initial release.
And the files themselves:
- Source + compiled .amx + 2 example races (annoying & fastlane)
Reply
#2

Nice job, everything seems to be working well.

As you say, some admins may need to edit it to stop chaos arising and maybe other checks people could mess with (such as typing /join loads of times to increase participants).

Moving/completely replacing checkpoints would be my biggest suggestion but you seem to have that planned out Keep coding!
Reply
#3

Alrighty, few updates, additions and bugfixes:

-Fixed a bug with /scp when selecting CP 0 when no CPs have been created yet.
-Prevented players from /joining the race multiple times (thanks to switch for noticing this)
-Now multiple people can be building races at the same time
-Cleaned up the code a bit, using multidimensional arrays now for coordinates.
-Added /mcp for moving checkpoints. Usage: /mcp [x/y/z] [amount]
-Added /dcp for deleting checkpoints. Usage: /dcp (select the checkpoint you want to delete with /scp)

<old versions removed, check the OP>

Reply
#4

OMFG THIS ROX!!!

THANK YOU
THANK YOU
YOU PWN
Reply
#5

Just noticed you have your checkpoint stuff in a timer. Is there a reason you are doing it this way and not with OnPlayerEnterRaceCheckpoint{}?
With the callback it is much faster and ends up feeling more responsive when you enter a checkpoint.

btw, nice changes.
Reply
#6

Uncomplied, this is only 21kb. Complied, this is 121kb. is this normal? It is massive compared to the other fs's i use.
Reply
#7

Quote:
Originally Posted by switch
Just noticed you have your checkpoint stuff in a timer. Is there a reason you are doing it this way and not with OnPlayerEnterRaceCheckpoint{}?
With the callback it is much faster and ends up feeling more responsive when you enter a checkpoint.
Um. Um. Yeah, there's a reason, I didn't know there was such a thing as OnPlayerEnterRaceCheckpoint() Guess I'll rework it to use that instead, as the timer stuff is pretty nasty since it has to be pretty frequent so it doesn't miss players going through the points.

Quote:
Originally Posted by Robert
Uncomplied, this is only 21kb. Complied, this is 121kb. is this normal? It is massive compared to the other fs's i use.
myeah, I was about to make note of it on the update but didn't. It's probably because of this:
Код:
new Float:BRaceCheckpoints[MAX_PLAYERS][MAX_RACECHECKPOINTS][3]; //Buildrace CP array
Each player can build their own race at the same time, so the result is pretty huge array, thus taking a lot of space as ****** mentioned.
Don't double post.
Reply
#8

Thanks, I was working on one of these myself, but never got time to finish it. Now I dont have to
Reply
#9

Ive got a problem - everytime i try to type /join and i started the race, it says Currenty building, cant join

How can i fix this?
Reply
#10

Use /clearrace to exit the buildmode, and then try /joining again.

Also sneaky v0.1a update:
-Prevented passengers from getting /ready
-Prevented using /ready to unready once countdown has started
-Prevented /buildrace when the wannabe builder is participating in a race
-Trying to /ready outside the starting checkpoint now returns the correct error message
-Fixed few situations where race wouldn't start even if everyone was /ready
-Added #defines RACEADMIN and BUILDADMIN which disables some commands from non-admins, uncomment from source to enable
-Players have their builder/racer status removed on disconnect
-Some code cleaning, new functions and such

Check the OP for links.
Reply
#11

have you this filterscript for sa-mp 0.1b ?

pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeease

thanks
Reply
#12

Quote:
Originally Posted by killer57
have you this filterscript for sa-mp 0.1b ?
No, I don\'t. But the script probably can be modified to work on SA-MP 0.1b simply by changing all the *RaceCheckpoint functions to normal *Checkpoint functions. That said, I don\'t have any need for 0.1b version of the script, so I won\'t start writing 0.1b and 0.2 versions of the script at the same time, especially with what bugs there probably still is in this one.

(and this would be a bit more pointless now that the v0.2 has been released :P)
Reply
#13

This is convenient because the checkpoints in Pawno are hard, why cant they just have something like this:
pawn Code:
AddCheckpoint(checkpointid, name, X, Y, Z);
//example:
AddCheckpoint(3, mycheck, 0.32, 5.23, 1.0);
//that would add a checkpoint in some fields in LS

//etc
Reply
#14

Alright, v0.2 update:
-Removed /startrace, doing /loadrace now loads the race, and starts it.
-Added /setlaps for setting how many laps are to be driven. Doing this in buildrace mode saves the amount of laps, doing this while a race is active overrides the race\'s laps setting.
-Added /racemode for setting the racemode. See OP for details
-Added /bestlap and /bestrace for viewing the top-5 lap times and track times.
-Modified the racefile format slightly, it now stores the top-5 times, along with racemode/laps information and race creator\'s name, as well as version number for future compatibility.

The races created with earlier versions are fully compatible with this release, and will get all the new features of this release when they are loaded and raced on. I haven\'t gotten much chance to test this very much now, I\'ve completed couple of races by myself and haven\'t encountered anything fatal, but please let me know if there are any issues. I\'m also open for new feature ideas.

edit:
v0.2d [d for dcmd] update
-Code cleaning. All commands now use dcmd instead, new function for setting checkpoints during race
-Fixed a bug that caused the automatic endrace to stop functioning in certain situations.
-Added /racemode and /setlaps to /buildhelp
-Fixed a bug with /racemode and /setlaps in building mode, now they should be saved properly for all builders.

edit2: As if someone cares, but anyways:
v0.3 update
-You don\'t have to be in the starting checkpoint to /ready anymore, should allow more racers now, as well as larger vehicles.
-Once half of the /joined players are /ready, the race will start after 2 minutes (time adjustable, can also be turned off).
-/ready players won\'t be locked until countdown starts
-Added /deleterace for deleting races (if either RACEADMIN or BUILDADMIN are defined, this command requires admin access)
-Added racemode 3 "Mirror Mode". The races start from the last CP, and work their way to the first.
-Added /airrace, which changes the checkpoints to air CP rings and back.
-Added /cpsize for setting the checkpoint size for the race (default: 8.0)
-Added #define MAX_BUILDERS, which determines how many players can build a race at once (default: 4, ~3 times smaller compile size than before)
-Readded /racestart. You can change cpsize, mode and laps between loadrace and racestart (or via using editrace)
-/racemode now accepts [default/ring/yoyo/mirror] as parameters, in addition to numbers
-/bestlap doesn\'t show best laps, nor are the laptimes are saved for racemode 0 races (since they don\'t have laps anyways)
-/bestlap [race] and /bestrace [race] now display the topscores for the specific race
-/bestlap and /bestrace will display the scores for the previous race until new one is loaded.
-Improved the readability of time
-Multiple small bug fixes

See OP for the files.
Reply
#15

nice script, but can u make when someone buildrace (maybe only admin) he can set price for winner?

+better 1.,2.,3. position different values
Reply
#16

Yeah, the prize system it currently has was pretty much just added in early on to give some kind of reason to race, I haven\'t touched that bit since I started. Don\'t know about adding the prize money to the race-file itself, but thenagain it would add in flexibility which I\'ve ranked pretty high when making the script. I\'ll see what I can do about it for the next version.
Reply
#17

Thank you very much for this FS

I think that there is bug in a \'/racemode\' command:
Code:
if(tempmode == 2 && BCurrentCheckpoints[b(playerid)] < 3)
	{
	  SendClientMessage(playerid, COLOR_YELLOW, "Can\'t set racemode 2 on races with only 2 CPs. Changing to mode 1 instead.");
	  Bracemode[b(playerid)] = tempmode;
	  return 1;
	}
should be
Code:
if(tempmode == 2 && BCurrentCheckpoints[b(playerid)] < 3)
	{
	  SendClientMessage(playerid, COLOR_YELLOW, "Can\'t set racemode 2 on races with only 2 CPs. Changing to mode 1 instead.");
	  Bracemode[b(playerid)] = 1;
	  return 1;
	}
Reply
#18

Thanks a lot Yagu, Ill be using it.

Edit: I have 2 questions:

1. How do I set the races so when someone types /join he will be teleported to the Race Start?

2. Will the races restart by themselves (for times when admins arent online)?
Reply
#19

Quote:
Originally Posted by Rush_iam
I think that there is bug in a \'/racemode\' command:
Owps. That\'s right. It\'s not very fatal bug since that\'s on race builder part, when loading the race, the script will correct the mode to 1 automatically. None the less, I\'ll fix it for the next version.

Quote:

1. How do I set the races so when someone types /join he will be teleported to the Race Start?

2. Will the races restart by themselves (for times when admins arent online)?

1) You\'d need a little bit of editing:
pawn Code:
SetPlayerPos(playerid,RaceCheckpoints[CurrentCheckpoint[playerid]][0],RaceCheckpoints[CurrentCheckpoint[playerid]][1],RaceCheckpoints[CurrentCheckpoint[playerid]][2]);
Place that after line 773 and it should automatically teleport the player to the checkpoint\'s position. It might not bring the player\'s vehicle along so you might need some additional tweaking Plus there might will be some chaos if multiple people /join at the same time.

2) No, there\'s no race rotation or anything, but you could leave raceadmin undefined (or have it defined but remove the admin checks from loadrace/startrace) so the players can start races by themselves. I didn\'t originally make this as 24/7 racing script, rather than "bah killing eachother with peaguns is boring, let\'s do a race or two and then get back to the killing"-type of activity, but I\'ll see if I add some sort of rotation option in the future.
Reply
#20

Thanks a lot, you really help me =]

I made the vehicle teleport by myself
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)