Auto-Spawn with command and hotkey.

Started by KAKAN, Nov 02, 2015, 06:21 PM

Previous topic - Next topic

KAKAN

Add this on your onScriptLoad
function onScriptLoad(){
ASpawn <- array( GetMaxPlayers(), false);
A_S <- BindKey(true,0x73,0,0);
}

This is needed onplayerpart:-
function onPlayerPart( player, reason ) {
ASpawn[ player.ID ] = false;
}

Now the main things:-
function onPlayerRequestClass( player, classID, team, skin )
{
if ( ASpawn[ player.ID ] ) player.Spawn();
}

Now the commands:-
function onPlayerCommand( player, command, arguments )
{
local cmd = command.tolower(), text = arguments.tolower();

if( cmd == "aspawn" || cmd == "autospawn" )
    {
if(!text)MessagePlayer("Use /" + cmd + " <on/off>.",player);
else
{
switch(text)
{
case "on":
ASpawn[ player.ID ] = true;
MessagePlayer("Auto-Spawn Activated",player);
break;

case "off":
ASpawn[ player.ID ] = false;
MessagePlayer("Auto-Spawn De-Activated",player);
break;

default: PrivMessage(player,"Syntax Error: Use /" + cmd + " <on/off>."); break;
}
}
    }
}

And now using the hotkey:-
function onKeyDown( player, key )
{

    switch(key)
        {
  case A_S:
  if( ASpawn[ player.ID ] ) {
  MessagePlayer("Auto-Spawn De-Activated.",player);
  ASpawn[ player.ID ] = false;
      } else {
        MessagePlayer(">> Auto-Spawn Activated.",player);
        ASpawn[ player.ID ] = true;
      }
  break;

default: break; //I know it seems weired.
}

}
You're now ready to use the snip.
Feel free to report if u found any bugs
Original credits goes to:- @ysc3839
Original post:- http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2656.0
oh no

Cool