Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Ksna on Jul 19, 2015, 06:50 AM

Title: Some commands without Database
Post by: Ksna on Jul 19, 2015, 06:50 AM
First of all , thanks to my master Gudio :)
No credits needed ,  you can use them if you want to save your time :D
Commands: 
goto , nogoto on/ off,; randspawn  on/off, stat on/off, spawnloc on/ off, spawnwep , antispawnkill



Add this to player class
  nogoto = false;
randspawn = false;
stat = false;
spawnloc = false;
X = 0;
Y = 0;
Z = 0;
spawnwep = false;
wep1 = 0;
wep2 = 0;
wep3 = 0;
wep4 = 0;
wep5 = 0;
wep6 = 0;
wep7 = 0;
        wep8 = 0;     


In on script load
     
stats <- array( GetMaxPlayers(), null );
spawnkill <- array( GetMaxPlayers() + 1, null );
spawnkill[0] = 5000; // 5sec }
       
Onplayerspawn
spawnkill[player.ID] = GetTickCount();
if ( stats[ player.ID ].randspawn )player.Pos = RandSpawn[rand() % RandSpawn.len()]; // Random spawn
if ( stats[ player.ID ].spawnloc ) player.Pos = Vector( stats[ player.ID ].X, stats[ player.ID ].Y, stats[ player.ID ].Z );
if ( stats[ player.ID ].spawnwep ){
player.SetWeapon( stats[ player.ID ].wep1 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep2 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep3 , 9999 );
player.SetWeapon( stats[ player.ID ].wep4 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep5 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep6 , 9999 );
player.SetWeapon( stats[ player.ID ].wep7 , 9999 );     
player.SetWeapon( stats[ player.ID ].wep8 , 9999 );     


onplayerKill
     if ((GetTickCount() - spawnkill[player.ID]) < spawnkill[0])              // ANTI SPAWN KILL  //Gudio // Without timer
{
Message( killer.Name + " has been drowned Reason: Anti-Spawn Killing is not allowed " );
Killer.Pos = Vector( -597.7496,-1858.9531,28.1291 );
}       
   if ( stats[ player.ID ].stat ) stats[ killer.ID ].Kills--;      // After adding kills
   


On player death
if (stats[player.ID].stat) stats[player.ID].Deaths--; //        After adding deathsRandSpawn <- [  Vector(-330.3437, -556.2602, 12.8126), Vector(-270.9442, -559.7090, 12.8023), Vector(-235.1805, -590.8958, 10.3459),
Vector(-378.7146, -650.3090, 10.4131), Vector(-377.8996, -594.8467, 10.3623), Vector(-457.1482, -588.4764, 12.8765)
]; // create this anywhere

On player command

else if ( cmd == "spawnloc" ) {                                               //Working
if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <on/off>", player );
else {
if ( text == "on" ){
stats[ player.ID ].X = player.Pos.x.tofloat();
stats[ player.ID ].Y = player.Pos.y.tofloat();
stats[ player.ID ].Z = player.Pos.z.tofloat();
stats[ player.ID ].spawnloc = true;
MessagePlayer( "Spawnloc Enabled", player );
}
else if ( text == "off" ){
stats[ player.ID ].spawnloc = false;
MessagePlayer( "Spawnloc disabled .", player );
}
}
}

else if ( cmd == "stat" ) {                                               //Working
if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <on/off>", player );
else {
if ( text == "on" ){
stats[ player.ID ].stat = false;
MessagePlayer( "Stats are Enabled, Kills and Deaths will be added", player );
}
else if ( text == "off" ){
stats[ player.ID ].stat = true;
MessagePlayer( "Stats are disabled. Your Kills and Deaths will not be added .", player );
}
}
}

else if ( cmd == "goto" ){                                                    // Working
if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Player Nick/ID>", player );
else{
local plr = text != "" ? IsNum( text ) ? FindPlayer( text.tointeger() ) : FindPlayer( text ) : player;
if ( !plr ) MessagePlayer( "[Error] - Unknown Player..", player );
            else if (  stats[ plr.ID ].nogoto ) MessagePlayer( "Error - You can't teleport to " + plr.Name + " because he has nogoto  enabled.", player );
else {
NewTimer( "go", 5000, 1, player.ID, plr.ID );
Announce( "~y~ Teleporting...", player );
player.IsFrozen = true;
MessagePlayer( "You will be teleported in 5 seconds to [ " + plr.Name + " ] ", player);
}
        }   
}

else if ( cmd == "nogoto" ) {                                            // Working
if ( !text ) MessagePlayer( "[Syntax] - /c " + cmd + " <on/off>", player );
else {
if ( text == "on" ) {
stats[ player.ID ].nogoto = true;
MessagePlayer( "Players Can't teleport to you anymore...", player );
}
else if ( text == "off" ) {
stats[ player.ID ].nogoto = false;
MessagePlayer( "Players Can teleport to you.", player );
}
}
}

else if ( cmd == "randspawn" ) {                                    // Working
if ( !text ) MessagePlayer( "[Syntax] - /c " + cmd + " <on/off>", player );
else {
if ( text == "on" ){
stats[ player.ID ].randspawn = true;
MessagePlayer( "Random Spawn Activated!", player );
}
else if ( text == "off" ){
stats[ player.ID ].randspawn = false;
MessagePlayer( "Random Spawn Deactivated..", player );
}
}
}
else if( cmd == "spawnwep" ){                                  // Working
if (!text) MessagePlayer(" Correct syntax: /wep <wep name/id> <wep name/id> ...", player );
else {
local Wep = "", i;
for( i = 0 ; i < split(text, " ").len() ; i++) {
if( GetWeaponName( GetWeaponID( split(text, " ")[ i ] ) )) {
player.SetWeapon( GetWeaponID( split(text, " ")[ i ] ), 9999 );
Wep = Wep + " " + GetWeaponName( GetWeaponID( split(text, " ")[ i ] ) ).tostring();
}
}
stats[ player.ID ].spawnwep = true;
stats[ player.ID ].wep1 = player.GetWeaponAtSlot( 1 );
stats[ player.ID ].wep2 = player.GetWeaponAtSlot( 2 );
stats[ player.ID ].wep3 = player.GetWeaponAtSlot( 3 );
stats[ player.ID ].wep4 = player.GetWeaponAtSlot( 4 );
stats[ player.ID ].wep5 = player.GetWeaponAtSlot( 5 );
stats[ player.ID ].wep6 = player.GetWeaponAtSlot( 6 );
stats[ player.ID ].wep7 = player.GetWeaponAtSlot( 7 );
stats[ player.ID ].wep8 = player.GetWeaponAtSlot( 8 );
MessagePlayer( "Given :" +stats[ player.ID ].wep6+ ""+stats[ player.ID ].wep5+ ""+stats[ player.ID ].wep4+"" , player);
MessagePlayer( "Spawnwep :" + Wep, player);
}
}


Next snippets will be race , derby and request below for any other commands
Title: Re: Some commands without Database
Post by: [VSS]Shawn on Jul 19, 2015, 07:07 AM
Race o.0 Track or full?

Btw Good but these are easy one
Title: Re: Some commands without Database
Post by: . on Jul 19, 2015, 07:10 AM
Quote from: Ksna on Jul 19, 2015, 06:50 AMFirst of all , thanks to my master Gudio :)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fimg.memecdn.com%2Fdo-as-your-master-says_o_379243.jpg&hash=242fb82b01ac98fc3b20fd5cd617886cd48dbbf2)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs.quickmeme.com%2Fimg%2Ffd%2Ffdfc30506f9ecf6f1e0721db6bf3346dd48a408dd63465962db5b296e93cd197.jpg&hash=313e9bd155998f1685339d10774c37156da5142e)

Coming straight from @VRocker 's fav list :P
Title: Re: Some commands without Database
Post by: Ksna on Jul 19, 2015, 07:43 AM
Quote from: S.L.C on Jul 19, 2015, 07:10 AM
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fimg.memecdn.com%2Fdo-as-your-master-says_o_379243.jpg&hash=242fb82b01ac98fc3b20fd5cd617886cd48dbbf2)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs.quickmeme.com%2Fimg%2Ffd%2Ffdfc30506f9ecf6f1e0721db6bf3346dd48a408dd63465962db5b296e93cd197.jpg&hash=313e9bd155998f1685339d10774c37156da5142e)

Coming straight from @VRocker 's fav list :P

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FITXTMGb.jpg&hash=3d5329ff7b68b069e93d8a00926a1c92a07b028f)
Title: Re: Some commands without Database
Post by: KAKAN on Jul 19, 2015, 11:05 AM
Useless using INI's is even better than this
Title: Re: Some commands without Database
Post by: Honey on Jul 19, 2015, 11:29 AM
Quote from: KAKAN on Jul 19, 2015, 11:05 AMUseless using INI's is even better than this

k then go use it and never return back to this topic.
Title: Re: Some commands without Database
Post by: [VSS]Shawn on Jul 19, 2015, 02:49 PM
KAkan dont insult anyone or jealous he makes it give him (y) this not become jealous
Btw Good WOrk
Title: Re: Some commands without Database
Post by: Murdock on Jul 19, 2015, 03:46 PM
Quote from: Ksna on Jul 19, 2015, 06:50 AM player.SetWeapon( stats[ player.ID ].wep1 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep2 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep3 , 9999 );
player.SetWeapon( stats[ player.ID ].wep4 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep5 , 9999 );
player.SetWeapon(  stats[ player.ID ].wep6 , 9999 );
player.SetWeapon( stats[ player.ID ].wep7 , 9999 );     
player.SetWeapon( stats[ player.ID ].wep8 , 9999 );

So what will you do if you want to give the player 100 weapons?
Repeat the same line 100 times?
Better use an array for that, and you could give as many weapons you like with 1 or 2 lines of code
Title: Re: Some commands without Database
Post by: Ksna on Jul 19, 2015, 04:09 PM
there are 8 weapon slots for a player and i will make a array
Title: Re: Some commands without Database
Post by: KAKAN on Jul 20, 2015, 06:36 PM
I have 10 weapons slot, what will u do?
And @Honey:- Sorry, but I don't have my server 24/7 hrs on