Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Cool on Oct 29, 2015, 12:25 PM

Title: Lms prob
Post by: Cool on Oct 29, 2015, 12:25 PM
lms not ending when 1 player kills in lms why
Onplayerkillfunction onPlayerKill( killer, player, reason, bodypart )
{
   try{
   if ( ( status[ killer.ID ].IsReg ) && ( status[ player.ID ].IsReg ) )
   {
       status[ killer.ID ].Kills++;
   status[ player.ID ].Deaths++;
IncCash(killer, 500);
DecCash(player, 250);
    ePrivMessage( "Killed: " + player.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Reward: 0", killer );
    ePrivMessage( "Killer: " + killer.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Lost: 0", player );
       EchoMessage(ICOL_RED + " " + killer.Name + " killed " + player.Name + " with Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ".");
    if ( bodypart <= 6 ) IncPlayerBodyPart( killer, bodypart, 1 );
       if ( reason <= 32 ) IncPlayerWep( killer, reason, 1 );
   status[ killer.ID ].Spree++;
   StartSpree( killer );
   if ( status[ player.ID ].Spree >= 5 ) EndSpree( player, killer );
   if ( stats[ player.ID ].LMS )
        {
         LMSCount--;
         EMessage( ">> " + player.Name + " is out of the LMS round." );
         stats[ player.ID ].LMS = false;
         if ( LMSCount == 1 ) CheckEnd( killer );
stats[ player.ID ].Lost++;
        }
}
   
   }
   catch(e) print( "OnPlayerKill Error: " + e );
}

Full lms Function EXcluding onplayerkill because i posted already and if player exit lms ends and onplayerdeath lms ended but not ending onplayerkill
function CheckEnd( a )
{
       Message( ">> " + a.Name + " has won the LMS match. Reward: [00]" );
       a.Cash += 3000;
       MessagePlayer( "You have been rewarded with 00.", a );
       LMSActive = false;
       stats[ a.ID ].LMS = false;
       a.Pos = Vector( 496.26, -83.9443, 10.0302  );
   LMSCount = 0;
   stats[ a.ID ].Wins++;
   for( local i = 0; i <= GetMaxPlayers(); i++ )
{
local plr = FindPlayer( i );
if ( stats[ plr.ID ].Bet )
  {
   local amount = BAmount;
    if ( stats[ plr.ID ].Bet = a.Name )
  {
   Message( ">>" + plr.Name + " has won the bet which was placed on " + a.Name + "." );
   plr.Cash += amount.tointeger();
   Message( ">>" + plr.Name + " has got $" + amount + "." );
   amount = 0;
  } else MessagePlayer( "You lost the bet", plr );
  }
}
}


function CheckMembers()
{
     if ( LMSCount > 1 )
{
NewTimer( "Ann", 1000, 1, "3" );
NewTimer( "Ann", 2000, 1, "2" );
NewTimer( "Ann", 3000, 1, "1" );
} else CloseLMS();
}

function Ann( number )
{
        for( local i = 0; i <= GetMaxPlayers(); i++ )
{
local plr = FindPlayer( i );
    if ( ( plr ) && ( stats[ plr.ID ].LMS ) )
                        {
switch( number.tointeger() )
    {
case 1:
Announce( "1", plr );
StartLMS();
Announce( "Play!", plr );
break;

case 2:
Announce( "2", plr );
break;

case 3:
Announce( "3", plr );
break;
    }
}
}
}

function StartLMS()
{
    Message( "LMS round activated" );
    local plr;
        for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
    if ( ( plr ) && ( stats[ plr.ID ].LMS ) )
                       {
                         plr.IsFrozen = false;
stats[ plr.ID ].Played++;
                       }
            }
}

function CloseLMS()
{
   Message( "LMS cancelled due to less players." );
   LMSActive = false;
   LMSCount = 0;
    local plr;
        for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
    if ( ( plr ) && ( stats[ plr.ID ].LMS ) )
                       {
                         stats[ plr.ID ].LMS = false;
                         plr.IsFrozen = false;
                         plr.Pos = Vector( 496.26, -83.9443, 10.0302  );
if ( BAmount > 0 ) Message( ">> The bet amount have been lost." );
BAmount = 0;
                       }
                }
}

function CheckEnd2()
{
for( local i = 0; i <= GetMaxPlayers(); i++ )
{
local plr = FindPlayer( i );
local winner = FindPlayer( i );
if (( plr ) && ( stats[ plr.ID ].Bet ))
  {
  if ( stats[ winner.ID ].LMS )
    {
      local amount = BAmount;
       if ( stats[ plr.ID ].Bet = winner.Name )
    {
     Message( "" + plr.Name + " has won the bet which was placed on " + winner.Name + "." );
     plr.Cash += amount.tointeger();
     Message( "" + plr.Name + " has got $" + amount + "." );
     amount = 0;
    } else MessagePlayer( "You lost the bet", plr );
    }
  }

    if ( ( plr ) && ( stats[ plr.ID].LMS ) )
            {
                Message( ">> " + plr.Name + " has won the LMS match. Reward: [00]" );
                plr.Cash += 3000;
                MessagePlayer( "You have been rewarded with 00.", plr );
                LMSActive = false;
                plr.Pos = Vector( 496.26, -83.9443, 10.0302  );
                stats[ plr.ID ].LMS = false;
LMSCount--;
stats[ plr.ID ].Wins++;
  } 

}
}
function BetCheck( plr, Winner )
{
local amount = BAmount;
if ( stats[ plr.ID ].Bet == Winner )
{
Message( "" + plr.Name + " has won the bet which was placed on " + Winner + "." );
plr.Cash += amount.tointeger();
Message( "" + plr.Name + " has got $" + amount + "." );
amount = 0;
} else MessagePlayer( "You lost the bet", plr );
}

function round(value, precision) {
     local factor = pow(10.0, precision);
     return floor(value * factor + 0.5) / factor;
}
Title: Re: Lms prob
Post by: Cool on Oct 29, 2015, 06:13 PM
no help thanks
Title: Re: Lms prob
Post by: KAKAN on Oct 30, 2015, 08:32 AM
You're welcome, if you don't mind the problem.
Title: Re: Lms prob
Post by: Cool on Oct 30, 2015, 08:36 AM
LOL i wait too much no reply comming i am waiting for reply to solve anyone my mean i say if you help me so thanks if not so thanks
sorry for bad english
Title: Re: Lms prob
Post by: KAKAN on Oct 30, 2015, 09:08 AM
Check the LMSCount.
Add this on your onplayerkill
print(LMSCount);
Title: Re: Lms prob
Post by: Cool on Oct 30, 2015, 09:47 AM
Nothing on console coming
Title: Re: Lms prob
Post by: KAKAN on Oct 30, 2015, 01:42 PM
Are you expecting it on script load?
Kill someone in LMS and tell
Title: Re: Lms prob
Post by: Cool on Oct 30, 2015, 01:48 PM
LOL i kill someone then i tell noting happens i am not fool
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 02:35 PM
@KAKAN help
Title: Re: Lms prob
Post by: SAzEe21 on Oct 31, 2015, 02:57 PM
@Noob take some screenshots or record video then show us.
Title: Re: Lms prob
Post by: KAKAN on Oct 31, 2015, 06:09 PM
Try this:-
if ( LMSCount <= 1 ) CheckEnd( killer );
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 06:26 PM
Not working same prob
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 06:53 PM
are the players your testing with registered ?  You've got everything in the OnPlayerKill event wrapped around...
if ( ( status[ killer.ID ].IsReg ) && ( status[ player.ID ].IsReg ) )
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 06:56 PM
I didnt get you but if your mean is that i am testing lms with registered players so yes players registered on which i test lms
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 06:59 PM
yes, that's what i meant.
Ok, remove the try/catch and see if any errors are in the console.

edit: your setting  "stats[ player.ID ].LMS = false;" twice, once in the OnPlayerKill event and again in the CheckEnd function, its only needed once in the OnPlayerKill event - this change wont fix your problem tho, its just a observation.
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:07 PM
nothing comming
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:08 PM
how many players are you testing with ?
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:08 PM
2
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:10 PM
at the top of the OnPlayerKill event, put

print( stats[ player.ID ].LMS );

look in the console, what does it return ?
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:12 PM
Quote from: Noob on Oct 31, 2015, 07:07 PMnothing comming
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:16 PM
well, if its returning nothing, that's your problem.

// Your asking it to return a value
if ( stats[ player.ID ].LMS )
{
      // This part is only triggered if the above statement is true
}

and in your case, you said it's returning nothing, so the code in the if statement wont get triggered.

Take a break and listen to this
https://www.youtube.com/watch?v=cc-ep3ldGVQ

Then post me your lms join code
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:28 PM
if ( cmd == "join" )
                                  {
                                        if ( !LMSActive ) MessagePlayer( "LMS is not active.", player );
                                        else if ( stats[ player.ID ].LMS ) MessagePlayer( "Already in LMS.", player );
                                        else if ( !player.Spawned ) MessagePlayer( "Not yet spawned.", player );
                                        else if ( player.Health < 75 ) MessagePlayer( "Need more HP [75%]", player );
                                        else
                                            {
                                                     player.Pos = Vector(-754.187866, -1602.638916, 23.734970);
                                                     player.IsFrozen = true;
                                                     Message( ">> " + player.Name + " joined LMS" );
                                                     LMSCount++;
                                                     player.Team = -1;
                                                     stats[ player.ID ].LMS = true;
player.Health = 100;
                                            }
                                  }
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:33 PM
you told me this returned nothing. its either going to return true or false.
print( stats[ player.ID ].LMS );

go back a step, and tell me what it returns
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:40 PM
nothing and if i try to print anything onplayerkill nothing retruning  whats can cause of it :P
Edit:Check Pm
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:42 PM
not sure about that, but you've defiantly removed the try/catch statement?, because there's got to be a error returning somewhere

the lms join code looks fine, i'm sure it's one of the if statements in your OnPlayerKill event not triggering, which one i dunno tho
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:48 PM
Like this you sayfunction onPlayerKill( killer, player, reason, bodypart )
{
print( stats[ player.ID ].LMS );
   if ( ( status[ killer.ID ].IsReg ) && ( status[ player.ID ].IsReg ) )
   {
       status[ killer.ID ].Kills++;
    status[ player.ID ].Deaths++;
IncCash(killer, 500);
DecCash(player, 250);
     ePrivMessage( "Killed: " + player.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Reward: 0", killer );
    ePrivMessage( "Killer: " + killer.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Lost: 0", player );
       EchoMessage(ICOL_RED + " " + killer.Name + " killed " + player.Name + " with Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ".");
    if ( bodypart <= 6 ) IncPlayerBodyPart( killer, bodypart, 1 );
       if ( reason <= 32 ) IncPlayerWep( killer, reason, 1 );
    status[ killer.ID ].Spree++;
    StartSpree( killer );
    if ( status[ player.ID ].Spree >= 5 ) EndSpree( player, killer );
    if ( stats[ player.ID ].LMS )
        {
         LMSCount--;
         EMessage( ">> " + player.Name + " is out of the LMS round." );
         stats[ player.ID ].LMS = false;
         if ( LMSCount == 1 ) CheckEnd( killer );
stats[ player.ID ].Lost++;
        }
}
   
   }
   
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:50 PM
send me your script and i'll look at it tomorrow, I don't have the time right now.

trying to debug over a forum is not easy lol
Title: Re: Lms prob
Post by: rulk on Oct 31, 2015, 07:52 PM
relax and listen to this
https://www.youtube.com/watch?v=aL8kZ-iVk90

I'll have a look at your script tomorrow for you.
Title: Re: Lms prob
Post by: Cool on Oct 31, 2015, 07:59 PM
Ok thanks
Title: Re: Lms prob
Post by: KAKAN on Nov 01, 2015, 06:26 AM
Quote from: Noob on Oct 31, 2015, 07:48 PMLike this you say[spoiler]function onPlayerKill( killer, player, reason, bodypart )
{
print( stats[ player.ID ].LMS );
   if ( ( status[ killer.ID ].IsReg ) && ( status[ player.ID ].IsReg ) )
   {
       status[ killer.ID ].Kills++;
    status[ player.ID ].Deaths++;
IncCash(killer, 500);
DecCash(player, 250);
     ePrivMessage( "Killed: " + player.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Reward: 0", killer );
    ePrivMessage( "Killer: " + killer.Name + ", Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ", Lost: 0", player );
       EchoMessage(ICOL_RED + " " + killer.Name + " killed " + player.Name + " with Wep: " + GetWeaponName( reason ) + ", Part: " + GetBodypartName(bodypart) + ".");
    if ( bodypart <= 6 ) IncPlayerBodyPart( killer, bodypart, 1 );
       if ( reason <= 32 ) IncPlayerWep( killer, reason, 1 );
    status[ killer.ID ].Spree++;
    StartSpree( killer );
    if ( status[ player.ID ].Spree >= 5 ) EndSpree( player, killer );
    if ( stats[ player.ID ].LMS )
        {
         LMSCount--;
         EMessage( ">> " + player.Name + " is out of the LMS round." );
         stats[ player.ID ].LMS = false;
         if ( LMSCount == 1 ) CheckEnd( killer );
stats[ player.ID ].Lost++;
        }
}
   
   }
   [/spoiler]
Really? It shows nothing in the console?
Update your server version this time :D
Title: Re: Lms prob
Post by: Thijn on Nov 01, 2015, 10:28 AM
Also make sure you don't have multiple onPlayerKill functions in your script.
Title: Re: Lms prob
Post by: Cool on Nov 01, 2015, 11:11 AM
Nope only single
Title: Re: Lms prob
Post by: rulk on Nov 01, 2015, 04:06 PM
I actually think this is a VC:MP bug, because i am writing a game-mode but also cannot get the 'onPlayerKill' event to trigger.

I am using VC:MP in windowed mode and connecting from the same PC.

Even if i strip everything out and put something as simple as

function onPlayerKill( killer, player, reason, bodypart )
{
print( player.Name );
}

It still won't print anything to the console.

is it possible if a dev could look into this ? or is anyone else having the same problem.  Remember i am connecting both players from the same computer and i am in windowed mode.

Kind regards

rulk
Title: Re: Lms prob
Post by: DizzasTeR on Nov 01, 2015, 04:19 PM
@rulk, Please consider this:

http://forum.vc-mp.org/?topic=254.msg1389#msg1389
Title: Re: Lms prob
Post by: rulk on Nov 01, 2015, 04:31 PM
@Doom_Killer That's the answer!!  your a genius. :-)
Title: Re: Lms prob
Post by: KAKAN on Nov 01, 2015, 05:03 PM
Team -1 is the free team.
Btw, if your server is based on DM (FFA), then you can use this:-
function onPlayerTeamKill( killer, player, reason, bodypart )
{
  onPlayerKill( killer, player, reason, bodypart )
}
I posted this because @Noob can solve that thing.
Title: Re: Lms prob
Post by: Cool on Nov 01, 2015, 06:49 PM
Thanks @Kakan @rulk @DoomKiller for help at last this topic solved thanks to all
Doomkiller hates me but thanks if you dont hate me give a like to my this post :P