Advertisement
Guest User

Oxside

a guest
Dec 11th, 2009
2,291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.40 KB | None | 0 0
  1. #include <a_samp>
  2. #include <color>
  3. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  4.  
  5. new Team[MAX_PLAYERS];
  6.  
  7. main(){print("GameMode Loaded");}
  8.  
  9.  
  10. public OnGameModeInit()
  11. {
  12.     SetGameModeText("Blank Script");
  13.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  14.     return 1;
  15. }
  16.  
  17. public OnGameModeExit()
  18. {
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerRequestClass(playerid, classid)
  23. {
  24.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  25.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  26.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerDisconnect(playerid, reason)
  36. {
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerSpawn(playerid)
  41. {
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerDeath(playerid, killerid, reason)
  46. {
  47.     return 1;
  48. }
  49.  
  50. public OnVehicleSpawn(vehicleid)
  51. {
  52.     return 1;
  53. }
  54.  
  55. public OnVehicleDeath(vehicleid, killerid)
  56. {
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerText(playerid, text[])
  61. {
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerCommandText(playerid, cmdtext[])
  66. {
  67.     dcmd(arrest, 6, cmdtext);
  68.     dcmd(kidnap, 6, cmdtext);
  69.     return 0;
  70. }
  71.  
  72. dcmd_arrest(playerid, params[])
  73. {
  74.     new id;
  75.     if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/arrest <playerid>\"");
  76.     else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "[Server] Player not found");
  77.     else
  78.     {
  79.         if(Team[playerid] == 1)
  80.         {
  81.             if (GetDistanceBetweenPlayers(playerid) > 5)
  82.             {
  83.                 SetPlayerPos(id, 197.6661,173.8179,1003.0234);
  84.                 SetPlayerInterior(id, 3);
  85.                 SendClientMessage(id, COLOR_RED, "[Server] You have been arrested");
  86.                 SendClientMessage(playerid, 0x00FF00AA, "[Server] You arrested someone");
  87.             }
  88.             else
  89.             {
  90.                 SendClientMessage(playerid, COLOR_RED, "[Server} You must be near the player you want to kidnap");
  91.             }
  92.         }
  93.     }
  94.     return 1;
  95. }
  96.  
  97. dcmd_kidnap(playerid, params[])
  98. {
  99.     new id;
  100.     if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kidnap <playerid>\"");
  101.     else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "[Server] Player not found");
  102.     else
  103.     {
  104.         if(Sniper[playerid] == 1)
  105.         {
  106.             if(Team[playerid] == 2)
  107.             {
  108.                 if (GetDistanceBetweenPlayers(playerid) >5)
  109.                 {
  110.                     SetPlayerPos(id, 197.6661,173.8179,1003.0234);
  111.                     SetPlayerInterior(id, 3);
  112.                     SendClientMessage(id, COLOR_RED, "[Server] You have been kidnapped");
  113.                     SendClientMessage(playerid, 0x00FF00AA, "[Server] You kidnapped someone");
  114.                 }
  115.                 else
  116.                 {
  117.                     SendClientMessage(playerid, COLOR_RED, "[Server] You must be near the player you want to kidnap");
  118.                 }
  119.             }
  120.             else { SendClientMessage(playerid, COLOR_RED, "[Server] You are gangster and not able to arrest"); }
  121.         }
  122.         else { SendClientMessage(playerid, COLOR_RED, "[Server] You are sniper, and not able to arrest"); }
  123.     }
  124.     return 1;
  125. }
  126.  
  127.  
  128. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  129. {
  130.     return 1;
  131. }
  132.  
  133. public OnPlayerExitVehicle(playerid, vehicleid)
  134. {
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerStateChange(playerid, newstate, oldstate)
  139. {
  140.     return 1;
  141. }
  142.  
  143. public OnPlayerEnterCheckpoint(playerid)
  144. {
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerLeaveCheckpoint(playerid)
  149. {
  150.     return 1;
  151. }
  152.  
  153. public OnPlayerEnterRaceCheckpoint(playerid)
  154. {
  155.     return 1;
  156. }
  157.  
  158. public OnPlayerLeaveRaceCheckpoint(playerid)
  159. {
  160.     return 1;
  161. }
  162.  
  163. public OnRconCommand(cmd[])
  164. {
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerRequestSpawn(playerid)
  169. {
  170.     return 1;
  171. }
  172.  
  173. public OnObjectMoved(objectid)
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerObjectMoved(playerid, objectid)
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerPickUpPickup(playerid, pickupid)
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnVehicleMod(playerid, vehicleid, componentid)
  189. {
  190.     return 1;
  191. }
  192.  
  193. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  194. {
  195.     return 1;
  196. }
  197.  
  198. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  199. {
  200.     return 1;
  201. }
  202.  
  203. public OnPlayerSelectedMenuRow(playerid, row)
  204. {
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerExitedMenu(playerid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnPlayerUpdate(playerid)
  224. {
  225.     return 1;
  226. }
  227.  
  228.  
  229.  
  230.  
  231. stock sscanf(string[], format[], {Float,_}:...)
  232. {
  233.     #if defined isnull
  234.         if (isnull(string))
  235.     #else
  236.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  237.     #endif
  238.         {
  239.             return format[0];
  240.         }
  241.     #pragma tabsize 4
  242.     new
  243.         formatPos = 0,
  244.         stringPos = 0,
  245.         paramPos = 2,
  246.         paramCount = numargs(),
  247.         delim = ' ';
  248.     while (string[stringPos] && string[stringPos] <= ' ')
  249.     {
  250.         stringPos++;
  251.     }
  252.     while (paramPos < paramCount && string[stringPos])
  253.     {
  254.         switch (format[formatPos++])
  255.         {
  256.             case '\0':
  257.             {
  258.                 return 0;
  259.             }
  260.             case 'i', 'd':
  261.             {
  262.                 new
  263.                     neg = 1,
  264.                     num = 0,
  265.                     ch = string[stringPos];
  266.                 if (ch == '-')
  267.                 {
  268.                     neg = -1;
  269.                     ch = string[++stringPos];
  270.                 }
  271.                 do
  272.                 {
  273.                     stringPos++;
  274.                     if ('0' <= ch <= '9')
  275.                     {
  276.                         num = (num * 10) + (ch - '0');
  277.                     }
  278.                     else
  279.                     {
  280.                         return -1;
  281.                     }
  282.                 }
  283.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  284.                 setarg(paramPos, 0, num * neg);
  285.             }
  286.             case 'h', 'x':
  287.             {
  288.                 new
  289.                     num = 0,
  290.                     ch = string[stringPos];
  291.                 do
  292.                 {
  293.                     stringPos++;
  294.                     switch (ch)
  295.                     {
  296.                         case 'x', 'X':
  297.                         {
  298.                             num = 0;
  299.                             continue;
  300.                         }
  301.                         case '0' .. '9':
  302.                         {
  303.                             num = (num << 4) | (ch - '0');
  304.                         }
  305.                         case 'a' .. 'f':
  306.                         {
  307.                             num = (num << 4) | (ch - ('a' - 10));
  308.                         }
  309.                         case 'A' .. 'F':
  310.                         {
  311.                             num = (num << 4) | (ch - ('A' - 10));
  312.                         }
  313.                         default:
  314.                         {
  315.                             return -1;
  316.                         }
  317.                     }
  318.                 }
  319.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  320.                 setarg(paramPos, 0, num);
  321.             }
  322.             case 'c':
  323.             {
  324.                 setarg(paramPos, 0, string[stringPos++]);
  325.             }
  326.             case 'f':
  327.             {
  328.  
  329.                 new changestr[16], changepos = 0, strpos = stringPos;
  330.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  331.                 {
  332.                     changestr[changepos++] = string[strpos++];
  333.                     }
  334.                 changestr[changepos] = '\0';
  335.                 setarg(paramPos,0,_:floatstr(changestr));
  336.             }
  337.             case 'p':
  338.             {
  339.                 delim = format[formatPos++];
  340.                 continue;
  341.             }
  342.             case '\'':
  343.             {
  344.                 new
  345.                     end = formatPos - 1,
  346.                     ch;
  347.                 while ((ch = format[++end]) && ch != '\'') {}
  348.                 if (!ch)
  349.                 {
  350.                     return -1;
  351.                 }
  352.                 format[end] = '\0';
  353.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  354.                 {
  355.                     if (format[end + 1])
  356.                     {
  357.                         return -1;
  358.                     }
  359.                     return 0;
  360.                 }
  361.                 format[end] = '\'';
  362.                 stringPos = ch + (end - formatPos);
  363.                 formatPos = end + 1;
  364.             }
  365.             case 'u':
  366.             {
  367.                 new
  368.                     end = stringPos - 1,
  369.                     id = 0,
  370.                     bool:num = true,
  371.                     ch;
  372.                 while ((ch = string[++end]) && ch != delim)
  373.                 {
  374.                     if (num)
  375.                     {
  376.                         if ('0' <= ch <= '9')
  377.                         {
  378.                             id = (id * 10) + (ch - '0');
  379.                         }
  380.                         else
  381.                         {
  382.                             num = false;
  383.                         }
  384.                     }
  385.                 }
  386.                 if (num && IsPlayerConnected(id))
  387.                 {
  388.                     setarg(paramPos, 0, id);
  389.                 }
  390.                 else
  391.                 {
  392.                     #if !defined foreach
  393.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  394.                         #define __SSCANF_FOREACH__
  395.                     #endif
  396.                     string[end] = '\0';
  397.                     num = false;
  398.                     new
  399.                         name[MAX_PLAYER_NAME];
  400.                     id = end - stringPos;
  401.                     foreach (Player, playerid)
  402.                     {
  403.                         GetPlayerName(playerid, name, sizeof (name));
  404.                         if (!strcmp(name, string[stringPos], true, id))
  405.                         {
  406.                             setarg(paramPos, 0, playerid);
  407.                             num = true;
  408.                             break;
  409.                         }
  410.                     }
  411.                     if (!num)
  412.                     {
  413.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  414.                     }
  415.                     string[end] = ch;
  416.                     #if defined __SSCANF_FOREACH__
  417.                         #undef foreach
  418.                         #undef __SSCANF_FOREACH__
  419.                     #endif
  420.                 }
  421.                 stringPos = end;
  422.             }
  423.             case 's', 'z':
  424.             {
  425.                 new
  426.                     i = 0,
  427.                     ch;
  428.                 if (format[formatPos])
  429.                 {
  430.                     while ((ch = string[stringPos++]) && ch != delim)
  431.                     {
  432.                         setarg(paramPos, i++, ch);
  433.                     }
  434.                     if (!i)
  435.                     {
  436.                         return -1;
  437.                     }
  438.                 }
  439.                 else
  440.                 {
  441.                     while ((ch = string[stringPos++]))
  442.                     {
  443.                         setarg(paramPos, i++, ch);
  444.                     }
  445.                 }
  446.                 stringPos--;
  447.                 setarg(paramPos, i, '\0');
  448.             }
  449.             default:
  450.             {
  451.                 continue;
  452.             }
  453.         }
  454.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  455.         {
  456.             stringPos++;
  457.         }
  458.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  459.         {
  460.             stringPos++;
  461.         }
  462.         paramPos++;
  463.     }
  464.     do
  465.     {
  466.         if ((delim = format[formatPos++]) > ' ')
  467.         {
  468.             if (delim == '\'')
  469.             {
  470.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  471.             }
  472.             else if (delim != 'z')
  473.             {
  474.                 return delim;
  475.             }
  476.         }
  477.     }
  478.     while (delim > ' ');
  479.     return 0;
  480. }
  481.  
  482. stock GetDistanceBetweenPlayers(playerid, playerid2)
  483. {
  484.     new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
  485.     new Float:tmpdis;
  486.     GetPlayerPos(playerid, x1, y1, z1);
  487.     GetPlayerPos(playerid2, x2, y2, z2);
  488.     tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2, x1)), 2) + floatpower(floatabs(floatsub(y2, y1)), 2) + floatpower(floatabs(floatsub(z2, z1)), 2));
  489.     return floatround(tmpdis);
  490. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement