Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <sscanf>
- enum speedtrap
- {
- Exists,
- Range,
- Velocity,
- Object
- };
- enum PLAYERS
- {
- Free
- };
- new trap[500][speedtrap];
- forward TrapUpdate();
- new player[MAX_PLAYERS][PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Speed TRAPS BY LCP9");
- print("--------------------------------------\n");
- new i = 0;
- while(i != 500)
- {
- new File[100];
- format(File,sizeof(File),"/Traps/%i.txt",i);
- if(dini_Exists(File))
- {
- new Float:x = dini_Float(File,"x");
- new Float:y = dini_Float(File,"y");
- new Float:z = dini_Float(File,"z");
- new Float:ang = dini_Float(File,"ang");
- new text[100];
- format(text,sizeof(text),"%s",dini_Get(File,"Text"));
- trap[i][Exists] = 1;
- trap[i][Velocity] = dini_Int(File,"velocity");
- trap[i][Range] = dini_Int(File,"range");
- trap[i][Object] = CreateObject(18880,x,y,z-1,0,0,ang);
- Create3DTextLabel(text,0xFF000FFF,x,y,z+3,60,0,0);
- }
- i++;
- }
- SetTimer("TrapUpdate",1000,1);
- return 1;
- }
- public TrapUpdate()
- {
- new id = 0;
- while(id <= MAX_PLAYERS)
- {
- if(GetPlayerVehicleSeat(id) == 0)
- {
- if(GetPlayerSkin(id) != 280 && GetPlayerSkin(id) != 281 && GetPlayerSkin(id) != 282)
- {
- if(player[id][Free] == 0)
- {
- if(IsPlayerInAnyVehicle(id))
- {
- new Float:x,Float:y,Float:z;
- GetVehicleVelocity(GetPlayerVehicleID(id),x,y,z);
- new i = 0;
- while(i <= 500)
- {
- if(trap[i][Exists] == 1)
- {
- new Float:X,Float:Y,Float:Z;
- GetObjectPos(trap[i][Object],X,Y,Z);
- if(IsPlayerInRangeOfPoint(id,trap[i][Range],X,Y,Z))
- {
- if(floatsqroot((x*x)+(y*y)+(z*z))*156.666667 > trap[i][Velocity])
- {
- SetPlayerWantedLevel(id,GetPlayerWantedLevel(id) + 1);
- player[id][Free] = 3;
- i = 600;
- SendClientMessage(id,0xFF0000FF,"You are caught by a speed trap, slow down.");
- /////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- new playerid = 0;
- new string[MAX_PLAYER_NAME + 100];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(id,name,sizeof(name));
- format(string,sizeof(string),"{002DFF}[Police News]{F5FF00}: Player {FF0000}%s{FFFA00} has been caught by a speedtrap, find him and catch him !",name);
- while(playerid <= MAX_PLAYERS)
- {
- if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282)
- {
- SetPlayerMarkerForPlayer(playerid,id,0xFF0000FF);
- SendClientMessage(playerid,0,string);
- }
- playerid++;
- }
- //////////////////////////////////////////////////////////////77
- //////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////77
- }
- }
- }
- i++;
- }
- }
- }
- else
- {
- player[id][Free]--;
- }
- }
- }
- id++;
- }
- }
- CMD:createspeedtrap(playerid,params[])
- {
- new range,text[100],velocity;
- if(!IsPlayerAdmin(playerid))return 0;
- if(sscanf(params,"dis",velocity,range,text))return SendClientMessage(playerid,0xFF000FFF,"USAGE: /createpeedtrap [velocity] [range] [Text]");
- new Float:x,Float:y,Float:z,Float:ang;
- GetPlayerPos(playerid,x,y,z);
- GetPlayerFacingAngle(playerid,ang);
- new i = 0;
- while(i != 500)
- {
- if(trap[i][Exists] == 0)
- {
- SetPlayerPos(playerid,x+5,y,z);
- trap[i][Object] = CreateObject(18880,x,y,z-1,0,0,ang);
- trap[i][Exists] = 1;
- trap[i][Velocity] = velocity;
- trap[i][Range] = range;
- //format(trap[i][Text],100,"%s",text);
- Create3DTextLabel(text,0xFF000FFF,x,y,z+3,60,0,0);
- new File[100];
- format(File,sizeof(File),"/Traps/%i.txt",i);
- dini_Create(File);
- dini_FloatSet(File,"x",x);
- dini_FloatSet(File,"y",y);
- dini_FloatSet(File,"z",z);
- dini_FloatSet(File,"ang",ang);
- dini_IntSet(File,"range",range);
- dini_IntSet(File,"velocity",velocity);
- dini_Set(File,"Text",text);
- i = 499;
- }
- i++;
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- player[playerid][Free] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement