Script for Admin Cod4 server

Have a question you need to ask? Need help? Ask here!

Moderator: Core Staff

Post Reply
DeltaSpades
CJ Wannabe
CJ Wannabe
Posts: 44
Joined: January 10th, 2013, 7:07 pm

Script for Admin Cod4 server

Post by DeltaSpades » February 6th, 2013, 4:26 pm

Does anyone know how to make it so that only Admins can use a script

I've added the Admin pick up script to my server but right now all on the server can use the pick up but i only want to make it so that the Admin is the only one who can use the pick up script

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script for Admin Cod4 server

Post by Drofder2004 » February 6th, 2013, 7:49 pm

Post the full script. A simple check on admin status should be easy to implement.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

DeltaSpades
CJ Wannabe
CJ Wannabe
Posts: 44
Joined: January 10th, 2013, 7:07 pm

Re: Script for Admin Cod4 server

Post by DeltaSpades » February 6th, 2013, 8:15 pm

The script is

Code: Select all

/* ______      ____      __
  / ____/___  / __ \    / /_  ______ ___  ____  ___  _____ _________  ____ ___
 / /   / __ \/ / / /_  / / / / / __ `__ \/ __ \/ _ \/ ___// ___/ __ \/ __ `__ \
/ /___/ /_/ / /_/ / /_/ / /_/ / / / / / / /_/ /  __/ /  _/ /__/ /_/ / / / / / /
\____/\____/_____/\____/\__,_/_/ /_/ /_/ .___/\___/_/  (_)___/\____/_/ /_/ /_/
                                      /*/
 
#include codjumper\_cj_utility;
 
init()
{
        /* You may use this file to add your custom             *
         * scripts without requiring a stock file hack. *
         * Thread your functions inside 'init()' and            *
         * place your custom functions below.           */
     
 
         thread onPlayerConnect();
       
 
 
}
 
onPlayerConnect()
{
        for(;;)
        {
                level waittill( "connected", Player );
               
                player thread onPlayerSpawned();
        }
}
 
onPlayerSpawned()
{
        for(;;)
        {
                self waittill( "spawned_Player" );
       
                self thread _AdminPickup();
       
        }
}
       
