Knife Invisible – Deagle War v1.1b




About:

 

KKINV Is a simple mod kind of fun, each user can use twice in a round 15 seconds of invisibly in which he has a knife only.

 

Could be used in side of mb_chrono's MB_Bullettime

 

This is my first script I have done, it was more for tutorial reasons to learn eventscript and es_tools, but at least something good came out of it :D.

 

I can't really say I did it all by myself since I had tons of help.

  

Key settings:
users can type "!inv" or "bind key "say !inv" " to activate the invisibility + knife for 15 sec.

Requirements:
Eventscripts 1.5+

ES_Tools v.418



Installation:
Copy folder kkinv into the eventscript directory from the zip'd file.

 

This script requires the following in your autoexec.cfg

Code:

es_load mb_kkinv

// recommended to change map so all users get popup!

 

 

* * * IF mani_admin_plugin with es_tools you should run it threw metamod !!! * * *

see fix: [WORKAROUND] How to fix Mani not working with EST

 


Thanks:
Thanks to all the people for helping me:

"OldManCan'tFight" for the mod idea and the push.

Everyone in the IRC channel who helped me allot,

"Anomaly" who really pointed me and walked me threw it.

All the scripts I look at to learn I can't mention one because I learned from each one allot and Mattie's wonderful forum.


CODE:

//**************************************************************//

// Knife Invisible - Deagle War                                 //

// v1.0b                                                        //

//                                                              //

// as you can see this is my first mod,                         //

// I did it as a tutorial for new scripter like myself who      //

// want to start but never scripted before.                     //

// it should give you a basic idea of simple events, keygroups  //

// and some block samples, I hope to make more tutorials each   //

// time with new code.                                          //

// I will try to make them as simple as possible to             //

// understand so users will be able to take ideas and           //

// implement them right away.                                   //

//                                                              //

//  as I said I am a new scripter so I am sure there are        //

//  better ways to do things and commands I really              //

//  don't know yet so if you want to make the script simpler    //

//  for understanding so I can learn too feel free.             //

//                                                              //

//  Thanks to all the people for helping me:                    //

//  "OldManCan'tFight" for the mod idea and the push            //

//  everyone in the IRC channel who helped me allot             //

//  "Anomaly" who realy pointed me and walked me threw it.      //

//  all the scripts I look at to learn I cant mention one       //

//  because I learned from each one allot and Mattie's          //

//  wonderful forum.                                            //

//                                                              //

// http://www.eventscripts.com  wiki for eventscripts           //

// http://www.eventscripts.com/pages/ESTools wiki for es_tools  //

// http://forums.mattie.info/cs/forums   mattes forum           //

// IRC channel: irc://irc.sourceplugins.com/eventscripts        //

// http://addons.eventscripts.com/addons/all add-ons list       //

//**************************************************************//

// Key settings:

// users can type "!inv" or "bind key "say !inv" " to activate the invisibility + knife for 15 sec.

//

// Requirements:

// Eventscripts 1.5+

// ES_Tools v.418

//

// Installation:

// Copy the files from the zip using the same file structure. This script requires the following in your autoexec.cfg

//

// use command line to load :

// es_load mb_kkinv

// recommended to change map so all users get popup!

// * * * IF mani_admin_plugin with es_tools you should run it threw metamod !!! * * *

// see fix: [WORKAROUND] How to fix Mani not working with EST

//          http://forums.mattie.info/cs/forums/viewtopic.php?t=16723

 

 

// this first block that starts when script is run

block load

{

      es_xload popup

      // Creates and/or sets the named variable to the value

      es_xset es_kkinv_version 1.1b

      // Makes a cvar public so you can see it on HLSW or game-monitor

      es_xmakepublic es_kkinv_version

      es_xset auser 0

      es_xsetinfo timeru 0

      es_xsetinfo inv_count 0

      es_xsetinfo key_exist 0

      es_xsetinfo user_alive 0

      es_xmsg #multi #green [kkinv]#default has been loaded!

      // create main keygoup

      es_xkeygroupcreate invu

      // Registers a console command that will initiate the specified block

      es_xregcmd uninv kkinv/uninv "run uinv block"

      es_xsetinfo kkinv_userid 0

      est_enable_weapon_restrictions 1

      es_xsetinfo round_number 0

      es_xsetinfo roundnum 0

      es_xsetinfo spawnc 0

      // create popup name

      popup create popkkinv

      // Now that the popup has been created, let us add some visible content to it:

      popup addline popkkinv "This Server Is Running : I'mSoBad's - Knife Invisible Deagle War"

      // To create an empty line to a popup, add a space to it:

      popup addline popkkinv " "

      popup addline popkkinv "You can Only use invisibilty twice every Round !!!"

      popup addline popkkinv "type !inv or bind key say !inv to run invisibility "

      popup addline popkkinv " "

      popup addline popkkinv "Have Fun!"

      popup addline popkkinv "press 0 to close popup"

      // restart game after 1 second

      mp_restartgame 1

}

// an event that will be run as soon as a map changes

event es_map_start

