Where can i find syntax for squirrel ?

Started by Pr0Ankit, May 26, 2015, 03:29 AM

Previous topic - Next topic

Pr0Ankit

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


PlayerX

#1
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
If some see me on a server and see that I'm not from Argentina, is an impostor >_>.
Playing since 9 years.

Mashreq

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.

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);

Kratos_

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 .
In the middle of chaos , lies opportunity.

Pr0Ankit

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.

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

Kratos_

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
}
In the middle of chaos , lies opportunity.

.

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.
.

jayant

#7
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

PlayerX

Do not give anything complex > _>, still do not know squirrel
If some see me on a server and see that I'm not from Argentina, is an impostor >_>.
Playing since 9 years.

Diego^

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);
  }
}
BRL's Developer.

Pr0Ankit

#10
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.

images hosting

jayant

#11
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)

Pr0Ankit

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

Stormeus

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.

jayant