_AdminPickup()
{
   self endon("disconnect");
 
        while(1)
        {        
                while(!self secondaryoffhandButtonPressed())
                {
                        wait 0.05;
                }
               
                start = self getEye();
                end = start + maps\mp\_utility::vector_scale(anglestoforward(self getPlayerAngles()), 999999);
                trace = bulletTrace(start, end, true, self);
                dist = distance(start, trace["position"]);
 
                ent = trace["entity"];
 
                if(isDefined(ent) && ent.classname == "player")
                {
                        if(isPlayer(ent))
                                ent IPrintLn("^1You've been picked up by the admin ^2" + self.name + "^1!");
 
                        self IPrintLn("^1You've picked up ^2" + ent.name + "^1!");
 
                        linker = spawn("script_origin", trace["position"]);
                        ent linkto(linker);
 
                        while(self secondaryoffhandButtonPressed())
                        {
                                wait 0.05;
                        }
 
                        while(!self secondaryoffhandButtonPressed() && isDefined(ent))
                        {
                                start = self getEye();
                                end = start + maps\mp\_utility::vector_scale(anglestoforward(self getPlayerAngles()), dist);
                                trace = bulletTrace(start, end, false, ent);
                                dist = distance(start, trace["position"]);
 
                                if(self fragButtonPressed() && !self adsButtonPressed())
                                        dist -= 15;
                                else if(self fragButtonPressed() && self adsButtonPressed())
                                        dist += 15;
 
                                end = start + maps\mp\_utility::vector_Scale(anglestoforward(self getPlayerAngles()), dist);
                                trace = bulletTrace(start, end, false, ent);
                                linker.origin = trace["position"];
 
                                wait 0.05;
                        }
     
                        if(isDefined(ent))
                        {
                                ent unlink();
                                       
                                if(isPlayer(ent))
                                        ent IPrintLn("^1You've been dropped by the admin ^2" + self.name + "^1!");
 
                                self IPrintLn("^1You've dropped ^2" + ent.name + "^1!");
                        }
 
                        linker delete();
                }
 
                while(self secondaryoffhandButtonPressed())
                {
                        wait 0.05;
                }
        }
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script for Admin Cod4 server

Post by Drofder2004 » February 7th, 2013, 2:48 am

Added DVAR to adjust level 'All/VIP/Admin'. Default VIP.
(adminPickup)

Code: Select all

/* ______      ____      __
  / ____/___  / __ \    / /_  ______ ___  ____  ___  _____ _________  ____ ___
 / /   / __ \/ / / /_  / / / / / __ `__ \/ __ \/ _ \/ ___// ___/ __ \/ __ `__ \
/ /___/ /_/ / /_/ / /_/ / /_/ / / / / / / /_/ /  __/ /  _/ /__/ /_/ / / / / / /
\____/\____/_____/\____/\__,_/_/ /_/ /_/ .___/\___/_/  (_)___/\____/_/ /_/ /_/
                                      /*/
 
#include codjumper\_cj_utility;
 
init()
{
        /* You may use this file to add your custom             *
         * scripts without requiring a stock file hack. *
         * Thread your functions inside 'init()' and            *
         * place your custom functions below.           */
     
         /* Admin Pickup Dvar, 0 = All, 1 = Admin/VIP, 2 = Admin Only */
         if(getDvar("adminPickup") == "")
                  setDvar("adminPickup", 1);
 
         thread onPlayerConnect();
}
 
onPlayerConnect()
{
        for(;;)
        {
                level waittill( "connected", Player );
               
                player thread onPlayerSpawned();
        }
}
 
onPlayerSpawned()
{
        for(;;)
        {
                self waittill( "spawned_Player" );
       
                if(self.cj["status"] >= getDvarInt("adminPickup"))
                        self thread _AdminPickup();
       
        }
}
       
_AdminPickup()
{
   self endon("disconnect");
 
        while(1)
        {        
                while(!self secondaryoffhandButtonPressed())
                {
                        wait 0.05;
                }
               
                start = self getEye();
                end = start + maps\mp\_utility::vector_scale(anglestoforward(self getPlayerAngles()), 999999);
                trace = bulletTrace(start, end, true, self);
                dist = distance(start, trace["position"]);
 
                ent = trace["entity"];
 
                if(isDefined(ent) && ent.classname == "player")
                {
                        if(isPlayer(ent))
                                ent IPrintLn("^1You've been picked up by the admin ^2" + self.name + "^1!");
 
                        self IPrintLn("^1You've picked up ^2" + ent.name + "^1!");
 
                        linker = spawn("script_origin", trace["position"]);
                        ent linkto(linker);
 
                        while(self secondaryoffhandButtonPressed())
                        {
                                wait 0.05;
                        }
 
                        while(!self secondaryoffhandButtonPressed() && isDefined(ent))
                        {
                                start = self getEye();
                                end = start + maps\mp\_utility::vector_scale(anglestoforward(self getPlayerAngles()), dist);
                                trace = bulletTrace(start, end, false, ent);
                                dist = distance(start, trace["position"]);
 
                                if(self fragButtonPressed() && !self adsButtonPressed())
                                        dist -= 15;
                                else if(self fragButtonPressed() && self adsButtonPressed())
                                        dist += 15;
 
                                end = start + maps\mp\_utility::vector_Scale(anglestoforward(self getPlayerAngles()), dist);
                                trace = bulletTrace(start, end, false, ent);
                                linker.origin = trace["position"];
 
                                wait 0.05;
                        }
     
                        if(isDefined(ent))
                        {
                                ent unlink();
                                       
                                if(isPlayer(ent))
                                        ent IPrintLn("^1You've been dropped by the admin ^2" + self.name + "^1!");
 
                                self IPrintLn("^1You've dropped ^2" + ent.name + "^1!");
                        }
 
                        linker delete();
                }
 
                while(self secondaryoffhandButtonPressed())
                {
                        wait 0.05;
                }
        }
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests