Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- #include <sdktools>
- //#include <smlib>
- #pragma semicolon 1;
- public Plugin:myinfo =
- {
- name = "OperationL2P Flash Test",
- author = "OperationL2P.com",
- description = "",
- version = "0.1",
- url = ""
- };
- #define FragColor {225,225,225,255}
- #define N MAXPLAYERS+1
- new g_BeamSprite = -1;
- new g_HaloSprite = -1;
- new Float:PositionLast[N][3];
- new bool:ClientView[N];
- new greyColor[4] = {128, 128, 128, 255};
- new Float:ClientAngles[N][3];
- new Float:ClientOrigins[N][3];
- new bool_sentinel[MAXPLAYERS+1];//between tele and explode? branching diagram
- new bool_dontStart[MAXPLAYERS+1];
- new bool_camDisable[MAXPLAYERS+1];
- new Float:ClientTargetAngles[N][3];
- new Float:ClientTargetOrigins[N][3];
- //BY DEFAULT ARRAYS INITIALIZED TO ZERO;
- new String:ClientNadeName[N][64];
- new BeamSprite;
- new Handle:specTimers[MAXPLAYERS+1];
- /******
- *Load*
- *******/
- public OnMapStart() BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt");
- public SaveTargetPosition(client)
- {
- GetClientEyeAngles(client, Float:ClientTargetAngles[client]);
- GetClientAbsOrigin(client, Float:ClientTargetOrigins[client]);
- }
- public LoadTargetPosition(client)
- {
- TeleportEntity(client, Float:ClientTargetOrigins[client], Float:ClientTargetAngles[client], NULL_VECTOR);/////
- PositionLast[client] = ClientTargetOrigins[client];
- }
- public SavePosition(client)
- {
- GetClientEyeAngles(client, Float:ClientAngles[client]);
- GetClientAbsOrigin(client, Float:ClientOrigins[client]);
- }
- public LoadPosition(client)
- {
- TeleportEntity(client, Float:ClientOrigins[client], Float:ClientAngles[client], NULL_VECTOR);
- }
- public StartView(client)
- {
- if(!ClientView[client])
- {
- if(IsClientInGame(client))
- {
- LoadTargetPosition(client);
- }
- ClientView[client] = true;
- }
- }
- public StopView(client)
- {
- if(ClientView[client])
- {
- if(IsClientInGame(client))
- {
- LoadPosition(client);
- }
- ClientView[client] = false;
- }
- }
- public OnPluginStart()
- {
- RegConsoleCmd("sm_camera", ToggleViewCmd, "Toggle between regular and projectile view");
- HookEvent("weapon_fire", OnShot);
- HookEvent("player_spawned", OnPlayerSpawn);
- HookEvent("inspect_weapon", OnInspect);
- }
- public OnClientDisconnect(client)
- {
- StopView(client);
- }
- public IsGrenadeName(const String:name[], const String:postfix[])
- {
- new String:buffer[64];
- Format(buffer, 63, "%s%s", "hegrenade", postfix);
- if(StrEqual(name, buffer)) return true;
- Format(buffer, 63, "%s%s", "smokegrenade", postfix);
- if(StrEqual(name, buffer)) return true;
- Format(buffer, 63, "%s%s", "flashbang", postfix);
- if(StrEqual(name, buffer)) return true;
- else return false;
- }
- public OnEntityCreated(iEntity, const String:classname[])
- {
- if(IsGrenadeName(classname, "_projectile")) SDKHook(iEntity, SDKHook_SpawnPost, OnEntitySpawned);
- }
- public OnEntitySpawned(iGrenade)
- {
- new client = GetEntPropEnt(iGrenade, Prop_Send, "m_hOwnerEntity");
- //Client_ChangeToLastWeapon(client);
- if (bool_camDisable[client] == 0){
- if (!ClientView[client]){
- SavePosition(client);
- CreateTimer(0.1, StartViewAction, client);
- } else {
- TeleportEntity(iGrenade, {0,0,0}, NULL_VECTOR, {0,0,0});
- }
- }
- TE_SetupBeamFollow(iGrenade, BeamSprite, 0, Float:20.0, Float:3.0, Float:3.0, 5, FragColor);
- TE_SendToAll();
- }
- public Action:StartViewAction(Handle:timer, any:client)
- {
- StartView(client);
- }
- public Action:StopViewAction(Handle:timer, any:client)
- {
- StopView(client);
- specTimers[client] = INVALID_HANDLE;
- }
- public Action:GiveNade(Handle:timer, any:client)
- {
- //new String:buffer[128] =
- //"give weapon_";
- //"weapon_";
- //StrCat(buffer, 127, ClientNadeName[client]);
- //FakeClientCommand(client, buffer);
- //Client_GiveWeapon(client, buffer);
- }
- public OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- PrintToChatAll("Event: player_spawned");
- if(IsClientInGame(client)) SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
- }
- public OnShot(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new String:weapon[32];
- GetEventString(event, "weapon", String:weapon, 32);
- if(
- !IsGrenadeName(weapon, "")
- && IsClientInGame(client)) SaveTargetPosition(client);
- else {
- strcopy(ClientNadeName[client], 63, weapon);
- CreateTimer(0.2, GiveNade, client);
- }
- }
- public OnInspect(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if (ClientView[client])
- {
- specTimers[client] = CreateTimer(0.1, StopViewAction, client);
- }
- }
- public Action:ToggleViewCmd(client, args)
- {
- // Client has access to toggle commands
- if(IsValidClient(client) && CheckCommandAccess(client, "sm_camera", 0, true))
- {
- // Toggle projectile view
- bool_camDisable[client] = !bool_camDisable[client];
- // Client just disabled projectile view
- if(bool_camDisable[client])
- {
- PrintToChat(client, "%s", "Camera disabled");
- }
- else
- {
- PrintToChat(client, "%s", "Camera enabled");
- }
- }
- else
- PrintToChat(client, "\x01\x0B\x04[SM]\x01 %t", "access");
- return Plugin_Handled;
- }
- /********
- *Stocks*
- *********/
- stock IsValidClient(client)
- {
- if(client > 0 && client <= MAXPLAYERS && IsClientInGame(client))
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement