Advertisement
Hellrocker

Untitled

Jan 26th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. public OnPlayerEnterRaceCheckpoint(playerid)
  2. {
  3. PlayerPlaySound(playerid, 1056, 0, 0, 0);
  4.  
  5. new func_str[32];
  6. format(func_str, 32, "cp_%d", playerCurrentCP[playerid]);
  7. CallRemoteFunction(func_str, "i", playerid);
  8.  
  9. switch(rVehicleModel) {
  10. case 0, -1:
  11. {
  12. GetPlayerPos(playerid, lcp_Pos[playerid][0], lcp_Pos[playerid][1], lcp_Pos[playerid][2]);
  13. GetPlayerVelocity( playerVehicleID[playerid], lcp_Velocity[playerid][0], lcp_Velocity[playerid][1] ,lcp_Velocity[playerid][2]);
  14. }
  15. default: {
  16. GetVehiclePos(playerVehicleID[playerid], lcp_Pos[playerid][0], lcp_Pos[playerid][1], lcp_Pos[playerid][2]);
  17. GetVehicleZAngle(playerVehicleID[playerid], lcp_Pos[playerid][3]);
  18. GetVehicleVelocity( playerVehicleID[playerid], lcp_Velocity[playerid][0], lcp_Velocity[playerid][1] ,lcp_Velocity[playerid][2]);
  19. }
  20. }
  21.  
  22. playerCurrentCP[playerid]++;
  23. if(playerCurrentCP[playerid] < rMaxCheckpoints)
  24. {
  25. new n = playerCurrentCP[playerid];
  26. new n2 = n + 1;
  27. if(n == (rMaxCheckpoints - 1)) n2 = 0; //Final Checkpoint, don't access n + 1
  28.  
  29. 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]);
  30. }
  31. else
  32. {
  33. racePositionCount++;
  34. raceFinishLeaderboard[racePositionCount - 1] = playerid;
  35.  
  36. new _timestamp = playerRaceTime[playerid],
  37. _hrs = ( _timestamp / ( 1000 * 60 * 60 ) ),
  38. _min = ( _timestamp % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ),
  39. _sec = ( (_timestamp % ( 1000 * 60 * 60 ) ) % ( 1000 * 60 ) ) / 1000;
  40. _timestamp = _timestamp - ( _hrs * 60 * 60 * 1000 ) - ( _min * 60 * 1000 ) - ( _sec * 1000);
  41.  
  42. raceAnnounceEvent("%s finished the race in %d%s place! {FFFF00}(%02d:%02d.%03d)", playerNick[playerid], racePositionCount, returnOrdinal(racePositionCount), _min, _sec, _timestamp);
  43.  
  44. DisablePlayerRaceCheckpoint(playerid);
  45.  
  46.  
  47. new cmdQuery[128];
  48. format(cmdQuery, 128, "INSERT INTO exr_race_times (timestamp,accid,raceid,time) VALUES (%d,%d,'%s',%d)", gettime(), playerAccount[playerid][playerAccID], currentUID, playerRaceTime[playerid]);
  49. mysql_function_query(1, cmdQuery, true, "insertRaceTimes", "d", 0);
  50.  
  51. //If 1'st, set timer to change soon.
  52. if(racePositionCount == 1) {
  53. countdownToNextCount = CHANGE_DELAY;
  54. changeTimerInitiated = true;
  55. countdownToNextTimer = SetTimer("countdownToNext", 1000, 1);
  56. changeTimerTimer = SetTimer("changeTimerPreReq", CHANGE_DELAY * 1000, 0);
  57.  
  58.  
  59. new nextRace = raceid + 1;
  60. if(nextRace >= sizeof(races)) {
  61. nextRace = 0;
  62. }
  63.  
  64. new path[128], tempRaceName[128], tempRaceAuthor[64];
  65. format(path, 128, "races/%s/config", races[nextRace]);
  66. getINIString(path, "name", tempRaceName);
  67. getINIString(path, "author", tempRaceAuthor);
  68.  
  69. new raceAnnouncement3[128];
  70. format(raceAnnouncement3, 128, ""MSGPREFIX"Next Race: '{FF0000}%s{0080FF}' by {FF0000}%s{0080FF}", tempRaceName, tempRaceAuthor);
  71. SendClientMessageToAll(0x0080FFFF, raceAnnouncement3);
  72.  
  73. }
  74.  
  75. new cRew, pRew;
  76. switch(racePositionCount) {
  77. case 1: { cRew = 50; pRew = 5; }
  78. case 2: { cRew = 40; pRew = 4; }
  79. case 3: { cRew = 30; pRew = 3; }
  80. case 4: { cRew = 20; pRew = 2; }
  81. default: { cRew = 10; pRew = 1; }
  82. }
  83. givePlayerPoints(playerid, pRew);
  84. givePlayerCash(playerid, cRew);
  85.  
  86. playerRaceFinished[playerid] = 1;
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement