Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #include <sdkhooks>
- int dead;
- int Ghost[MAXPLAYERS+1];
- #define FFADE_IN 0x0002 // Fade in
- #define FFADE_MODULATE 0x0004 // Modulate
- public Plugin:myinfo =
- {
- name = "Ghost",
- author = "ONIONZZZ",
- description = "Play as a ghost and fly whilst dead",
- version = "2.2.2",
- url = "https://dominationservers.com"
- };
- public OnPluginStart()
- {
- HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
- HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
- HookEvent("player_spawn", Event_PlayerSpawn);
- HookEvent("player_death", Event_PlayerDeath);
- RegConsoleCmd("sm_ghost", Command_Ghost);
- AddNormalSoundHook(blockSound);
- }
- public OnClientPutInServer(client)
- {
- SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
- SDKHook(client, SDKHook_TraceAttack, OnTakedamage);
- }
- public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
- {
- dead = 0;
- }
- public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- dead = 1;
- }
- public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(Ghost[client])
- {
- CreateTimer(0.5, fixSolids, client); // this overwrites noblock etc..
- Ghost[client] = 0;
- }
- }
- public Action fixSolids(Handle timer, any client)
- {
- SetEntProp(client, Prop_Data, "m_CollisionGroup", 1);
- SetEntProp(client, Prop_Data, "m_nSolidType", 0);
- SetEntProp(client, Prop_Send, "m_usSolidFlags", 4);
- ScreenEffect(client, 0, 0, FFADE_IN | FFADE_MODULATE, 255, 255, 255, 255);
- }
- public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}Type {darkred}!ghost {default}to move around, and hold {lime}E {default}to fly!");
- }
- public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
- {
- if(GetEntProp(client, Prop_Send, "m_lifeState") == 1)
- {
- MoveType movetype = GetEntityMoveType(client);
- if((buttons & IN_USE))
- {
- if(movetype != MOVETYPE_NOCLIP)
- {
- SetEntityMoveType(client, MOVETYPE_NOCLIP);
- }
- }else{
- if(movetype != MOVETYPE_WALK)
- {
- SetEntityMoveType(client, MOVETYPE_WALK);
- }
- }
- buttons &= ~IN_USE;
- }
- return Plugin_Continue;
- }
- public Action Command_Ghost(client, args)
- {
- if(dead)
- {
- if (!IsPlayerAlive(client))
- {
- if(GetClientTeam(client) > 1)
- {
- Ghost[client] = 1;
- CS_RespawnPlayer(client);
- int weaponIndex;
- for (new i = 0; i <= 3; i++)
- {
- if ((weaponIndex = GetPlayerWeaponSlot(client, i)) != -1)
- {
- RemovePlayerItem(client, weaponIndex);
- RemoveEdict(weaponIndex);
- }
- }
- GivePlayerItem(client, "weapon_knife");
- SetEntProp(client, Prop_Send, "m_lifeState", 1);
- ScreenEffect(client, 100, 1000000000, FFADE_IN | FFADE_MODULATE, 0, 0, 0, 150);
- PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You are now {lime}Ghosted{default}.");
- }
- else
- {
- PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You must be on a team to use this{default}.");
- }
- }
- else
- {
- PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You must be dead to use this{default}.");
- }
- }
- else
- {
- PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}Please wait till next round{default}.");
- }
- return Plugin_Handled;
- }
- stock void ScreenEffect(int client, int duration, int hold_time, int flag, int red, int green, int blue, int alpha)
- {
- Handle hFade = INVALID_HANDLE;
- if(client)
- {
- hFade = StartMessageOne("Fade", client);
- }
- else
- {
- hFade = StartMessageAll("Fade");
- }
- if(hFade != INVALID_HANDLE)
- {
- if(GetUserMessageType() == UM_Protobuf)
- {
- int clr[4];
- clr[0]=red;
- clr[1]=green;
- clr[2]=blue;
- clr[3]=alpha;
- PbSetInt(hFade, "duration", duration);
- PbSetInt(hFade, "hold_time", hold_time);
- PbSetInt(hFade, "flags", flag);
- PbSetColor(hFade, "clr", clr);
- }
- EndMessage();
- }
- }
- public Action:OnWeaponCanUse(client, weapon)
- {
- if(GetEntProp(client, Prop_Send, "m_lifeState") == 1)
- {
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action OnTakedamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- if(GetEntProp(victim, Prop_Send, "m_lifeState") == 1)
- {
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action blockSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
- {
- if (IsValidClient(entity))
- {
- if(GetEntProp(entity, Prop_Send, "m_lifeState"))
- {
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- stock bool:IsValidClient(client, bool:nobots = true)
- {
- if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
- {
- return false;
- }
- return IsClientInGame(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement