reseted after kick

Started by :P, Oct 08, 2015, 09:06 AM

Previous topic - Next topic

:P

if a player failed login and hes kicked but why player stats reseted  kills deaths money bank
function AccInfo( player )
{
      try{
  EchoMessage( ICOL_ORANGE + "** [" + player.ID + "] " + player.Name + " Joined the Server." );
  if ( CheckBan( player ) == 1 ) Kick( player, "Server", "Banned From Server" );
  status[ player.ID ] = PlayerStats();
  local id = player.ID;
  local ip = player.IP;
  if ( GetLevel( player ) > 0 )
  {
      if ( ip != GetIP( player ) )
  {
      ePrivMessage( "Welcome to the Server " + player.Name + "!", player );
  ePrivMessage( "You're not Logged-In. Please login by /login <password>", player );
  status[ player.ID ].IsReg = true;
  status[ player.ID ].IsLogged = false;
  }
  else if ( ip == GetIP( player ) )
  {
       local q = QuerySQL( db, "SELECT * FROM Account WHERE Name='" + player.Name.tolower() + "'" );
   if ( GetSQLColumnData( q, 0 ) != null )
              {
   status[ player.ID ].Kills = GetSQLColumnData( q, 4 );
   status[ player.ID ].Deaths = GetSQLColumnData( q, 5 );
   status[ player.ID ].Cash = GetSQLColumnData( q, 6 );
   status[ player.ID ].Bank = GetSQLColumnData( q, 7 );
   status[ player.ID ].Level = GetSQLColumnData( q, 2 );
   }
   FreeSQLQuery( q );
   ePrivMessage( "Welcome to the Server " + player.Name + "!", player );
   ePrivMessage( "You've auto-logged in onto the server!", player );
   status[ player.ID ].IsReg = true;
   status[ player.ID ].IsLogged = true;
   EchoMessage( ICOL_BROWN + ">> " + player.Name + " Auto-Logged In." );
   
  }
 
  }
  else
  {
      ePrivMessage( "Welcome to the Server " + player.Name + "!", player );
  ePrivMessage( "You're not registered with us. Register by /register <password>", player );   
  }
  WriteIniString( "Files/ServData.ini", "IP", player.Name, player.IP );
  }
  catch(e) print( "AccInfo Error: " + e );
}
OnPlAyerspawn
function onPlayerSpawn( player )
{
    Message( ">> " + player.Name + " has spawned." );
if ( ( status[ player.ID ].IsReg == true ) && ( status[ player.ID ].IsLogged == false ) )
{
    Announce( "/Login", player );
    ePrivMessage("Login First To Access Services",player);
player.Kick();

}
if ( status[ player.ID ].IsReg == false )
    {
    Announce( "/ register", player );
    ePrivMessage("Register First To Access Services",player);
    player.Kick();
}
if ( ( status[ player.ID ].IsReg ) && ( status[ player.ID ].IsLogged ) )
    {
    player.Cash = status[ player.ID ].Cash;
    }  
}
SLC is a good scripter but he always use bad words for abusing players :P

MacTavish

Why you kick player when you can prevent spawn if they aren't logged/registered

function onPlayerRequestSpawn(player)
{
if(status[ player.ID ].IsReg== false)
{
MessagePlayer("Please register first by /register",player);
return 0;
}
else if(status[ player.ID ].IsReg == true && status[ player.ID ].IsLogged == false)
{
MessagePlayer("Please login first by /login",player);
return 0;
}
else return 1;
}

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

Retired VC:MP Player/Scripter :P

:P

#2
thanks kusnangi its great idea
can you give me idea how to create logout cmds and function
SLC is a good scripter but he always use bad words for abusing players :P

Mashreq

The best way to implement logout is to first edit your IP in database to something else and then you need to set your logged class as false as well as kill the player when you have logged out.

Xmair

#4
Easy.
else if ( cmd == "logout" )
{
if ( status[player.ID].IsReg == false ) MessagePlayer("You are not registered.",player);
elss if ( status[player.ID].IsLogged == false ) MessagePlayer("You are not logged in",player);
else
{
status[player.ID].IsLogged=false;
player.Health=0.00;
player.Pos=Vector(player.Pos.x,player.Pos.y,player.Pos.z 10); //to eject player if in a vehicle. Remember to put the plus sign at player.Pos.z. 10 as my mobile doesnt have the plus sign
MessagePlayer("Logged out.",player);
}
}
Untested because I am at mob.

Credits to Boystang!

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

MacTavish

Quote from: Mashreq on Oct 08, 2015, 10:59 AMThe best way to implement logout is to first edit your IP in database to something else and then you need to set your logged class as false as well as kill the player when you have logged out.

Quote from: Xmair on Oct 08, 2015, 11:00 AMEasy.
else if ( cmd == "logout" )
{
if ( status[player.ID].IsReg == false ) MessagePlayer("You are not registered.",player);
elss if ( status[player.ID].IsLogged == false ) MessagePlayer("You are not logged in");
else
{
status[player.ID].IsLogged=false;
player.Health=0.00;
player.Pos=Vector(player.Pos.x,player.Pos.y,player.Pos.z 10); //to eject player if in a vehicle.
}
}
Untested because I am at mob.

Okay but what about the data that will only gonna save when player leaves server

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

Retired VC:MP Player/Scripter :P

Xmair

#6
I guess there is already a savestats function onPlayerPart in warchiefs.
Anyway, updated :
else if ( cmd == "logout" )
{
if ( status[player.ID].IsReg == false ) MessagePlayer("You are not registered.",player);
elss if ( status[player.ID].IsLogged == false ) MessagePlayer("You are not logged in",player);
else
{
SaveStats(player);//Or wotever you use to save the stats.
status[player.ID].IsLogged=false;
player.Health=0.00;
player.Pos=Vector(player.Pos.x,player.Pos.y,player.Pos.z 10); //to eject player if in a vehicle. Remember to put the plus sign at player.Pos.z. 10 as my mobile doesnt have the plus sign
MessagePlayer("Logged out.",player);
}
}
Untested because I am at mob.

Credits to Boystang!

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

:P

error end of statment expected if or ;
SLC is a good scripter but he always use bad words for abusing players :P

KingOfVC

-..-

else if ( cmd == "logout" )
{
if ( status[player.ID].IsReg == false ) MessagePlayer("You are not registered.",player);
else if ( status[player.ID].IsLogged == false ) MessagePlayer("You are not logged in",player);
else
{
SaveStats(player);//Or wotever you use to save the stats.
status[player.ID].IsLogged=false;
player.Health=0.00;
player.Pos=Vector(player.Pos.x,player.Pos.y,player.Pos.z 10); //to eject player if in a vehicle. Remember to put the plus sign at player.Pos.z. 10 as my mobile doesnt have the plus sign
MessagePlayer("Logged out.",player);
}
}

Mashreq

Try using this one:
else if ( cmd == "logout" )
{
if ( status[ player.ID ].IsReg == false ) MessagePlayer("You are not registered.",player);
elss if ( status[ player.ID ].IsLogged == false ) MessagePlayer("You are not logged in",player);
else
{
SaveStats( player );
local IP = "0.0.0.0";
QuerySQL( db, "UPDATE Account SET IP='" + IP + "' WHERE Name='" + player.Name.tolower() + "'" );
status[ player.ID ].IsLogged = false;
player.Health = 0;
player.Pos = player.Pos;
MessagePlayer("You have logged out from the server.",player);
}
}

:P

SLC is a good scripter but he always use bad words for abusing players :P

Mashreq

I have spotted a error while checking if a player is logged in or not.
Change your:
elss if ( status[ player.ID ].IsLogged == false ) MessagePlayer("You are not logged in",player);
to
else if ( status[ player.ID ].IsLogged == false ) MessagePlayer("You are not logged in",player);

:P

error player trying to set null
SLC is a good scripter but he always use bad words for abusing players :P

KAKAN

On which line does it shows the error?
oh no

:P

no line was specified only OnPlayerCommand  Player trying to set null
SLC is a good scripter but he always use bad words for abusing players :P