March 29, 2024, 02:35:26 pm

Author Topic: VCMP Scripts Manual/Tutorial  (Read 10808 times)

0 Members and 1 Guest are viewing this topic.

GangstaRas

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • *
  • *
  • *
  • Posts: 1754
  • Country: jm
  • Representing VU for Life
    • View Profile
VCMP Scripts Manual/Tutorial
« on: February 15, 2013, 12:03:34 am »
i know, pascal, javascript and html coding, its time I learn this bitch. But I don't see anything on this crap, what language it is, how you make it, none a that shit. So anyone of you that know how to write scripts, gimme a starter link, why don't ya
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor



MaDKilleR

  • Vice Underdog
  • Crazy Man
  • *
  • Posts: 1517
  • Country: ca
  • Hi.
    • View Profile
    • MaDKiLLeR's Site
Re: VCMP Scripts Manual/Tutorial
« Reply #1 on: February 15, 2013, 11:05:43 am »
As you know Vice City Multiplayer has currently 3 languages available. Squirrel, Pawn, mIRC ( outdated ). People do use pawn but at the moment, squirrel is the best choice. I'll explain briefly how you can start writing scripts in Squirrel.

(I'm not much good at explaining!)

Learning Squirrel

You need to learn Squirrel first. You can find the online manual here.

Basics

As you know, to create a good and attractive server, your script should have:
  • Regiser / Login System
  • Statistics System
  • Vehicles & Properties Systems
  • and much more...

Besides these, their are vast ideas too but they depend on your imagination and knowledge.

Getting back into squirrel, the best idea is to study some released scripts. They'll give you a complete idea of how they work and you can learn much squirrel but studying them. Some scripts are:

VCMP Base Scripts (VBS)
FBS
MDM-SQ

By studying these scripts, you can know how various systems works.

Firstly, you need to setup a squirrel server. You can download the server by clicking here. A Tutorial about setting up the server can be found here.

Examples

I've written some examples below. Hope this helps. Don't forget to check the wiki.

  • Loading the Script

First, you need to create a .nut file and have to load it into the server by editing server.conf. Scroll to the bottom and edit the line:

Code: [Select]
<script></script>
[code]

with

[code]
<script>your-script.nut</script>

Now, the script has been loaded into the server. This is where the VCMP server's event onScriptLoad() is called. You can find a list of all VC:MP events here with examples.

Code: [Select]
function onScriptLoad()
{
  print( "Script loaded!" );
}


Following is the example of working with a class.

Code: [Select]
class Player
{
   Kills = 0;
   Deaths = 0;
   Joins = 0;
}

At the top, we'll create an array to store the details.

Code: [Select]
playerStats <- array( GetMaxPlayers, null );

Let's welcome the player.

Code: [Select]
function onPlayerJoin( pPlayer )
{
    PrivMessage( "Welcome to the server, "+player.Name+"!", player ); //Send a welcome message.
    local id = player.ID;
    playerStats[ id ] = null; //Delete any previous data.
    playerStats[ id ] = Player(); //The class we declared at the top.
}

Stats Example:

Code: [Select]
function onPlayerKill( killer, player, reason, bodypart )
{
    playerStats[ killer.ID ].Kills++;
    playerStats[ player.ID ].Deaths++;
}


Creating a command:


Code: [Select]
function onPlayerCommand( player, command, text )
{
      local
      cmd = command.tolower(),  //To avoid stupid bugs. For Example, the command "stats" will work even if the player types /c StAts or /c STATS etc
id = player.ID;
     
     if ( cmd == "stats" )
     {
           PrivMessage( "Your Kills:<"+playerStats[player.ID].Kills+"> Deaths:<"+playerStats[player.ID].Deaths+"> Joins:<"+playerStats[player.ID].Joins+">", player );
     }
}


You can find a list of all VCMP Squirrel Server functions here with examples. You've to just use different functions at different places according to what you're building.

Winner Winner x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

- [VU]MaDKiLLeR

GangstaRas

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • *
  • *
  • *
  • Posts: 1754
  • Country: jm
  • Representing VU for Life
    • View Profile
Re: VCMP Scripts Manual/Tutorial
« Reply #2 on: February 15, 2013, 01:37:28 pm »
ah thanks madkiller, some of these examples look javascripty, so atleast I don't have a huge learning curve to go through. I'll definitely be using all of this
Agree Agree x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor



[xTr]FastShooter

  • Newbie
  • *
  • Posts: 1
  • Country: pk
    • View Profile
Re: VCMP Scripts Manual/Tutorial
« Reply #3 on: December 14, 2013, 08:25:19 am »
can you add hashes example too in this ....
Artistic Artistic x 1 Brain Donor Brain Donor x 6 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor