Lock/unlock

Started by Cool, Oct 22, 2015, 09:00 PM

Previous topic - Next topic

Cool

error can not convert string line # 427local veh = FindVehicle( text.tointeger() );
else if ( cmd == "lock" )
{
local q = QuerySQL( db, "SELECT * FROM Cars WHERE rowid LIKE '" + text + "'" );
if ( !player.IsSpawned ) ePrivMessage( "[Error] - You haven't spawned yet..", player );
else if ( !text ) MessagePlayer( "Usage: /"+cmd+" [Vehicle/ID]", player );
else {
local veh = FindVehicle( text.tointeger() );
if ( !veh ) ePrivMessage( "[Error] - Invalid veh / ID", player );
else if ( !IsOwnerOrSharer( veh, player ) ) MessagePlayer(RED+"** [Error]: "+ORANGE+"You don't owned this vehicle!", player );
else {
if ( text == "on" )
{
   if ( status[ player.ID ].Vehicle.Locked ) MessagePlayer( "** >> Locked-Vehicle: " + GetVehicleNameFromModel( veh.Model ) + "." , player )

   else
   {
      status[ player.ID ].Vehicle.Locked = true;
      ePrivMessage( "locked...", player );
   }
}
}
}

MacTavish

#16
Try its untested wrote from mobile, please let me know if it throw any errorelse if ( cmd == "lock" )
{
if ( !player.IsSpawned ) ePrivMessage( "[Error] - You haven't spawned yet..", player );
else if ( !text ) MessagePlayer( "Usage: /"+cmd+" [Vehicle/ID]", player );
else {
local veh = FindVehicle(GetTok(text," ",1)), mode = GetTok(text," ",2);
if ( !IsNum(veh) ) ePrivMessage( "[Error] - Invalid veh / ID", player );
else if(mode != "on" || mode !="off") ePrivMessage( "[Error] - Mode must be on/off", player );
else
{
local q = QuerySQL( db, "SELECT * FROM Cars WHERE rowid LIKE '" + veh + "'" );
 if ( !IsOwnerOrSharer( veh, player ) ) MessagePlayer(RED+"** [Error]: "+ORANGE+"You don't owned this vehicle!", player );
else {
if ( mode == "on" )
    {
       if ( veh.Locked == true ) MessagePlayer("Error - This Veh Is Already Locked",player);
else
{
veh.Locked = true;
MessagePlayer( "** >> Locked-Vehicle: " + GetVehicleNameFromModel( veh.Model ) + "." , player );
}
}
else if( mode == "off")
{
if ( veh.Locked == false ) MessagePlayer("Error - This Veh Is Already Unlocked",player);
       else
       {
          veh.Locked = false;
          ePrivMessage( "Unlocked...", player);
}
}
}
}
}
}

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

Retired VC:MP Player/Scripter :P

Cool

#17
onplayercommand one parameter has invalid type expected string integer  no specific line

MacTavish

Quote from: Noob on Oct 24, 2015, 05:51 PMonplayercommand one parameter has invalid no specific line

How you using it., the actual syntax is /lock VehID on/off

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

Retired VC:MP Player/Scripter :P

Cool

i using with that syntax which you tell but error

MacTavish

Please post an screenshot of console error

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

Retired VC:MP Player/Scripter :P

Cool


Thijn

Remove the try catch block around your onPlayerCommand...

Cool

not woking now giving error in this line local veh = FindVehicle(GetTok(text," ",1)), mode = GetTok(text," ",2);

MacTavish

Use this code it is tested
else if ( cmd == "lock" )
{
if ( !player.IsSpawned ) MessagePlayer( "[Error] - You haven't spawned yet..", player );
else if (!text) MessagePlayer("Invalid Syntax, use /lock ID",player);
else
{
if (!IsNum(text)) MessagePlayer("ID must be Integer",player);
else if (!IsOwnerOrSharer(veh, player)) MessagePlayer("You aren't sharer or owner of this vehicle",player);
else
{
local Veh = FindVehicle(text.tointeger());
if (Veh.Locked == true)
{
Veh.Locked = false;
MessagePlayer("Vehicle unlocked",player);
}
else{
Veh.Locked = true;
MessagePlayer("Vehicle locked",player);
}
}
}
}

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

Retired VC:MP Player/Scripter :P