Guest User

Kinetic

a guest
Mar 22nd, 2009
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. // mascii's simple anti-vehicle FS
  2. // Edited by Kinetic, but all credits still go to mascii
  3.  
  4. #include <a_samp>
  5. #include <utils>
  6. #define COLOR_GREY 0xAFAFAFAA
  7.  
  8. forward strtok(const string[], &index);
  9. new Antiv[MAX_PLAYERS];
  10. //0 = off
  11. //1 = on
  12.  
  13. public OnFilterScriptInit()
  14. {
  15. return 1;
  16. }
  17.  
  18. public OnPlayerConnect(playerid)
  19. {
  20. Antiv[playerid] = 1;
  21. return 1;
  22. }
  23.  
  24. public OnPlayerStateChange(playerid, newstate, oldstate)
  25. {
  26. if(newstate == PLAYER_STATE_PASSENGER || PLAYER_STATE_DRIVER)
  27. {
  28. if (Antiv[playerid] == 0)
  29. {
  30. RemovePlayerFromVehicle(playerid);
  31. }
  32. }
  33. return 1;
  34. }
  35.  
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. new idx;
  39. new cmd[64];
  40. new tmp[128];
  41. new str[128];
  42. cmd = strtok(cmdtext, idx);
  43. if(strcmp(cmd, "/antiv", true) == 0)
  44. {
  45. if (IsPlayerAdmin(playerid) == 1)
  46. {
  47. tmp = strtok(cmdtext, idx);
  48. if(!strlen(tmp))
  49. {
  50. SendClientMessage(playerid, COLOR_GREY, "/antiv [playerid]");
  51. return 1;
  52. }
  53. new tmpplayer = ReturnUser(tmp);
  54. if(Antiv[tmpplayer] == 0)
  55. {
  56. new name[MAX_PLAYER_NAME];
  57. GetPlayerName(tmpplayer, name, sizeof(name));
  58. format(str, sizeof(str), "You have disabled vehicle entry for %s(ID:%d)", name, tmpplayer);
  59. SendClientMessage(playerid, COLOR_GREY, str);
  60. SendClientMessage(tmpplayer, COLOR_GREY, "Admin has disabled your vehicle entry privlages");
  61. Antiv[tmpplayer] = 1;
  62. }
  63. if(Antiv[tmpplayer] == 1)
  64. {
  65. new name[MAX_PLAYER_NAME];
  66. GetPlayerName(tmpplayer, name, sizeof(name));
  67. format(str, sizeof(str), "You have enabled vehicle entry for %s(ID:%d)", name, tmpplayer);
  68. SendClientMessage(playerid, COLOR_GREY, str);
  69. SendClientMessage(tmpplayer, COLOR_GREY, "Admin has enabled your vehicle entry privlages");
  70. Antiv[tmpplayer] = 0;
  71. }
  72. }
  73. }
  74. if(strcmp(cmdtext, "/antiv on", true) == 0)
  75. {
  76. if (IsPlayerAdmin(playerid) == 1)
  77. {
  78. SendClientMessageToAll(COLOR_GREY,"Admin has turned the use of Vehicles on");
  79. for(new i=0; i<=GetMaxPlayers(); i++)
  80. {
  81. Antiv[i] = 1;
  82. }
  83. }
  84. return 1;
  85. }
  86. if(strcmp(cmdtext, "/antiv off", true) == 0)
  87. {
  88. if (IsPlayerAdmin(playerid) == 1)
  89. {
  90. SendClientMessageToAll(COLOR_GREY,"Admin has turned the use of Vehicles off");
  91. for(new i=0; i<=GetMaxPlayers(); i++)
  92. {
  93. Antiv[i] = 0;
  94. }
  95. }
  96. return 1;
  97. }
  98. return 0;
  99. }
  100.  
  101. strtok(const string[], &index) // Strtok
  102. {
  103. new length = strlen(string);
  104. while ((index < length) && (string[index] <= ' '))
  105. {
  106. index++;
  107. }
  108.  
  109. new offset = index;
  110. new result[20];
  111. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  112. {
  113. result[index - offset] = string[index];
  114. index++;
  115. }
  116. result[index - offset] = EOS;
  117. return result;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment