Random Numbers

Started by FinchDon, Sep 28, 2015, 03:18 PM

Previous topic - Next topic

FinchDon

Hello I just make a Snippet It is Easy But it will be liked by Newbies Because they don't know much about random

First Put this on ScriptLoad

tf <- [ "true", "false"];
password <- [ "mypass", "pass", "~", "password", "server", "editor", "@"];
weather <- [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ];
servername <- [ "VCCNR", "HP", "FBK's", "VU", "DM", "FF"];
maxplayers <- [ 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 67, 77, 70, 100, 90, 80 ];
timerate <- [ 1000, 2000, 5000, 10000, 0, 1, 100000, 50000];
gm <- [ "v1.0", "VCCNR v1.2", "LW C++++ 1.2", "DM v2.0"];

Now Some Functions
function GetLevel( player )
{
   local lvl1 =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT Level FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
   if ( lvl1 ) return lvl1;
   else return 0;
}

Commands

if ( cmd == "commands")
{
PrivMessage( player, "Admin Commands");
PrivMessage( player, "timerate, friendlyfire, stuntbike, maxplayers, servername, setweather, stuntbike, serverpass, gamemode" );
}
else if (cmd == "timerate")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetTimeRate(timerate[rand()% timerate.len()]);
Message( " " + player.Name + " set Time Rate : " + timerate[rand()% timerate.len()] + ".");
}
}
if ( cmd == "friendlyfire")
{
local ff = rand() % 2;
if ( GetLevel( player ) < 2 ) PrivMessage(player,"No!")
else if ( ff == 1 )
{
SetFriendlyFire(true)
Message(player.Name+" has set friendly fire true!");
}
else if ( ff == 2 )
{
SetFriendlyFire(false)
Message(player.Name+" has set friendly fire false!");
}
}
if ( cmd == "stuntbike")
{
local ff = rand() % 2;
if ( GetLevel( player ) < 2 ) PrivMessage(player,"No!")
else if ( ff == 1 )
{
SetStuntBike(true)
Message(player.Name+" has set Stunt Bike true!");
}
else if ( ff == 2 )
{
SetStuntBike(false)
Message(player.Name+" has set Stunt Bike false!");
}
}
else if (cmd == "setweather")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetWeather(weather[rand()% weather.len()]);
Message( " " + player.Name + " set Weather : " + weather[rand()% weather.len()] + ".");
}
}
else if (cmd == "maxplayers")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetMaxPlayers(maxplayers[rand()% maxplayers.len()]);
Message( " " + player.Name + " set Max Players : " + maxplayers[rand()% maxplayers.len()] + ".");
}
}
else if (cmd == "serverpass")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetPassword(password[rand()% password.len()]);
Message( " " + player.Name + " set Server Pass : " + password[rand()% password.len()] + ".");
}
}
else if (cmd == "servername")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetServerName(servername[rand()% servername.len()]);
Message( " " + player.Name + " set Server Name : " + servername[rand()% servername.len()] + ".");
}
}
else if (cmd == "gamemode")
{
if ( GetLevel( player ) < 2 ) PrivMessage( player, "No!");
else
{
SetGameModeName(gm[rand()% gm.len()]);
Message( " " + player.Name + " set Server Game Mode: " + gm[rand()% gm.len()] + ".");
}
}

Creator:FinchDon
Helper: Beztone Help in FriendlyFire

Here you go..
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR


MacTavish

I will request to @Stormeus to remove this topic before newbies explode their scripts by using @FinchDon's broken codes

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

What if a player uses FAS?
What shall he use? An array or an broken query?
This script can lag your server, random server name gens? lol, why will anyone need it? Server having a random name or having a unique name is better?
oh no

Thijn

Locked. Useless and the topic starter is banned so wont be fixed.