Team system adding player

Started by Nihongo^, Nov 02, 2016, 04:15 PM

Previous topic - Next topic

Nihongo^

i was thinking about team system is it possible to add 3 players in instead of 2 in team ? what should i need to do modify the array ?

Nihongo^


Thijn


Nihongo^

class PInfo
{
request = 51;
team = false;
teamp = null;
}

function onScriptLoad()
{
stats <- array( GetMaxPlayers(), null );
}

function onPlayerJoin( player )
{
print( "Player " + player.Name + " joined. [" + player.ID + "]" );
        stats[ player.ID ] = PInfo();
}

function onPlayerSpawn( player )
{
  if ( stats[ player.ID ].team )
       {
    local plr = GetPlayer( stats[ player.ID ].teamp );
    if ( plr.Spawned )
   {
   player.Skin = 0;
       player.Skin = plr.Skin;
       player.Team = plr.Team;
   player.Pos = plr.Pos;
   }
   }
}

function onPlayerCommand( player, cmd, text )
{
local i = 0;
local plr = player;
if ( text )
{
i = NumTok( text, " " );
if (i == 1) plr = GetPlayer( text );
}
 
  if ( cmd.tolower() == "team" )
    {
      local plr = GetPlayer( text );
      if ( !text )MessagePlayer( "Wrong syntax.", player );
      else if (( text ) && ( !plr )) MessagePlayer( "Unknown Player.", player );
      else if ( stats[ player.ID ].team ) MessagePlayer( "Already in team.", player );
      else if (( plr ) && ( stats[ plr.ID ].team )) MessagePlayer( "This player is already in a team.", player );
      else
         {
     PrivMessage( ">>" + player.Name + " would like to team up with you.", plr );
     PrivMessage( "Team-up message sent.", player );
     stats[ player.ID ].request = plr.ID;
     }
    }

   else if ( cmd.tolower() == "accept" )
     {
       local plr = GetPlayer( text );
       if ( !text ) MessagePlayer( "Wrong syntax. [/c accept player].", player );
       else if (( text ) && ( !plr )) MessagePlayer( "Unknown Player.", player );
       else if (( plr ) && ( player.ID != stats[ plr.ID ].request )) MessagePlayer( "This player haven't sent you team request.", player );
       else if ( stats[ player.ID ].team ) MessagePlayer( "Already in a team.", player );
       else
          {
       Message( ">> " + player.Name + " has teamed-up with " + plr.Name + "." );
       stats[ player.ID ].team = true;
       player.Skin = 0;
       player.Skin = plr.Skin;
       player.Team = plr.Team;
   player.Pos = plr.Pos;
       stats[ plr.ID ].teamp = player.Name;
       stats[ player.ID ].teamp = plr.Name;
      }
     }

   else if ( cmd.tolower() == "deny" )
    {
     local plr = GetPlayer( text );
    if ( !text ) MessagePlayer( "Wrong syntax. [/c deny player].", player );
    else if (( text ) && ( !plr )) MessagePlayer( "Unknown Player.", player );
    else if (( plr ) && ( player.ID != stats[ plr.ID ].request )) MessagePlayer( "This player haven't sent you team request.", player );
    else
       {
        Message( ">>" + player.Name + " denied team request from " + plr.Name + "." );
    stats[ plr.ID ].request = 51;
       }
    }

  else if ( cmd.tolower() == "leave" )
   {
    if ( stats[ player.ID ].team )
       {
   local plr = GetPlayer( stats[ player.ID ].teamp );
   Message( ">>" + player.Name + " left the team." );
   stats[ player.ID ].team = false;
   stats[ plr.ID ].teamp = null;
   stats[ player.ID ].teamp = null;
   }
     }
}

function onPlayerPart( player, reason )
{
  if ( stats[ player.ID ].team )
       {
   local plr = GetPlayer( stats[ player.ID ].teamp );
   Message( ">>" + player.Name + " left the team." );
   stats[ plr.ID ].teamp = null;
   stats[ player.ID ] = null;
   }
}

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
    else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
  tokenized = split(string, separator),
  text = "";

if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

Xmair

Quote from: Nihongo^ on Nov 03, 2016, 10:46 AMfunction onPlayerSpawn( player )
{
  if ( stats[ player.ID ].team )
       {
    local plr = GetPlayer( stats[ player.ID ].teamp );
    if ( plr.Spawned )
   {
   player.Skin = 0;
       player.Skin = plr.Skin;
What?

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Nihongo^

Please ignore it and tell me something about it

Nihongo^