{

      // removes the view of player id's so when you look at users you will not see there name

      mp_playerid 2

      // everyone can talk to everyone

      sv_alltalk 1

      // flashlight is enabled

      mp_flashlight 1

      // footsteps make noise

      mp_footsteps 1

      // friendly fire is off

      mp_friendlyfire 0

      // he time before users can move when round starts (in seconds)

      mp_freezetime 3

}

// event that runs every round start

event round_start

{

      // Searches all online users to see if their STEAMID, userid, or name matches the match-text.

      es_xgetuserid auser

      // Cause a player to manipulate game entities - in this case disable bomb an hostage rescue to take effect

      es_fire server_var(auser) func_bomb_target Disable

      es_fire server_var(auser) func_hostage_rescue Disable

      es_xmath round_number + 1

}

 

// event that runs as soon as a player spawns

event player_spawn

{

      //  es_delayed = delay command for x seconds - es_tell = display a message to user

       es_delayed 3 es_tell event_var(userid)   #multi #green [KKINV]#default bind key "say !INV" #lightgreen for 15 Seconds Of invisiblity!

      //  es_tools restrcit all wepons

      es est_restrictall event_var(userid)

      //  es_tools unrestrcit knife

      es est_unrestrict event_var(userid) weapon_knife

      //  es_tools unrestrcit deagle

      es est_unrestrict event_var(userid) weapon_deagle

      //  es_tools - Syntax: est_SetPlayerColor <identifier> <red> <green> <blue> <alpha> [color weapons]

      es est_setplayercolor event_var(userid) 250 250 250 255 1

      //  set speed normal

      es est_speed event_var(userid) 1

      //  set gravity normal

      es est_SetGravity event_var(userid) 1

      // strip user from his weapons

      es_give event_var(userid) player_weaponstrip

      es_fire event_var(userid) player_weaponstrip strip

      //  give user knife

      es_delayed 0.001 es_give event_var(userid) weapon_knife

      //  give user deagle

      es_delayed 0.002 es_give event_var(userid) weapon_deagle

      // remove idle weapons

      es_xdelayed 0.002 est_RemoveIdle weapon

      //  checked keygroup to see if a has been creatwd for the user

      es_exists key_exist key invu event_var(userid)

      //  if the key has not been created then create one

      if (server_var(key_exist) = 0) do

      {

            //  create the key for the user

            es_keycreate invu event_var(userid)

      }

      //  set keyvalue for the user "inv_count" to 2

      es_keysetvalue invu event_var(userid) inv_count 2

      //  set keyvalue for the user "timeru" to 0

      es_keysetvalue invu event_var(userid) timeru 0

      //  set user cash to 0

      es_setplayerprop event_var(userid) CCSPlayer.m_iAccount 0

      // set user armor to 100

      es est_setarmor event_var(userid) 100

      // gets users spawnc value and sets spawnc to that value

      es_keygetvalue spawnc invu event_var(userid) spawnc

      // if the spawnc value is not equal to 1 then..

      if (server_var(spawnc) == 1) do

      {

            // send popup messange to user

            es popup send popkkinv event_var(userid)

            // sets user's spawnc value to 0 (to prevent the popup more then once per user)

            es_keysetvalue invu event_var(userid) spawnc 0

      }

}

// an event that checks what users type in the chat

event player_say

{

      // if user text = "!inv" then do...

      if (event_var(text) == !inv) do

      {

            es getplayerinfo user_alive event_var(userid) isdead

            if (server_var(user_alive) == 0) do

            {

                  // get user keyvalue "timeru" and set var "timeru" to its value

                  es_keygetvalue timeru invu event_var(userid) timeru

                  {

                        //   check if timeru is equal to 1 then do...

                        if (server_var(timeru) = 1) do

                        {

                           es es_tell event_var(userid) #multi #lightgreen You must wait untill you become visible to use !inv again

                        }

                        else do

                        {

                              //     get user keyvalue "inv_counr" and set var "inv_count" to its value

                              es_keygetvalue inv_count invu event_var(userid) inv_count

                              //     check if "inv_count" is equal to 2 then do...

                              if (server_var(inv_count) == 2) do

                              {

                                         es_tell event_var(userid) #multi #lightgreen You Can Use !inv only once more this round

                                    //       run block inv in script kkinv

                                    es_xdoblock kkinv/inv

                                    //       set keyvalue for the user "timeru" to 1

                                    es_keysetvalue invu event_var(userid) timeru 1

                                    //       set keyvalue for the user "inv_count" to 1

                                    es_keysetvalue invu event_var(userid) inv_count 1

                              }

                              //     check if "inv_count" is equal to 1 then do...

                              if (server_var(inv_count) == 1) do

                              {

                                                es_tell event_var(userid) #multi #lightgreen That was your last !inv, You have now used all your !inv's for this round

                              //       run block inv in script kkinv

                              es_xdoblock kkinv/inv

                              //       set keyvalue for the user "timeru" to 1

                              es_keysetvalue invu event_var(userid) timeru 1

                              //       set keyvalue for the user "inv_count" to 0

                              es_keysetvalue invu event_var(userid) inv_count 0

                              }

                              //     check if "inv_count" is equal to 0 then do...

                              if (server_var(inv_count) == 0) do

                              {

                              es_tell event_var(userid) #multi #lightgreen You Can not Use !inv more then twice in a round

                              }

                        }

                  }

            }

            else do

        {

            es_tell event_var(userid) #multi #lightgreen you can not run !inv when Dead

            }

      }

}

// an event that will run when a player dies (can be run on killer or victim)

event player_death

{

      // Set attacker's cash back to 0 so they can't buy from the $300 they got for killing the player.

      es_setplayerprop event_var(attacker) CCSPlayer.m_iAccount 0

      // es_tools restrict all victim weapon's so they  will not get weapons but mistake

      es est_restrictall event_var(victim)

      // es_tools - Syntax: est_SetPlayerColor <identifier> <red> <green> <blue> <alpha> [color weapons]

      es est_setplayercolor event_var(victim) 250 250 250 255 1

}

// a block that was created buy me and will be run threw the es_xdoblock kkinv/inv as shown before

block inv

{

      // set keyvalue for the user "roundc" to "round_number"

      es_keysetvalue invu event_var(userid) roundc server_var(round_number)

      est_enable_weapon_restrictions 1

      // restrict all weapons for a user using es_tools

      es est_restrictall event_var(userid)

      // unrestrict only knifes for user

      es est_unrestrict event_var(userid) weapon_knife

      // give weaponstrip for user

      es_give event_var(userid) player_weaponstrip

      // run weaponstrip for user

      es_fire event_var(userid) player_weaponstrip strip

       // give knife to user - I gave a delay of 0.001 because I don't want the weaponstrip to cause problem with the knife giving

      es_delayed 0.001 es_give event_var(userid) weapon_knife

      // give user alpha 5 = almost invisible - see est_setplayercolor syntax

      es_delayed 0.001 es est_setplayercolor event_var(userid) 250 250 250 5 1

      // make users speed X1.5 faster

      es est_speed event_var(userid) 1.5

      // make users gravity X0.7 lower

      es est_SetGravity event_var(userid) 0.7

      // remove all idle weapons from map ( will prevent some lags and clean the map)

      es_xdelayed 0.002 est_RemoveIdle weapon

      // delay 15 seconds and run userid in block uninv

      es_delayed 15 uninv event_var(userid)

}

block uninv

{

      {

            es_xgetargv kkinv_userid 1

            //gets userd roundc value and puts it into roundnum

            es_keygetvalue roundnum invu server_var(kkinv_userid) roundc

            // checks if the round number is equal to roundnum set in "inv block" to make sure this block will not continue in next round

            // this is for test only

            //es_msg #multi #green [ server_var(roundnum)]#default server_var(round_number)

            if (server_var(roundnum) = server_var(round_number)) do

            {

                  es getplayerinfo user_alive server_var(kkinv_userid) isdead

                  if (server_var(user_alive) == 0) do

                  {

 

                        est_enable_weapon_restrictions 1

                        es est_restrictall server_var(kkinv_userid)

                        es est_unrestrict server_var(kkinv_userid) weapon_knife

                        //    un restrict weapon deagle

                        es est_unrestrict server_var(kkinv_userid) weapon_deagle

                        //    make users alpha 255 = visible

                        es est_setplayercolor server_var(kkinv_userid) 250 250 250 255 1

                        //    set speed to normal

                        es est_speed server_var(kkinv_userid) 1

                        //    set gravity to normal

                        es est_SetGravity server_var(kkinv_userid) 1

                        //    strip player again from all weapons

                        es_give server_var(kkinv_userid) player_weaponstrip

                        es_fire server_var(kkinv_userid) player_weaponstrip strip

                        //    give user knife

                        es_delayed 0.001 es_give server_var(kkinv_userid) weapon_knife

                        //    give user deagle

                        es_delayed 0.002 es_give server_var(kkinv_userid) weapon_deagle

                        //    remove all dropped weapons again

                        es_xdelayed 0.002 est_RemoveIdle weapon

                        es_keysetvalue invu server_var(kkinv_userid) timeru 0

                  }

            }

      }

}

event player_activate

{

      // creates a userid key when connected

      es_keycreate invu event_var(userid)

      // crates user spawnc to value 1

      es_keysetvalue invu event_var(userid) spawnc 1

}

 

event player_disconnect

{

      // removed users key when dissconnected

      es_keydelete invu event_var(userid)

}

 

// a block that runs when you unload the script very important to do this so the users will not have to restart there server from all script // leftovers.

block unload

{

      // re enable bomb and hostage rescue

      es_fire server_var(auser) func_hostage_rescue Enable

      es_fire server_var(auser) func_bomb_target Disable

      // reset all players to visible

      es est_setplayercolor event_var(userid) 250 250 250 255 1

      // restart game again

      mp_restartgame 1

      // deletes the keygroup when script is unloaded

      es_xkeygroupdelete invu

      popup delete popkkinv

}