Advertisement
Guest User

Blitzer/SpeedTrap system lcp9

a guest
Oct 7th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.45 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <dini>
  7. #include <zcmd>
  8. #include <sscanf>
  9.  
  10. enum speedtrap
  11. {
  12.     Exists,
  13.     Range,
  14.     Velocity,
  15.     Object
  16. };
  17. enum PLAYERS
  18. {
  19.     Free
  20. };
  21. new trap[500][speedtrap];
  22. forward TrapUpdate();
  23. new player[MAX_PLAYERS][PLAYERS];
  24.  
  25. public OnFilterScriptInit()
  26. {
  27.     print("\n--------------------------------------");
  28.     print("Speed TRAPS BY  LCP9");
  29.     print("--------------------------------------\n");
  30.    
  31.    
  32.     new i = 0;
  33.     while(i != 500)
  34.     {
  35.         new File[100];
  36.         format(File,sizeof(File),"/Traps/%i.txt",i);
  37.         if(dini_Exists(File))
  38.         {
  39.             new Float:x = dini_Float(File,"x");
  40.             new Float:y = dini_Float(File,"y");
  41.             new Float:z = dini_Float(File,"z");
  42.             new Float:ang = dini_Float(File,"ang");
  43.             new text[100];
  44.             format(text,sizeof(text),"%s",dini_Get(File,"Text"));
  45.            
  46.  
  47.             trap[i][Exists] = 1;
  48.             trap[i][Velocity] = dini_Int(File,"velocity");
  49.             trap[i][Range] = dini_Int(File,"range");
  50.             trap[i][Object] = CreateObject(18880,x,y,z-1,0,0,ang);
  51.             Create3DTextLabel(text,0xFF000FFF,x,y,z+3,60,0,0);
  52.         }
  53.         i++;
  54.     }
  55.     SetTimer("TrapUpdate",1000,1);
  56.     return 1;
  57. }
  58. public TrapUpdate()
  59. {
  60.     new id = 0;
  61.     while(id <= MAX_PLAYERS)
  62.     {
  63.         if(GetPlayerVehicleSeat(id) == 0)
  64.         {
  65.             if(GetPlayerSkin(id) != 280 && GetPlayerSkin(id) != 281 && GetPlayerSkin(id) != 282)
  66.             {
  67.                 if(player[id][Free] == 0)
  68.                 {
  69.                     if(IsPlayerInAnyVehicle(id))
  70.                     {
  71.                         new Float:x,Float:y,Float:z;
  72.                         GetVehicleVelocity(GetPlayerVehicleID(id),x,y,z);
  73.                         new i = 0;
  74.                         while(i <= 500)
  75.                         {
  76.                             if(trap[i][Exists] == 1)
  77.                             {
  78.                                 new Float:X,Float:Y,Float:Z;
  79.                                 GetObjectPos(trap[i][Object],X,Y,Z);
  80.  
  81.                                 if(IsPlayerInRangeOfPoint(id,trap[i][Range],X,Y,Z))
  82.                                 {
  83.                                     if(floatsqroot((x*x)+(y*y)+(z*z))*156.666667 > trap[i][Velocity])
  84.                                     {
  85.                                         SetPlayerWantedLevel(id,GetPlayerWantedLevel(id) + 1);
  86.                                         player[id][Free] = 3;
  87.                                         i = 600;
  88.                                         SendClientMessage(id,0xFF0000FF,"You are caught by a speed trap, slow down.");
  89.                                         /////////////////////////////////////////////////////////////
  90.                                         /////////////////////////////////////////////////////////////////
  91.                                         ////////////////////////////////////////////////////////////////
  92.                                         //////////////////////////////////////////////////////////////
  93.                                        
  94.                                         new playerid = 0;
  95.                                         new string[MAX_PLAYER_NAME + 100];
  96.                                         new name[MAX_PLAYER_NAME];
  97.                                         GetPlayerName(id,name,sizeof(name));
  98.                                         format(string,sizeof(string),"{002DFF}[Police News]{F5FF00}: Player {FF0000}%s{FFFA00} has been caught by a speedtrap, find him and catch him !",name);
  99.                                         while(playerid <= MAX_PLAYERS)
  100.                                         {
  101.                                             if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282)
  102.                                             {
  103.                                                 SetPlayerMarkerForPlayer(playerid,id,0xFF0000FF);
  104.                                                 SendClientMessage(playerid,0,string);
  105.                                             }
  106.                                             playerid++;
  107.                                         }
  108.                                         //////////////////////////////////////////////////////////////77
  109.                                         //////////////////////////////////////////////////////////////////
  110.                                         //////////////////////////////////////////////////////////////////
  111.                                         /////////////////////////////////////////////////////////////////////
  112.                                         /////////////////////////////////////////////////////////////////77
  113.                                     }
  114.                                 }
  115.                             }
  116.                             i++;
  117.                         }
  118.                     }
  119.                 }
  120.                 else
  121.                 {
  122.                         player[id][Free]--;
  123.                 }
  124.             }
  125.            
  126.         }
  127.         id++;
  128.     }
  129. }
  130. CMD:createspeedtrap(playerid,params[])
  131. {
  132.     new range,text[100],velocity;
  133.     if(!IsPlayerAdmin(playerid))return 0;
  134.     if(sscanf(params,"dis",velocity,range,text))return SendClientMessage(playerid,0xFF000FFF,"USAGE: /createpeedtrap [velocity] [range] [Text]");
  135.     new Float:x,Float:y,Float:z,Float:ang;
  136.     GetPlayerPos(playerid,x,y,z);
  137.     GetPlayerFacingAngle(playerid,ang);
  138.     new i = 0;
  139.     while(i != 500)
  140.     {
  141.         if(trap[i][Exists] == 0)
  142.         {
  143.             SetPlayerPos(playerid,x+5,y,z);
  144.             trap[i][Object] = CreateObject(18880,x,y,z-1,0,0,ang);
  145.             trap[i][Exists] = 1;
  146.             trap[i][Velocity] = velocity;
  147.             trap[i][Range] = range;
  148.             //format(trap[i][Text],100,"%s",text);
  149.             Create3DTextLabel(text,0xFF000FFF,x,y,z+3,60,0,0);
  150.            
  151.             new File[100];
  152.             format(File,sizeof(File),"/Traps/%i.txt",i);
  153.             dini_Create(File);
  154.             dini_FloatSet(File,"x",x);
  155.             dini_FloatSet(File,"y",y);
  156.             dini_FloatSet(File,"z",z);
  157.             dini_FloatSet(File,"ang",ang);
  158.             dini_IntSet(File,"range",range);
  159.             dini_IntSet(File,"velocity",velocity);
  160.             dini_Set(File,"Text",text);
  161.             i = 499;
  162.         }
  163.         i++;
  164.     }
  165.     return 1;
  166. }
  167. public OnFilterScriptExit()
  168. {
  169.     return 1;
  170. }
  171.  
  172.  
  173. public OnPlayerRequestClass(playerid, classid)
  174. {
  175.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  176.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  177.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  178.     return 1;
  179. }
  180.  
  181. public OnPlayerConnect(playerid)
  182. {
  183.     player[playerid][Free] = 0;
  184.     return 1;
  185. }
  186.  
  187. public OnPlayerDisconnect(playerid, reason)
  188. {
  189.     return 1;
  190. }
  191.  
  192. public OnPlayerSpawn(playerid)
  193. {
  194.     return 1;
  195. }
  196.  
  197. public OnPlayerDeath(playerid, killerid, reason)
  198. {
  199.     return 1;
  200. }
  201.  
  202. public OnVehicleSpawn(vehicleid)
  203. {
  204.     return 1;
  205. }
  206.  
  207. public OnVehicleDeath(vehicleid, killerid)
  208. {
  209.     return 1;
  210. }
  211.  
  212. public OnPlayerText(playerid, text[])
  213. {
  214.     return 1;
  215. }
  216.  
  217. public OnPlayerCommandText(playerid, cmdtext[])
  218. {
  219.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  220.     {
  221.         // Do something here
  222.         return 1;
  223.     }
  224.     return 0;
  225. }
  226.  
  227. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  228. {
  229.     return 1;
  230. }
  231.  
  232. public OnPlayerExitVehicle(playerid, vehicleid)
  233. {
  234.     return 1;
  235. }
  236.  
  237. public OnPlayerStateChange(playerid, newstate, oldstate)
  238. {
  239.     return 1;
  240. }
  241.  
  242. public OnPlayerEnterCheckpoint(playerid)
  243. {
  244.     return 1;
  245. }
  246.  
  247. public OnPlayerLeaveCheckpoint(playerid)
  248. {
  249.     return 1;
  250. }
  251.  
  252. public OnPlayerEnterRaceCheckpoint(playerid)
  253. {
  254.     return 1;
  255. }
  256.  
  257. public OnPlayerLeaveRaceCheckpoint(playerid)
  258. {
  259.     return 1;
  260. }
  261.  
  262. public OnRconCommand(cmd[])
  263. {
  264.     return 1;
  265. }
  266.  
  267. public OnPlayerRequestSpawn(playerid)
  268. {
  269.     return 1;
  270. }
  271.  
  272. public OnObjectMoved(objectid)
  273. {
  274.     return 1;
  275. }
  276.  
  277. public OnPlayerObjectMoved(playerid, objectid)
  278. {
  279.     return 1;
  280. }
  281.  
  282. public OnPlayerPickUpPickup(playerid, pickupid)
  283. {
  284.     return 1;
  285. }
  286.  
  287. public OnVehicleMod(playerid, vehicleid, componentid)
  288. {
  289.     return 1;
  290. }
  291.  
  292. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  293. {
  294.     return 1;
  295. }
  296.  
  297. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  298. {
  299.     return 1;
  300. }
  301.  
  302. public OnPlayerSelectedMenuRow(playerid, row)
  303. {
  304.     return 1;
  305. }
  306.  
  307. public OnPlayerExitedMenu(playerid)
  308. {
  309.     return 1;
  310. }
  311.  
  312. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  313. {
  314.     return 1;
  315. }
  316.  
  317. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  318. {
  319.     return 1;
  320. }
  321.  
  322. public OnRconLoginAttempt(ip[], password[], success)
  323. {
  324.     return 1;
  325. }
  326.  
  327. public OnPlayerUpdate(playerid)
  328. {
  329.     return 1;
  330. }
  331.  
  332. public OnPlayerStreamIn(playerid, forplayerid)
  333. {
  334.     return 1;
  335. }
  336.  
  337. public OnPlayerStreamOut(playerid, forplayerid)
  338. {
  339.     return 1;
  340. }
  341.  
  342. public OnVehicleStreamIn(vehicleid, forplayerid)
  343. {
  344.     return 1;
  345. }
  346.  
  347. public OnVehicleStreamOut(vehicleid, forplayerid)
  348. {
  349.     return 1;
  350. }
  351.  
  352. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  353. {
  354.     return 1;
  355. }
  356.  
  357. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  358. {
  359.     return 1;
  360. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement