Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- PlayerPlaySound(playerid, 1056, 0, 0, 0);
- new func_str[32];
- format(func_str, 32, "cp_%d", playerCurrentCP[playerid]);
- CallRemoteFunction(func_str, "i", playerid);
- switch(rVehicleModel) {
- case 0, -1:
- {
- GetPlayerPos(playerid, lcp_Pos[playerid][0], lcp_Pos[playerid][1], lcp_Pos[playerid][2]);
- GetPlayerVelocity( playerVehicleID[playerid], lcp_Velocity[playerid][0], lcp_Velocity[playerid][1] ,lcp_Velocity[playerid][2]);
- }
- default: {
- GetVehiclePos(playerVehicleID[playerid], lcp_Pos[playerid][0], lcp_Pos[playerid][1], lcp_Pos[playerid][2]);
- GetVehicleZAngle(playerVehicleID[playerid], lcp_Pos[playerid][3]);
- GetVehicleVelocity( playerVehicleID[playerid], lcp_Velocity[playerid][0], lcp_Velocity[playerid][1] ,lcp_Velocity[playerid][2]);
- }
- }
- playerCurrentCP[playerid]++;
- if(playerCurrentCP[playerid] < rMaxCheckpoints)
- {
- new n = playerCurrentCP[playerid];
- new n2 = n + 1;
- if(n == (rMaxCheckpoints - 1)) n2 = 0; //Final Checkpoint, don't access n + 1
- SetPlayerRaceCheckpoint(playerid, floatround(rCheckpoints[n][4]), rCheckpoints[n][0], rCheckpoints[n][1], rCheckpoints[n][2], rCheckpoints[n2][0], rCheckpoints[n2][1], rCheckpoints[n2][2], rCheckpoints[0][3]);
- }
- else
- {
- racePositionCount++;
- raceFinishLeaderboard[racePositionCount - 1] = playerid;
- new _timestamp = playerRaceTime[playerid],
- _hrs = ( _timestamp / ( 1000 * 60 * 60 ) ),
- _min = ( _timestamp % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ),
- _sec = ( (_timestamp % ( 1000 * 60 * 60 ) ) % ( 1000 * 60 ) ) / 1000;
- _timestamp = _timestamp - ( _hrs * 60 * 60 * 1000 ) - ( _min * 60 * 1000 ) - ( _sec * 1000);
- raceAnnounceEvent("%s finished the race in %d%s place! {FFFF00}(%02d:%02d.%03d)", playerNick[playerid], racePositionCount, returnOrdinal(racePositionCount), _min, _sec, _timestamp);
- DisablePlayerRaceCheckpoint(playerid);
- new cmdQuery[128];
- format(cmdQuery, 128, "INSERT INTO exr_race_times (timestamp,accid,raceid,time) VALUES (%d,%d,'%s',%d)", gettime(), playerAccount[playerid][playerAccID], currentUID, playerRaceTime[playerid]);
- mysql_function_query(1, cmdQuery, true, "insertRaceTimes", "d", 0);
- //If 1'st, set timer to change soon.
- if(racePositionCount == 1) {
- countdownToNextCount = CHANGE_DELAY;
- changeTimerInitiated = true;
- countdownToNextTimer = SetTimer("countdownToNext", 1000, 1);
- changeTimerTimer = SetTimer("changeTimerPreReq", CHANGE_DELAY * 1000, 0);
- new nextRace = raceid + 1;
- if(nextRace >= sizeof(races)) {
- nextRace = 0;
- }
- new path[128], tempRaceName[128], tempRaceAuthor[64];
- format(path, 128, "races/%s/config", races[nextRace]);
- getINIString(path, "name", tempRaceName);
- getINIString(path, "author", tempRaceAuthor);
- new raceAnnouncement3[128];
- format(raceAnnouncement3, 128, ""MSGPREFIX"Next Race: '{FF0000}%s{0080FF}' by {FF0000}%s{0080FF}", tempRaceName, tempRaceAuthor);
- SendClientMessageToAll(0x0080FFFF, raceAnnouncement3);
- }
- new cRew, pRew;
- switch(racePositionCount) {
- case 1: { cRew = 50; pRew = 5; }
- case 2: { cRew = 40; pRew = 4; }
- case 3: { cRew = 30; pRew = 3; }
- case 4: { cRew = 20; pRew = 2; }
- default: { cRew = 10; pRew = 1; }
- }
- givePlayerPoints(playerid, pRew);
- givePlayerCash(playerid, cRew);
- playerRaceFinished[playerid] = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement