Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Pr0Ankit on May 26, 2015, 03:29 AM

Title: Where can i find syntax for squirrel ?
Post by: Pr0Ankit on May 26, 2015, 03:29 AM
Hi,

As you all have noticed in vcmp 0.3 pawno tool. You see all the syntax or things which can be used in script in the right hand side like ClientMessage,Showplayer,etc.
How do i know which syntax i can use for squirrel ?

I tried guessing and making a fix command.

else if( cmd == "fix" )
{
      [ player.SetCarHealth ] = 1000;
  MessagePlayer("#06FA16] Your car has been fixed.");

}

But this gives an error. So please guys instead of giving me this full code. Please tell me what are the syntax and what mistake i made so I can fix it myself and learn from my mistakes.

Thanks and Best Regards,
Pr0Ankit

Title: Re: Where can i find syntax for squirrel ?
Post by: PlayerX on May 26, 2015, 03:41 AM
You

else if( cmd == "fix" )
 {
      [ player.SetCarHealth ] = 1000;
   MessagePlayer("#06FA16] Your car has been fixed.");
 
 }

FIX:

else if( cmd == "fix" )
{
   local Vehicle = Player.Vehicle;
   Vehicle.Health = 1000;
   MessagePlayer("[#06FA16] Your car has been fixed.",Player);
}

http://wiki.vc-mp.org/wiki/Scripting_Resources

for color, use HEX with "[" and "]":

[#FF0000] <- RED
[#00FF00] <- GREEN
[#0000FF] <- BLUE
Title: Re: Where can i find syntax for squirrel ?
Post by: Mashreq on May 26, 2015, 03:43 AM
You cannot find a syntax in squirrel since squirrel codes are done using Notepad c++.
You can have a look in the wiki for all the syntax currently available for squirrel over here. (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions)

The error has occured because you have used MessagePlayer it is only for a player (private messages), so you need to use it as follows:

MessagePlayer("#06FA16] Your car has been fixed.", player);
Title: Re: Where can i find syntax for squirrel ?
Post by: Kratos_ on May 26, 2015, 03:51 AM
AFAIK there isn't any text editor which contains VC:MP 0.4 squirrel syntax by default .

However , you could program some text editors like sublime or Atom to do this task .
Title: Re: Where can i find syntax for squirrel ?
Post by: Pr0Ankit on May 26, 2015, 04:42 AM
Quote from: Steam on May 26, 2015, 03:43 AMYou cannot find a syntax in squirrel since squirrel codes are done using Notepad c++.
You can have a look in the wiki for all the syntax currently available for squirrel over here. (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions)

The error has occured because you have used MessagePlayer it is only for a player (private messages), so you need to use it as follows:

MessagePlayer("#06FA16] Your car has been fixed.", player);

Hi,

So you mean that I have not made any mistakes by only adding the first line or I have to define the variable first with local and then use it as PlayerX told me ?

Thanks and Best Regards,
Pr0Ankit
Title: Re: Where can i find syntax for squirrel ?
Post by: Kratos_ on May 26, 2015, 05:00 AM
You aren't checking whether player is in vehicle or not . Something of this type :-
local veh = player.vehicle;
if(! veh ) // not in vehicle
else
{
// fix vehicle
}
Title: Re: Where can i find syntax for squirrel ?
Post by: . on May 26, 2015, 05:34 AM
No wonder you get an error. You want to send a message to a player, right? So, don't you think you need a player to send a message to?
MessagePlayer("#06FA16] Your car has been fixed.");Be creative and try to imagine which player will receive that message.
Title: Re: Where can i find syntax for squirrel ?
Post by: jayant on May 26, 2015, 06:17 AM
MessagePlayer explains indirectly that it wants his receiver,i.e,player
if(!veh) to check player is in vehicle or not.
You can also check health n damage of vehicle to fix vehicle and you can also decrease cash etc. of the player to fix vehicle.
else if( cmd == "fix" )
{
   local veh = player.Vehicle;
   if (!veh) MessagePlayer("[#ffffff]You must be in a vehicle to fix your vehicle", player );
  else
  {
   // here somethings
  }
}

> If forgot that u mentioned not full code..:P
Title: Re: Where can i find syntax for squirrel ?
Post by: PlayerX on May 26, 2015, 06:55 AM
Do not give anything complex > _>, still do not know squirrel
Title: Re: Where can i find syntax for squirrel ?
Post by: Diego^ on May 26, 2015, 11:06 AM
else if( cmd == "fix" )
{
   local veh = player.Vehicle;
   if (!veh) MessagePlayer("[#ffffff]You must be in a vehicle to fix your vehicle", player );
  else
  {
veh.Fix();
MessagePlayer("[#06FA16]Your car has been fixed.", player);
  }
}
Title: Re: Where can i find syntax for squirrel ?
Post by: Pr0Ankit on May 27, 2015, 02:59 AM
Hi Everyone,

After learning what you all have posted here and seeing the example I came out with something :-


else if( cmd == "fix" )
{
   local Vehicle = player.Vehicle;
   if ( !veh ) MessagePlayer("[#06FA16]You must be in a vehicle to fix your vehicle", player );  <---- This line gives error (Line 269)
   else if (Vehicle.Health == 1000.0) MessagePlayer("Your vehicle is already in excellent condition." ,player);
   else
   {
  veh.Fix();
  player.Cash -= 200;
  MessagePlayer("[#06FA16]Your car has been fixed for 200$", player);
   }
}



EDIT : The line above which checks if the player is in veh or not it gives error.
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs23.postimg.org%2Fiogn7m3ij%2Ferror.png&hash=8cae01436213c96d48de70ad3352827505cff91f) (http://postimg.org/image/fudhu61c7/full/)
images hosting (http://postimage.org/)
Title: Re: Where can i find syntax for squirrel ?
Post by: jayant on May 27, 2015, 04:32 AM
else if( cmd == "fix" )
{
   local veh = player.Vehicle;
   if (!veh) MessagePlayer("[#ffffff]You must be in a vehicle to fix your vehicle", player );
 else if (veh.Health == 1000) MessagePlayer("Your vehicle is already in excellent condition." ,player);
  else
  {
  veh.Health = 1000;
  veh.Damage = 0;
  MessagePlayer("[#ffffff]Your vehicle is fixed now",player);
  }
}
 
Notice that you have defined veh = player.Vehicle, so you will use veh and that code gives error because there it is defined as Vehicle = player.Vehicle..So, to fix you will use if ( !Vehicle)
Title: Re: Where can i find syntax for squirrel ?
Post by: Pr0Ankit on May 27, 2015, 08:18 AM
Quote from: jayant on May 27, 2015, 04:32 AMelse if( cmd == "fix" )
{
   local veh = player.Vehicle;
   if (!veh) MessagePlayer("[#ffffff]You must be in a vehicle to fix your vehicle", player );
 else if (veh.Health == 1000) MessagePlayer("Your vehicle is already in excellent condition." ,player);
  else
  {
  veh.Health = 1000;
  veh.Damage = 0;
  MessagePlayer("[#ffffff]Your vehicle is fixed now",player);
  }
}
 
Notice that you have defined veh = player.Vehicle, so you will use veh and that code gives error because there it is defined as Vehicle = player.Vehicle..So, to fix you will use if ( !Vehicle)

Hi,
So I have to also change veh.health == 1000.0 to Vehicle.health == 1000.0 ? and also veh.Fix() to Vehicle.Fix() ?
But the veh.fix works idk why does it needs to be changed only in that particular line which checks if the player is in vehicle ?


Thanks and Best Regards,
Pr0Ankit
Title: Re: Where can i find syntax for squirrel ?
Post by: Stormeus on May 27, 2015, 10:48 AM
jayant is correct. You can't do veh.Fix when veh doesn't exist as a variable and your variable names need to be consistent.
Title: Re: Where can i find syntax for squirrel ?
Post by: jayant on May 27, 2015, 01:18 PM
@Pr0Ankit - See this post for further help - http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2486.0