Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Cool on Oct 22, 2015, 09:00 PM

Title: Lock/unlock
Post by: Cool on Oct 22, 2015, 09:00 PM
how we can create a system with which owners can lock there's cars and unlock
Title: Re: Lock/unlock
Post by: SAzEe21 on Oct 22, 2015, 09:02 PM
Quote from: Noob on Oct 22, 2015, 09:00 PMhow we I can create a system with which owners can lock there's cars and unlock
Title: Re: Lock/unlock
Post by: MatheuS on Oct 22, 2015, 09:30 PM
vehicle.IsLock = bool;  //true or false...
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 02:51 AM
Like this
else if (cmd == "lock")
{
if (!owner) messageplayer ("you are not the buyer" ,player)
else
{
vehicle.islock = true
messageplayer ("locked" ,player)
}
}
Title: Re: Lock/unlock
Post by: jayant on Oct 23, 2015, 03:14 AM
If you got a full vehicle system you can easily implement above cmd you mentioned.
Title: Re: Lock/unlock
Post by: EK.IceFlake on Oct 23, 2015, 05:15 AM
!owner
...
understand what you did wrong there
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 05:21 AM
ya i fix it with that line
else if ( GetSQLColumnData( q, 2 ) != player.Name ) MessagePlayer( "you are not buyer..", player );
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 05:45 AM
Quote from: Zeeshan.Bhatti on Oct 22, 2015, 09:02 PM
Quote from: Noob on Oct 22, 2015, 09:00 PMhow we I can create a system with which owners can lock there's cars and unlock
soory mis typed i post from mobile
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 04:24 PM
can we save car locks on or off in db if yes then how
Title: Re: Lock/unlock
Post by: jayant on Oct 23, 2015, 04:28 PM
In your database you just need to make one more column,name it,for example,status. Make a simple command,in it query and SELECT your database and just toggle it on/off. [ You can see nogoto on command for an example ]. And yes do not forget this - vehicle.IsLock = true/false;
Title: Re: Lock/unlock
Post by: . on Oct 23, 2015, 04:29 PM
Quote from: Noob on Oct 23, 2015, 04:24 PMcan we save car locks on or off in db if yes then how

Must you ask that question? I supposed you want someone to give you some code and you just to copy and paste it. Then you to come here a couple more times because you can't even copy the code properly. And you know why? Coz you don't know sh!t.
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 04:32 PM
no S.L.C I just ask how dont understand me wrong
Title: Re: Lock/unlock
Post by: KAKAN on Oct 23, 2015, 04:49 PM
And what did he tell?
That's the meaning of How :P
Btw, see @jayant 's post
Title: Re: Lock/unlock
Post by: Cool on Oct 23, 2015, 04:51 PM
ya i understand on @jayant post is very help full
Title: Re: Lock/unlock
Post by: KAKAN on Oct 23, 2015, 04:58 PM
Try to do it then.
If you find any error, you're free to post them, and we're ready to help you.
Good Luck!
Title: Re: Lock/unlock
Post by: Cool on Oct 24, 2015, 05:05 PM
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 );
   }
}
}
}
Title: Re: Lock/unlock
Post by: MacTavish on Oct 24, 2015, 05:41 PM
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);
}
}
}
}
}
}
Title: Re: Lock/unlock
Post by: Cool on Oct 24, 2015, 05:51 PM
onplayercommand one parameter has invalid type expected string integer  no specific line
Title: Re: Lock/unlock
Post by: MacTavish on Oct 24, 2015, 05:53 PM
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
Title: Re: Lock/unlock
Post by: Cool on Oct 24, 2015, 05:57 PM
i using with that syntax which you tell but error
Title: Re: Lock/unlock
Post by: MacTavish on Oct 24, 2015, 06:02 PM
Please post an screenshot of console error
Title: Re: Lock/unlock
Post by: Cool on Oct 24, 2015, 07:37 PM
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi59.tinypic.com%2F4rupgn.png&hash=a6198e3447bbee76aac6c2ae52f01eef165fffca)
Title: Re: Lock/unlock
Post by: Thijn on Oct 24, 2015, 08:05 PM
Remove the try catch block around your onPlayerCommand...
Title: Re: Lock/unlock
Post by: Cool on Oct 25, 2015, 06:32 AM
not woking now giving error in this line local veh = FindVehicle(GetTok(text," ",1)), mode = GetTok(text," ",2);
Title: Re: Lock/unlock
Post by: MacTavish on Oct 25, 2015, 09:48 AM
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);
}
}
}
}