Guest User

Stunt Ramp

a guest
Jun 20th, 2010
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.87 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3. #include <cpstream>
  4. #pragma tabsize 0
  5. #define COLOR_RED 0xFF0000AA
  6. #define COLOR_YELLOW 0xFFFF00AA
  7. #define COLOR_WHITE 0xFFFFFFAA
  8. #define COLOR_LIGHTBLUE 0x33CCFFAA
  9. #define COLOR_ORANGE 0xFF9900AA
  10. #define COLOR_GREEN 0x33AA33AA
  11. #define COLOR_GRAD1 0xB4B5B7FF
  12. new RampCheck;
  13. new InStunt[MAX_PLAYERS];
  14. new StuntOn;
  15. new playername[MAX_PLAYER_NAME];
  16. new str[256];
  17. new CD[MAX_PLAYERS];
  18. new CdTimer[MAX_PLAYERS];
  19. //==============================================================================
  20. public OnFilterScriptInit()
  21. {
  22.     print("\nStunt FS Load...\n");
  23. }
  24. //==============================================================================
  25. public OnGameModeInit()
  26. {
  27.     RampCheck = CPS_AddCheckpoint(1967.8470,-1422.0588,13.5723,2.0,40);
  28.     AddStaticVehicle(522,1944.9897,-1405.3782,13.1443,194.9478,6,25); // nrg
  29.     AddStaticVehicle(522,1941.4489,-1405.7056,13.1399,186.4512,6,25); // nrg
  30.     AddStaticVehicle(522,1938.6359,-1407.4504,13.1453,170.6302,6,25); // nrg
  31.     return 1;
  32. }
  33. //==============================================================================
  34. public OnPlayerCommandText(playerid, cmdtext[])
  35. {
  36.     new cmd[256];
  37.     new idx;
  38.     cmd = AGstrtok(cmdtext, idx);
  39.  
  40.  
  41.     if (strcmp(cmd, "/Ramp", true) == 0 || strcmp(cmd, "/Ra", true) == 0)
  42. {
  43.     SetPlayerPos(playerid,1961.2983,-1407.7300,13.5772);
  44.     SetPlayerFacingAngle(playerid, 201.8824);
  45.     return 1;
  46. }
  47.     if (strcmp(cmd, "/StartStunt", true) == 0 || strcmp(cmd, "/SS", true) == 0)
  48. {
  49.     if(!CPS_IsPlayerInCheckpoint(playerid,RampCheck)) return SendClientMessage(playerid,COLOR_RED,"You are not in the Checkpoint in the Ramp.");
  50.     if(GetPlayerMoney(playerid)< 2000) return SendClientMessage(playerid,COLOR_RED,"Sorry, you dont have enough money, you need 2000$.");
  51.     if(StuntOn == 1) return SendClientMessage(playerid,COLOR_RED,"Sorry, but there is a player that doing the Stunt Ramp.");
  52.     if(InStunt[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You already start the Stunt Ramp get to the top building!");
  53.     if(IsPlayerInAnyVehicle(playerid)) {
  54.     SetPlayerRaceCheckpoint(playerid,1,1817.7235,-1432.9052,35.9219,210.4877,-217.9810,1050.7249,15);
  55.     InStunt[playerid] = 1;
  56.     StuntOn = 1;
  57.     GetPlayerName(playerid, playername, sizeof(playername));
  58.     format(str, sizeof(str), "%s Has started the Stunt Ramp!", playername);
  59.     SendClientMessageToAll(COLOR_LIGHTBLUE, str);
  60.     SendClientMessage(playerid,COLOR_RED,"You started the Stunt Ramp, you have a minute to get to the top building!");
  61.     for(new i=0;i<=MAX_PLAYERS;i++){
  62.     if(IsPlayerConnected(i)){
  63.     if(InStunt[i] == 1) {
  64.     CdTimer[i] = SetTimerEx("CountDown", 1000, 1, "i", i);
  65.     CD[i] = 60;
  66.             }
  67.         }
  68.     }
  69. }
  70.     else
  71. {
  72.     return SendClientMessage(playerid,COLOR_RED,"Youre not in a car, get NRG - 500 and come.");
  73. }
  74.     return 1;
  75. }
  76.     return 0;
  77. }
  78. //==============================================================================
  79. public OnPlayerDisconnect(playerid)
  80. {
  81.     InStunt[playerid] = 0;
  82.     return 1;
  83. }
  84. //==============================================================================
  85. public OnPlayerDeath(playerid, killerid, reason)
  86. {
  87.     if(StuntOn == 1)
  88. {
  89.     if(InStunt[playerid] == 1)
  90. {
  91.     InStunt[playerid] = 0;
  92.     StuntOn = 0;
  93.     DisablePlayerRaceCheckpoint(playerid);
  94.     SendClientMessage(playerid,COLOR_RED,"You loss at the Stunts Ramp.");
  95.     KillTimer(CdTimer[playerid]);
  96. }}
  97.     return 1;
  98. }
  99. //==============================================================================
  100. public OnPlayerExitVehicle(playerid, vehicleid)
  101. {
  102.     if(StuntOn == 1)
  103. {
  104.     if(InStunt[playerid] == 1)
  105. {
  106.     InStunt[playerid] = 0;
  107.     StuntOn = 0;
  108.     DisablePlayerRaceCheckpoint(playerid);
  109.     SendClientMessage(playerid,COLOR_RED,"You loss at the Stunts Ramp, please dont exit your vehicle when you are in the Stunt Ramp!");
  110.     KillTimer(CdTimer[playerid]);
  111.         }
  112.     }
  113.     return 1;
  114. }
  115. //==============================================================================
  116. public OnPlayerEnterCheckpoint(playerid)
  117. {
  118.       if (CPS_IsPlayerInCheckpoint(playerid,RampCheck))
  119. {
  120.       if(InStunt[playerid] == 0)
  121. {
  122.       SendClientMessage(playerid,COLOR_RED,"-----------------------------------");
  123.       SendClientMessage(playerid,COLOR_RED,"/SS - To start the Stunt Ramp");
  124.       SendClientMessage(playerid,COLOR_RED,"You need 2000$ to play the Stunt Ramp");
  125.       SendClientMessage(playerid,COLOR_RED,"-----------------------------------");
  126. }}
  127.       return 1;
  128. }
  129. //==============================================================================
  130. public OnPlayerEnterRaceCheckpoint(playerid)
  131. {
  132.     if(InStunt[playerid] == 1)
  133. {
  134.     InStunt[playerid] = 0;
  135.     StuntOn = 0;
  136.     GivePlayerMoney(playerid, 10000);
  137.     DisablePlayerRaceCheckpoint(playerid);
  138.     GetPlayerName(playerid, playername, sizeof(playername));
  139.     format(str, sizeof(str), "%s Won the Stunt Ramp and he got 10000$!",playername);
  140.     SendClientMessageToAll(COLOR_LIGHTBLUE, str);
  141.     KillTimer(CdTimer[playerid]);
  142. }
  143.     return 1;
  144. }
  145. //==============================================================================
  146. forward CountDown(playerid);
  147. public CountDown(playerid)
  148. {
  149.     if(CD[playerid] > 0)
  150. {
  151.     format(str,256,"~r~%d",CD[playerid]);
  152.     GameTextForPlayer(playerid,str,1000,6);
  153.     CD[playerid] = CD[playerid]-1;
  154. }
  155.     else
  156. {
  157.     InStunt[playerid] = 0;
  158.     StuntOn = 0;
  159.     DisablePlayerRaceCheckpoint(playerid);
  160.     SendClientMessage(playerid,COLOR_RED,"You loss at the Stunt Ramp, the time is over");
  161.     KillTimer(CdTimer[playerid]);
  162. }
  163.     return 1;
  164. }
  165. //==============================================================================
  166.     stock AGstrtok(const string[], &index)
  167. {
  168.     new length = strlen(string);
  169.     while((index < length) && (string[index] <= ' ') && (string[index] > '\r')) index++;
  170.     new offset = index, result[30];
  171.     while((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index], index++;
  172.     result[index - offset] = EOS;
  173.     return result;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment