Raised This Month: $48 Target: $400
 12% 

Solved L4D2 Admin Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ricksfishin
Senior Member
Join Date: Oct 2017
Old 04-25-2018 , 09:49   L4D2 Admin Only
Reply With Quote #1

Help to make this plugin admin only.
PHP Code:
/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools>
#include <sdktools_functions> 
 
#define SOUND_GRAB        "UI/helpful_event_1.wav"
new g_iVelocity ;
public 
Plugin:myinfo 
{
    
name "Push And Drag",
    
author "Pan Xiaohai",
    
description "<- Description ->",
    
version "1.1",
    
url "<- URL ->"
}

public 
OnPluginStart()
{    
    
g_iVelocity FindSendPropOffs("CBasePlayer""m_vecVelocity[0]");
}
new 
Float:lasttime;
new 
Float:ShoveTime[MAXPLAYERS+1];
new 
KeyBuffer[MAXPLAYERS+1];
new 
KeyState[MAXPLAYERS+1];
new 
GrabedEnt[MAXPLAYERS+1];
new 
Float:GrabEnerge[MAXPLAYERS+1];
new 
Float:KeyTime[MAXPLAYERS+1];
new 
Float:HoldDistance[MAXPLAYERS+1];
public 
OnMapStart()
{
    
PrecacheSound(SOUND_GRABtrue);
}
public 
OnGameFrame()
{
    new 
Float:currenttime=GetEngineTime();
    new 
Float:duration=currenttime-lasttime;
    if(
duration<0.0 || duration>1.0)duration=0.0;
      for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
        {
            if(
GetClientTeam(client)==&& IsPlayerGhost(client))
            {
                
GrabedEnt[client]=0;
            }
            else 
            {
                Do(
clientcurrenttimeduration);
            }
        }
        else
        {
            
GrabedEnt[client]=0;
        }
    }
    
lasttime=currenttime;
}
Do(
client Float:ctimeFloat:duration)
{
    
    new 
button=GetClientButtons(client);
    new 
bool:startgrab=false;
     if(
KeyState[client]==0)
    {
        if((
button IN_USE) && !(KeyBuffer[client] & IN_USE))
        {         
            
KeyState[client]=1;
            
KeyTime[client]=ctime;
            
//PrintToChat(client, "state 1"); 
        
}
    } 
    if(
KeyState[client]==1)
    {
        if(
ctime-KeyTime[client]<0.3)
        {
            if(!(
button IN_USE) && (KeyBuffer[client] & IN_USE))
            {
                
KeyState[client]=2;
                
//PrintToChat(client, "state 2");
            
}
        }
        else
        {
            
KeyState[client]=0;
        }
         
    } 
    if(
KeyState[client]==2)
    {
        if(
ctime-KeyTime[client]<0.3)
        {
            if((
button IN_USE) && !(KeyBuffer[client] & IN_USE))
            {                
                
KeyState[client]=3;
                
startgrab=true;
                 
//PrintToChat(client, "state 3");
            
}
        }
        else
        {
            
KeyState[client]=0;
        }
    }
    if(
KeyState[client]==&& !(button IN_USE))
    {
        
KeyState[client]=0;
        
//PrintToChat(client, "state 0");
    
}
    new 
bool:grabed=false;
    if(
GrabedEnt[client]>&& IsValidEdict(GrabedEnt[client]))grabed=true;
    if(
KeyState[client]==&& grabed )
    {    
        if((
button IN_ATTACK2))ThrowEnt(clientGrabedEnt[client], ctime2000.0);
        else 
ThrowEnt(clientGrabedEnt[client], ctime100.0);
        
KeyState[client]=0;
        
GrabedEnt[client]=0;
        
grabed=false;
    }
     
    
KeyBuffer[client]=button;
 
    if (
startgrab
    {
        
GrabedEnt[client]=GetEnt(clientctime);
        if(
GrabedEnt[client]>0)
        {
            
grabed=true;
            
decl Float:vOrigin[3];
            
GetClientEyePosition(client,vOrigin);
            
EmitSoundToAll(SOUND_GRAB0SNDCHAN_WEAPONSNDLEVEL_TRAFFICSND_NOFLAGSSNDVOL_NORMAL100_vOriginNULL_VECTORfalse0.0);    
        }
    }
    if(
grabed)
    {
        new 
bool:throw=false;
        if(
button IN_ATTACK)
        {
            throw=
true;
        }
        
        if(throw)
        {    
            
ThrowEnt(clientGrabedEnt[client], ctime2000.0);
            
GrabedEnt[client]=0;
        }
        else
        {
            
GrabEnt(clientGrabedEnt[client], duration);
            if(
GrabEnerge[client]<ctime)
            {
                
GrabedEnt[client]=0;
            }
        }
    }
    else
    {
        
GrabedEnt[client]=0;
    }
      
}
GrabEnt(cliententFloat:duration)
{
    
decl Float:vAngles[3];
    
decl Float:vOrigin[3];
    
decl Float:pos[3];
    
decl Float:velocity[3];
    
    
GetClientEyePosition(client,vOrigin);
    
GetClientEyeAngles(clientvAngles);
    
GetEntPropVector(entProp_Send"m_vecOrigin"pos);
    
GetEntDataVector(clientg_iVelocityvelocity);
    
    
ScaleVector(velocityduration*4.0);
    
AddVectors(vOriginvelocity ,vOrigin);

    
GetAngleVectors(vAnglesvAnglesNULL_VECTORNULL_VECTOR);
    
NormalizeVector(vAnglesvAngles);
    
ScaleVector(vAnglesHoldDistance[client]);
    
AddVectors(vOriginvAnglesvOrigin);
    new 
Float:dis=GetVectorDistance(vOriginpos);
    new 
Float:force=0.0;        
    if(
dis>100.0)dis=100.0;
    
force=0.2*dis*dis;
    
//PrintToChatAll("%f, %f", dis, force);
    
SubtractVectors(vOriginposvelocity);
    
NormalizeVector(velocityvelocity);
    
ScaleVector(velocityforce);
    
TeleportEntity(entNULL_VECTORNULL_VECTORvelocity);

}
ThrowEnt(cliententFloat:ctimeFloat:force)
{    
    
//PrintToChat(client, "throw");
    
decl Float:vAngles[3];
    
decl Float:vOrigin[3];
    
decl Float:pos[3];
    
GetClientEyePosition(client,vOrigin);
    
GetClientEyeAngles(clientvAngles);
    
GetEntPropVector(entProp_Send"m_vecOrigin"pos);
    
    new 
Float:dis=GetVectorDistance(vOriginpos);
    if(
dis>1000.0)dis=1000.0;
    
force=force*(1000.0-dis)/1000.0+200.0;
    
//PrintToChatAll("%f %f",dis, force);
    
decl Float:volicity[3];
    
SubtractVectors(posvOriginvolicity);
    
NormalizeVector(volicityvolicity);
    
ScaleVector(volicityforce);
    
TeleportEntity(entNULL_VECTORNULL_VECTORvolicity);
    
    
decl String:classname[64];
    
GetEdictClassname(entclassname64);        
    if(
StrContains(classname"prop_")!=-1)
    {
        
SetEntPropEnt(entProp_Data"m_hPhysicsAttacker"client);
        
SetEntPropFloat(entProp_Data"m_flLastPhysicsInfluenceTime"ctime);
    }
}
GetEnt(clientFloat:ctime)
{
    new 
ent=0;
    
    
decl Float:vAngles[3];
    
decl Float:vOrigin[3];
    
decl Float:pos[3];

    
GetClientEyePosition(client,vOrigin);
    
GetClientEyeAngles(clientvAngles);

    new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SOLIDRayType_InfiniteTraceRayDontHitSelfclient);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(postrace);
        
ent=TR_GetEntityIndex(trace);
        if(
ent>0)
        {
            new 
Float:dis=GetVectorDistance(vOriginpos);
            
            if(
dis<1000.0)
            {
                
decl String:classname[64];
                
GetEdictClassname(entclassname64);        
                if(
StrContains(classname"ladder")!=-1){ent=0;}
                else if(
StrContains(classname"door")!=-1){ent=0;}
                else if(
StrContains(classname"infected")!=-1){ent=0;}
                else 
                {             
                    
HoldDistance[client]=100.0;
                    
GrabEnerge[client]=ctime+10.0;
                    if(
StrContains(classname"prop_")!=-1)
                    {
                        
SetEntPropEnt(entProp_Data"m_hPhysicsAttacker"client);
                        
SetEntPropFloat(entProp_Data"m_flLastPhysicsInfluenceTime"ctime);
                        
//PrintToChatAll("You grabbed a prop");
                        
HoldDistance[client]=120.0;
                        
GrabEnerge[client]=ctime+15.0;                        
                    }
                    if(
StrContains(classname"car")!=-1)
                    {
                        
HoldDistance[client]=200.0;
                        
GrabEnerge[client]=ctime+10.0;        
                        
//PrintToChatAll("You grabbed a car");
                    
}
                    if(
StrContains(classname"weapon_")!=-1)
                    {
                        
HoldDistance[client]=50.0;
                        
GrabEnerge[client]=ctime+30.0;
                        
//PrintToChatAll("You grabbed a weapon");
                    
}
                    if(
StrContains(classname"player")!=-1)
                    {
                        
HoldDistance[client]=70.0;
                        
GrabEnerge[client]=ctime+15.0;
                        
//PrintToChatAll("You grabbed a player");
                    
}

                    if(
ent<=MaxClients)    
                    {
                        if(
GetClientTeam(client)==GetClientTeam(ent))
                        {
                            
PrintHintText(client"You grabbed %N"ent);
                            
PrintHintText(ent"%N grabbed you"client);                            
                        }
                        else
                        {
                            
PrintHintText(client"You can not grab emney!");
                            
ent=0;
                        }
                    }
                    else
                    {
                        
PrintHintText(client"You grabbed something!");
                    }
                    
                }
            }
            else
            {
                
ent=0;
                
PrintHintText(client"It is too far");
            }
        }
        else
        {
            
PrintHintText(client"You grabbed nothing!");
        }
    }
    
CloseHandle(trace)
    
    return 
ent;
}
bool:IsPlayerGhost (client)
{
    if (
GetEntData(clientFindSendPropInfo("CTerrorPlayer""m_isGhost"), 1))
        return 
true;
    return 
false;
}
public 
bool:TraceRayDontHitSelf(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    return 
true;


Last edited by ricksfishin; 04-26-2018 at 09:10.
ricksfishin is offline
Dragokas
Senior Member
Join Date: Nov 2017
Location: Ukraine
Old 04-25-2018 , 11:23   Re: L4D2 Admin Only
Reply With Quote #2

Put somewhere IsClientAdmin(), like instead:
Code:
if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
write:
Code:
if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client) && IsClientAdmin(client))
Code:
bool IsClientAdmin(int client)
{
//	if (!IsClientInGame(client)) return false;
	return GetUserAdmin(client) != INVALID_ADMIN_ID;
}
__________________
Expert of CMD/VBS/VB6. Malware analyst.
Dragokas is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 04-25-2018 , 13:02   Re: L4D2 Admin Only
Reply With Quote #3

I'm sure it's me I can get this to work and compile, if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client) && IsClientAdmin(client))

No luck with this,bool

bool IsClientAdmin(int client)
{
// if (!IsClientInGame(client)) return false;
return GetUserAdmin(client) != INVALID_ADMIN_ID;
}
just get error's not in right place maybe?
bool IsClientAdmin(int client), declaration of a local variable must appear in a compound block
undefined symbol "IsClientAdmin, if i define it then bool is undefined.etc
Thanks for reply Dragokas.

Last edited by ricksfishin; 04-25-2018 at 13:02.
ricksfishin is offline
Dragokas
Senior Member
Join Date: Nov 2017
Location: Ukraine
Old 04-25-2018 , 14:04   Re: L4D2 Admin Only
Reply With Quote #4

You must place IsClientAdmin function somewhere: e.g. at the end of your script.

Or, you can just use
Code:
( GetUserAdmin(client) != INVALID_ADMIN_ID )
instead of
Code:
IsClientAdmin(client)
__________________
Expert of CMD/VBS/VB6. Malware analyst.

Last edited by Dragokas; 04-25-2018 at 14:05.
Dragokas is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 04-25-2018 , 16:01   Re: L4D2 Admin Only
Reply With Quote #5

Awesome Works great thank you very much Dragokas.
ricksfishin is offline
Alexmy
Senior Member
Join Date: Oct 2014
Location: Russian Federation, Omsk
Old 04-26-2018 , 06:30   Re: Solved L4D2 Admin Only
Reply With Quote #6

PHP Code:
if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client)) 
replace
PHP Code:
if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client) && GetUserFlagBits(client) > 0
Alexmy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:29.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode