Quote:
Originally Posted by XHUNTERX
each round can be used 1 time
Stays active for 5 seconds then returns to normal
thanks
|
I also added that after the 5 seconds over the client will be teleported to the place he was when he used the command so he wont get stucked.
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0.1"
bool g_bUsed[MAXPLAYERS + 1] = { false };
float g_fClientPos[MAXPLAYERS + 1][3];
public Plugin myinfo =
{
name = "Self Noclip",
author = "killjoy",
description = "personal noclip for Donators",
version = PLUGIN_VERSION,
url = "http://www.epic-nation.com"
};
public OnPluginStart()
{
RegConsoleCmd("sm_noclipme",NoclipMe,"Toggles noclip on yourself");
HookEvent("round_start", OnRoundStart);
}
public void OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
for (int i = 1; i <= MaxClients; i++)
{
g_bUsed[i] = false;
}
}
public Action NoclipMe(int client, int args)
{
char sAuthID[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID));
GetClientAbsOrigin(client, g_fClientPos[client]);
if( client < 1 || !IsClientInGame(client) || !IsPlayerAlive(client ))
{
ReplyToCommand(client, "\x04[SM] \x05You need to be alive to use noclip");
return Plugin_Handled;
}
if (GetEntityMoveType(client) != MOVETYPE_NOCLIP && !g_bUsed[client])
{
CreateTimer(5.0, StopNoclip, client);
g_bUsed[client] = true;
LogAction(client, client, "%N (%s) Enabled noclip", client, sAuthID);
SetEntityMoveType(client, MOVETYPE_NOCLIP);
ReplyToCommand(client, "\x04[SM] \x05Noclip Enabled");
}
return Plugin_Handled;
}
public Action StopNoclip(Handle timer, int client)
{
SetEntityMoveType(client, MOVETYPE_WALK);
TeleportEntity(client, g_fClientPos[client], NULL_VECTOR, NULL_VECTOR);
PrintToChat(client, "\x04[SM] \x05Noclip Disabled");
}
__________________