Timer

Started by FarisDon, Jul 13, 2015, 04:44 AM

Previous topic - Next topic

FarisDon

   else if ( cmd == "fix" )
           {
           if ( binfo[player.ID].registered==true )
            {
       if ( binfo[player.ID].logged==true )
                {
                                    local Veh = player.Vehicle;
                                    if (Veh)
                                    {
                                    ClientMessage( "Your Vehicle will be fixed in 5 Seconds.", player,255,255,0 );
                                    NewTimer( "Fix", 5000, 1, player );
                                       }
                                   
else ClientMessage ( "Error - You need to be inside at vehicle that you want to fix.", player,255,255,0);
}
else ClientMessage ( "Error - You are not logged in.", player,255,255,0);
}
else ClientMessage ( "Error - You haven't registered your nickname.", player,255,255,0);
}
function Fix(player)
{
local plr=FindPlayer(player);
if (plr)
{
ClientMessage("Your Vehicle has been successfully fixed!",plr,255,255,0);
        plr.Vehicle.Fix();

}}
Well as you guys can see that i am using a timer , so when i go in server and type /fix after 5 seconds it crashes plus its says in a window error Caption:Microsoft VisualC++ runtime library 
                                     Text:Program E/UKC/server32.exe
                                                            R6025
                                                            -pure virtual function call.
And when i make the code simply like this function Fix(player)
{

ClientMessage("Your Vehicle has been successfully fixed!",player,255,255,0);
        player.Vehicle.Fix();

}
It just crash without giving any error
P.S:Sorry guys cannot post screen shot as i am unable to do it from laptop!

MatheuS

#1
Test !

function Fix(player)
{
 local veh=player.Vehicle;
 if (player)
 {
 ClientMessage("Your Vehicle has been successfully fixed!",player,255,255,0);
        veh.Fix();
   
}}
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

FarisDon

Quote from: MatheuS on Jul 13, 2015, 04:55 AMTest !

function Fix(player)
{
 local veh=player.Vehicle;
 if (player)
 {
 ClientMessage("Your Vehicle has been successfully fixed!",plr,255,255,0);
        veh.Fix();
   
}}
Nah didnt work , but even its crashed , and didn't show any error.

Mashreq

#3
You were using the wrong way for the timer, use the following one:

Command:
   else if ( cmd == "fix" )
            {
             if ( binfo[player.ID].registered==true )
              {
          if ( binfo[player.ID].logged==true )
                  {
                                    local Veh = player.Vehicle;
                                    if (Veh)
                                    {
                                    ClientMessage( "Your Vehicle will be fixed in 5 Seconds.", player,255,255,0 );
                                    NewTimer( "Fix", 5000, 1, player.ID );
                                       }
                                   
    else ClientMessage ( "Error - You need to be inside at vehicle that you want to fix.", player,255,255,0);
   }
   else ClientMessage ( "Error - You are not logged in.", player,255,255,0);
  }
  else ClientMessage ( "Error - You haven't registered your nickname.", player,255,255,0);
 }

Function:
function Fix(playerID)
{
 local player=FindPlayer(playerID);
 if (player)
 {
 ClientMessage("Your Vehicle has been successfully fixed!",player,255,255,0);
        player.Vehicle.Fix();
   
}
}

FarisDon

Quote from: Mashreq on Jul 13, 2015, 05:17 AMYou were using the wrong way for the timer, use the following one:

Command:
   else if ( cmd == "fix" )
            {
             if ( binfo[player.ID].registered==true )
              {
          if ( binfo[player.ID].logged==true )
                  {
                                    local Veh = player.Vehicle;
                                    if (Veh)
                                    {
                                    ClientMessage( "Your Vehicle will be fixed in 5 Seconds.", player,255,255,0 );
                                    NewTimer( "Fix", 5000, 1, player.ID );
                                       }
                                   
    else ClientMessage ( "Error - You need to be inside at vehicle that you want to fix.", player,255,255,0);
   }
   else ClientMessage ( "Error - You are not logged in.", player,255,255,0);
  }
  else ClientMessage ( "Error - You haven't registered your nickname.", player,255,255,0);
 }

Function:
function Fix(playerID)
{
 local player=FindPlayer(playerID);
 if (player)
 {
 ClientMessage("Your Vehicle has been successfully fixed!",player,255,255,0);
        player.Vehicle.Fix();
   
}
}
I see ; thanks Mashreq.