|
|
#1 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
Hello, i've scripted my own race system. Everything seems work apart from the last two checkpoints. The second to last checkpoint shows but doesn't function meaning the last one wont show at all.
OnPlayerEnterDynamicCheckpoint pawn Code:
My OtherRaceInfo Var pawn Code:
Kind Regards, Luis. |
|
|
|
|
|
#2 |
|
Huge Clucker
![]() ![]() ![]() Join Date: Nov 2007
Location: Florida
Posts: 418
Reputation: 17
|
Actually about to get off and get to bed, but decided to quickly respond before I do, anyways:
Code:
if(PlayerCheckpoint[playerid] >= OtherRaceInfo[ChosenRace][TotalCheckpoints]) |
|
|
|
|
|
#3 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
The total checkpoints is set to how many checkpoints there are which is 18 but i'll try setting it to 19 now.
|
|
|
|
|
|
#4 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Jul 2011
Posts: 635
Reputation: 103
|
idk if that will work , but you should try
![]() because i have made a similar system before pawn Code:
|
|
|
|
|
|
#5 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
None of the above is working unfortunately. I'm really confused about this seeing at the other checkpoints work but the last two don't :S
|
|
|
|
|
|
#6 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
Can someone help me with this, as I need it being fixed as soon as possible. Thank you.
|
|
|
|
|
|
#7 |
|
Huge Clucker
![]() ![]() ![]() Join Date: Nov 2007
Location: Florida
Posts: 418
Reputation: 17
|
In order to pinpoint a problem, print statements are highly recommended to be placed everywhere (Usually at every turn in the code such as an IF or an ELSE). However, it may be easier to just use client messages instead if you're testing within the server, so I'll include both:
Code:
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid) { if(checkpointid == CheckpointIDRace[playerid] && IsRaceOn == true && IsPlayerInRace(playerid)) { new string[128]; DestroyDynamicRaceCP(CheckpointIDRace[playerid]); PlayerCheckpoint[playerid]++; CheckpointIDRace[playerid] = CreateDynamicRaceCP(OtherRaceInfo[ChosenRace][MarkerType], AroundTheCountry[PlayerCheckpoint[playerid]][X], AroundTheCountry[PlayerCheckpoint[playerid]][Y], AroundTheCountry[PlayerCheckpoint[playerid]][Z], AroundTheCountry[PlayerCheckpoint[playerid]+1][X], AroundTheCountry[PlayerCheckpoint[playerid]+1][Y], AroundTheCountry[PlayerCheckpoint[playerid]+1][Z], OtherRaceInfo[ChosenRace][CheckpointSize], -1, -1, playerid, 500.0); PlayerBestLap[playerid] = gettime() - RaceStartTime; new seconds = PlayerBestLap[playerid] % 60, minutes = (PlayerBestLap[playerid] - seconds) / 60, format(string, sizeof string, "~n~~n~~n~~n~~n~~n~~n~~n~~b~%s~n~~r~Checkpoints Remaining: ~w~%d/%d~n~Time: %02d:%02d", OtherRaceInfo[ChosenRace][Name], PlayerCheckpoint[playerid], OtherRaceInfo[ChosenRace][TotalCheckpoints], minutes, seconds); GameTextForPlayer(playerid, string, 28000000, 3); if(PlayerCheckpoint[playerid] >= OtherRaceInfo[ChosenRace][TotalCheckpoints]) { IsRaceOn = false; //PlayerCheckpoint[playerid] = -1; ChosenRace = 0; DestroyDynamicRaceCP(CheckpointIDRace[playerid]); format(string, sizeof string, "RACE: {FFFFFF}The race is now over. {FF0000}%s {FFFFF}has won!", GetPlayerNameEx(playerid)); SendClientMessageToAll(COLOR_PURPLE, string); GameTextForAll(" ", 100, 3); StopAudioStreamForPlayer(playerid); DestroyVehicle(GetPlayerVehicleID(playerid)); } } return 1;}
There are only 2 IFs in the code you've displayed for us, so after each of those IFs, throw in a print(); or you may throw in a SendClientMessageToAll() or even both depending on your testing conditions. The messages used should be diffirent for each section (Point A for example, then Point B etc.) Next, when you reach that 2nd to last checkpoint, make sure both of those prints/messages were called to ensure the script at least ran. If you're missing a print/message, then you'll at least know what IF failed and have an idea of where exactly to start looking in the code for your problem. Not only will this help you locate this problem, but also help with future problems by using this method Once you've figured out which one of these IFs isnt being triggered when its suppose to be, we can examine that IF and start locating the source of the problem... CreateDynamicRaceCP() or DestroyDynamicRaceCP() might be where the problem is as well, but isn't displayed here UPDATE: if(checkpointid == CheckpointIDRace[playerid] && IsRaceOn == true && IsPlayerInRace(playerid)) This line of code is what I'm guessing is failing to pass when called on the 2nd to last checkpoint, so look into CheckpointIDRace[playerid], IsRaceOn and IsPlayerInRace. Something must have changed these values in your script somewhere down the line... |
|
|
|
|
|
#8 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
I've done some more snooping on this and i've set the total checkpoints to 5 for a small test and everything works, it ends the race and what not. But if the total checkpoints are 18 it wont work correctly.
|
|
|
|
|
|
#9 |
|
Huge Clucker
![]() ![]() ![]() Join Date: Nov 2007
Location: Florida
Posts: 418
Reputation: 17
|
Well that's just interesting... (I assume you meant finishes the race early at the 4th,5th or 6th CP)
In that case, try lowering the total checkpoints instead of raising if you haven't already... You started off with 18, then you tried 19, have you yet tried 17? |
|
|
|
|
|
#10 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,183
Reputation: 155
|
I've been working on this and it's now not working with the last checkpoint which would be the finish.
Updated code pawn Code:
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Race system | P<3TS | Server Support | 0 | 04/08/2012 04:10 PM |
| Looking for Race System. | petrolhead | General | 6 | 18/03/2012 06:15 AM |
| Race system | wumpyc | Scripting Help | 6 | 26/10/2011 02:19 PM |
| Race system | AzTeCaS | Help Archive | 4 | 03/12/2010 04:08 PM |
| about race system | xExpressx | Help Archive | 1 | 20/10/2010 05:28 AM |