Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*============================================= The Usefull Server inbuilt Functions=========================================
- *
- *This script is created by Zeeshan.Bhatti :)
- *
- */
- /*===========================================================================================================================
- class PlayerStats
- {
- LastIPUsed = 0.0.0.0;
- Registered = false;
- Logged = false;
- Deaths = 0;
- Kills = 0;
- Joins = 0;
- Level = 0;
- Cash = 0;
- Bank = 0;
- LoginAttempt = 0;
- }
- //======================= IRC CONSTANTS ====================================================================================
- const ICOL_WHITE = "\x000300";
- const ICOL_BLACK = "\x000301";
- const ICOL_BLUE = "\x000302";
- const RED = "[#FF0000]";
- const PINK = "[#FF1493]";
- const ORANGE = "[#FF8C00]";
- const YELLOW = "[#FFFF81]";
- const PURPLE = "[#9400D3]";
- const GREEN = "[#008000]";
- const LBLUE = "[#1E90FF]";
- const BLUE = "[#4682B4]";
- const BROWN = "[#8B4513]";
- const WHITE = "[#FFFFFF]";
- const BLACK = "[#000000]";
- const GREY = "[#808080]";
- const LOWRED = "[#ed4242]";
- const LOWGREEN = "[#e9e9e9]";
- const ICOL_GREEN = "\x000303";
- const ICOL_RED = "\x000304";
- const ICOL_BROWN = "\x000305";
- const ICOL_PURPLE = "\x000306";
- const ICOL_ORANGE = "\x000307";
- const ICOL_YELLOW = "\x000308";
- const ICOL_LGREEN = "\x000309";
- const ICOL_CYAN = "\x000310";
- const ICOL_LCYAN = "\x000311";
- const ICOL_LBLUE = "\x000312";
- const ICOL_PINK = "\x000313";
- const ICOL_GREY = "\x000314";
- const ICOL_LGREY = "\x000315";
- const ICOL = "\x0003";
- const ICOL_BOLD = "\x0002";
- const ICOL_ULINE = "\x0031";
- //=========================== CONSTANTS ====================================================================================
- const Author = "Zeeshan.Bhatti";
- const Mode = "UF";
- const Version = "version 1.0";
- const Credits = "Zeeshan.Bhatti";
- const Helper = "Decent_946";
- const SERVER = "[UF] Unique Force Server";
- const Forum = "uf-clan.vc-mp.net";
- const IP = "Comming soon";
- const IRC = "Comming soon";
- //===========================================================================================================================
- function onScriptLoad()
- {
- //==== prints server info ==============================
- print( "=======================================================" );
- print( "= [UF] Unique Force Server scripted by Zeeshan.Bhatti =" );
- print( "=======================================================" );
- //==== needed to connect to the database file===========
- db <- ConnectSQL( "files/Database.db" );
- print( "[LOADED] SQL database succesfully" );
- //==== needed to load the other server files.===========
- dofile( "script/functions.nut" );
- dofile( "script/cmds.nut" );
- dofile( "script/Accounts.nut" );
- //==== needed to load and create the tables.============
- CreateTables();
- //==== lets create some arrays to load the functions.===
- status <- array(GetMaxPlayers(), null );
- //==== auto mute arrays =============
- IsMuted <- array( GetMaxPlayers(), false);
- antiSpamTime <- array( GetMaxPlayers(), 0 );
- antiSpamWarnings <- array( GetMaxPlayers(), 0 );
- }
- function onScriptUnload()
- {
- //====saves players stats.=========
- for ( local i = 0; i < GetMaxPlayers(); i++ )
- {
- local player = FindPlayer( i );
- if( player )
- {
- SaveStatus( player );
- }
- }
- //===Disconnects the database.===== ( always disconnect database in last )
- DisconnectSQL( db );
- print( "Disconnected SQL Database" );
- }
- function onPlayerJoin( player )
- {
- try
- {
- //===loads the player info.========
- status[ player.ID ] = PlayerStats();
- playerinfo( player );
- catch(e) print( "PlayerJoin Function Error: " + e );
- }
- }
- function onPlayerRequestClass( player, classID, team, skin )
- {
- try
- {
- Announce( "~0~ -"+GetPlayerTeamName( team )+"- ", player, 2 );
- return 1;
- catch(e) print( "PlayerReqClass Function Error: " + e );
- }
- }
- function onPlayerRequestSpawn( player )
- {
- try
- {
- if ( status[ player.ID ].Registered == false )
- {
- MessagePlayer(RED+"/register to play", player );
- return 0;
- }
- else if ( ( status[ player.ID ].Registered == true ) && ( status[ player.ID ].Logged == false ) )
- {
- MessagePlayer(RED+"/login to play", player );
- return 0;
- }
- else return 1;
- catch(e) print( "PlayerReqSpawn Function Error: " + e );
- }
- }
- function onPlayerSpawn( player )
- {
- try
- {
- //====Spawn messages/sound======/send messages and sound when player spawns
- Message(LBLUE + player.Name +" spawned as "+GetPlayerTeamName( player.Team )+"." );
- catch(e) print( "PlayerSpawn Function Error: " + e );
- }
- }
- function onPlayerDeath( player, reason )
- {
- try
- {
- if ( status[ player.ID ].Registered )
- {
- status[ player.ID ].Deaths++;
- local DCash = player.Cash;
- if ( DCash >= 250 ) DecCash( player, 250 );
- else DecCash( player, DCash );
- if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
- }
- //========Spree Functions=======
- EndKillingSpree(player,255);
- if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
- catch(e) print( "PlayerDeath Function Error: " + e );
- }
- }
- function onPlayerKill( killer, player, reason, bodypart )
- {
- try
- {
- //===increases players kills/Deaths+score======
- killer.Score++;
- status[ killer.ID ].Kills++;
- status[ player.ID ].Deaths++;
- IncCash( killer, 500 );
- if ( player.Cash >= 250 ) DecCash( player, 250 );
- //==========Spree Functions========
- IncPlayerSpree(killer,1);
- StartKillingSpree(killer);
- EndKillingSpree(player,killer);
- if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
- catch(e) print( "PlayerKill Function Error: " + e );
- }
- }
- function onPlayerTeamKill( player, killer, reason, bodypart )
- {
- if ( killer.Team == 255 && player.Team == 255 )
- {
- onPlayerKill( player, killer, reason, bodypart );
- }
- }
- function onPlayerChat( player, text )
- {
- try
- {
- //====== Team chat function====================
- if ( text.slice(0,1) == "\\" )
- {
- local text = text.slice(1);
- for ( local i = 0; i < GetMaxPlayers(); i++ )
- {
- local plr = FindPlayer( i );
- if ( plr && plr.Team == player.Team )
- {
- ClientMessage("[Team-Chat] "+player.Name+": "+text+".",plr,0,255,255);
- }
- }
- return 0;
- }
- return 1;
- catch(e) print( "PlayerChat Function Error: " + e );
- }
- }
- function onPlayerPart( player, reason )
- {
- try
- {
- if ( ( GetLevel( player ) > 0 ) && ( status[ player.ID ].Logged == true ) )
- {
- //====saves players stats.=========
- SaveStatus( player );
- }
- //==Part Reason? ==================
- local Text = "Unknown"
- switch ( reason )
- {
- case PARTREASON_DISCONNECTED:
- Text = "Disconnected";
- break;
- case PARTREASON_TIMEOUT:
- Text = "Timeout";
- break;
- case PARTREASON_QUIT:
- Text = "Quit";
- break;
- case PARTREASON_KICKED:
- Text = "Kicked";
- break;
- case PARTREASON_CRASHED:
- Text = "Crashed";
- break;
- }
- //==========Spree Functions======
- EndKillingSpree(player,255);
- SetPlayerSpree(player);
- print("** " + player + " has left the game. ( " + Text + " ) at " + GetFullTime() + ".");
- catch(e) print( "PlayerPart Function Error: " + e );
- }
- }
Add Comment
Please, Sign In to add comment