Some commands without Database

Started by Ksna, Jul 19, 2015, 06:50 AM

Previous topic - Next topic

Ksna

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

[VSS]Shawn

Race o.0 Track or full?

Btw Good but these are easy one

.

#2
Quote from: Ksna on Jul 19, 2015, 06:50 AMFirst of all , thanks to my master Gudio :)



Coming straight from @VRocker 's fav list :P
.


KAKAN

Useless using INI's is even better than this
oh no

Honey

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.

[VSS]Shawn

KAkan dont insult anyone or jealous he makes it give him (y) this not become jealous
Btw Good WOrk

Murdock

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

Ksna

there are 8 weapon slots for a player and i will make a array

KAKAN

I have 10 weapons slot, what will u do?
And @Honey:- Sorry, but I don't have my server 24/7 hrs on
oh no