Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - habi
Community Plugins / logfile maker
« on October 19th, 2020, 03:48 PM »
Hi guys, vc-mp server already makes logfile named server_log.txt. But in some cases, like closing server via x button it is reported that log files are not written.

So this plugin will write 'whatever is on screen' to 'logfile.txt'

Platform: Windows       Language: Squirrel

Just call the function 'export' followed by paranthesis. eg. export()  and you can see a new logfile in your folder.

Each time you call the function, the logfiles are fresh written.



Source code c++
Off-Topic General / somebody multiple accounts
« on September 15th, 2020, 05:07 PM »
this i got from users online

Community Plugins / simple announce
« on August 13th, 2020, 01:41 PM »
Hi guys, this is what i have been doing for the past couple of hours.

Run your server and just double click announce.exe. It will announce to masterlist.

Just got an interest on how vcmp announce is working.

Code: [Select]
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <thread>
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")

#define DEFAULT_BUFLEN 10240

int __cdecl main(int argc, char** argv)
    char server_port[6] = "8192";
    if (argc == 2)
        if (strlen(argv[1]) < 4)ZeroMemory(server_port, 6);
        memcpy(server_port, argv[1], strlen(argv[1]));
    const char* PORT = "80";
    const char* IP_ADDR = "";

    WSADATA wsaData;
    SOCKET ConnectSocket = INVALID_SOCKET;
    struct addrinfo* result = NULL,
        * ptr = NULL,
    char recvbuf[DEFAULT_BUFLEN];
    int iResult;
    int recvbuflen = DEFAULT_BUFLEN;
    // Initialize Winsock
    iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
    if (iResult != 0) {
        printf("WSAStartup failed with error: %d\n", iResult);
        return 1;

    ZeroMemory(&hints, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    //hints.ai_protocol = IPPROTO_UDP;

    // Resolve the server address and port
    iResult = getaddrinfo(IP_ADDR, PORT, &hints, &result);
    if (iResult != 0) {
        printf("getaddrinfo failed with error: %d\n", iResult);
        return 1;

    // Attempt to connect to an address until one succeeds
    for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {

        // Create a SOCKET for connecting to server
        ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype,
        if (ConnectSocket == INVALID_SOCKET) {
            printf("socket failed with error: %ld\n", WSAGetLastError());
            return 1;

        // Connect to server.
        iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
        if (iResult == SOCKET_ERROR) {
            ConnectSocket = INVALID_SOCKET;


    if (ConnectSocket == INVALID_SOCKET) {
        printf("Unable to connect to server!\n");
        return 1;
    char buf[512];
    sprintf(buf,"POST /announce.php HTTP/1.1\r\n"
        "Connection: close\r\n"
        "User-Agent: VCMP/0.4\r\n"
        "VCMP-Version: 0.4\r\n"//VCMP->GetServerVersion();
        "Content-Type: application/x-www-form-urlencoded\r\n"
        "Content-Length: %d\r\n"//strlen of "PORT:8192"
    printf("%s\n", buf);
    // Send an initial buffer
    iResult = send(ConnectSocket, buf, strlen(buf), 0);
    if (iResult == SOCKET_ERROR) {
        printf("send failed with error: %d\n", WSAGetLastError());
        return 1;
    else printf("iResult is %d\n", iResult); int len = 5192;
    char reply[4096];
    iResult = 0;
    iResult = recv(ConnectSocket, reply, len, 0);
    if (iResult > 0)
        printf("iResult is %d\n",iResult);
        reply[iResult] = '\0';
        printf("reply is %s\n", reply);


This is mainly made to call from other programs. You have to call regularly. samp calls their announce every 5 minutes. I think VCMP will retain server in masterlist for 15 minutes or so.

The default port is 8192. If there is a change in port, open Command Prompt, go to the directory where this exe lies and type
announce 8194
Bugs and Crashes / OnPlayerStateChange
« on August 8th, 2020, 12:49 PM »
This function is getting called continuously with oldstate=newstate.
Community Plugins / Plugin development
« on August 7th, 2020, 07:03 AM »
I see that many players have difficulty in plugin development. One of the members asked me how to call a plugin function ( a c++ function inside the plugin) from squirrel.

First of all download a plugin template which has squirrel connected. One you can find in my older post

You might be the first time using C++, never mind. It is so simple. Just google how to install this 'Visual Studio'.

Now when you open the project(.vcxproj), you can see many source files on your right side. Find SQFuncs.cpp. we are going to edit it.

If you open it, into the bottom you can find a function named 'RegisterFuncs'. I think it is created by the LU devs or someone.

Do you know what we are going to do. We are going to create a small function in c++, which can be called from our squirrel. Think of it. In squirrel, we load the plugin from server.cfg and call 'this function' from squirrel. How beautiful?

In some other tutorial i will show how to do the reverse, i.e calling a squirrel function from c++. by squirrel function i mean
Code: [Select]
function abcd(a,b)
     print ("a is "+a+ " and b is "+b);

It is easy to understand if i tell you we are going to embed this function into plugin.
Say a is a string ie. a "something" and b is an integer ( 100 or something )
We are building a c++ function.
Now search SQFuncs.cpp for 'void RegisterFuncs(HSQUIRRELVM v) '
Just above that function add the following piece of code.
Code: [Select]
SQInteger n = sq->gettop(v);
if (n == 3) {
const SQChar* a;
sq->getstring(v, 2, &a);
SQInteger b;
sq->getinteger(v, 3, &b);
printf("a is %s and b is %d", a, b);
return 1;
return 0;
//'void RegisterFuncs(HSQUIRRELVM v) ' begins below
void RegisterFuncs(HSQUIRRELVM v) {

Now let us understand what is what. Don't ask me about 'void RegisterFuncs(HSQUIRRELVM v) ', because it is already there. i mentioned it to specify the location of posting our code.

Code: [Select]
All Squirrel type functions in vcmp plugin begins like this. SQ_abcd is the function name. you can name it as abcd also. (instead of SQ_). No problem. we need the name later.
Code: [Select]
SQInteger n = sq->gettop(v);
Here we are getting the number of arguments passed to our plugin. we will be calling abcd("something",100) from squirrel. However, one extra argument, which i think is called 'root table' also comes. so in our case the number of arguments is not 2, but 3.
we could have used int n instead of SQInteger n. because in c++, everything we do with int. But don't worry. we can use this n the same way as we use int n anywhere. So keep it as SQInteger n.
sq->gettop will return how many arguments are passed( it is called stack and how many members in stack ). In our case we settle it, THREE.
Code: [Select]
if (n == 3) {
const SQChar* a;
We are checking if n is actually three. If somebody called 'abcd("something",100,200)' then n is 4. also n can be 2 if 100 and 200 are avoided.
Now SQChar* a
You know, in c++ strings are handled like 'char* a' and 'const char*a="hello" ' etc. Since we are dealing with squirrel, here it is SQChar* a.
Code: [Select]
sq->getstring(v, 2, &a);
Now get the string and store in our variable 'a'. 2 means the second argument.
first argument is root table, second argument is "something" and third is 100 if we follow the pattern i mentioned above.
Code: [Select]
SQInteger b;
sq->getinteger(v, 3, &b);
I think this is obvious. See here it is 3, because (our second parameter becomes the third parameter here).
What in the world is &b. It is just a symbol used to denote the 'address' of b. Just keep it, no change. it works.
Code: [Select]
printf("a is %s and b is %d", a, b);
return 1;
This is obvious. I think you know about the c++ printf function. it is like our format function in old pawn. (btw i am building a pawn plugin now). s denotes string. d denotes integer.
return 1. this 1 will be returned to squirrel.
ie.abcd("something",200) ==1 in squirrel
Code: [Select]
return 0;
In case the function failed, zero is returned.

Now one more step is there.

Go to void RegisterFuncs(HSQUIRRELVM v) {
Inside this function in the end, before function closing bracket add a line.
Code: [Select]
RegisterSquirrelFunc(v, SQ_abcd, "abcd", 0, 0);
This will tell the plugin to make a function named function abcd whose details will be provided by SQ_abcd.
i.e. whenever squirrel calls function abcd, it will redirects to SQ_abcd.
SQ_abcd is what we defined and explained in length above.

Press Ctrl+Shift+B and building starts. Hopefully no error will come. You can see output
Code: [Select]
Open the folder and you can find your dll. I think i had set all options in the (.vcxproj) file so it will be simple for you.
(Go to Build->Configuration Manager->Active Solution Platform. Select x64 for 64 bit or x86 for 32 bit)
So we finally compiled a dll ( plugin ) for windows. (compiling a linux plugin is little difficult, i had already made a topic on it)

Now what? open server.cfg and add name of your plugin there.
Then run vcmp server to test. If you have ysc's input plugin you can straight go to console and type abcd();
Code: [Select]
a is something and b is 100

or if you do not have ysc's input plugin,
Code: [Select]
function onScriptLoad()

Tutorials / vehicle.Damage Complete Information
« on August 5th, 2020, 06:19 PM »
Hi everybody, i came across setting damage of vehicle and found no articles on it. So i went to vice city, somewhere near Vercetti estate, took a stretch car and started setting vehicle Damage. Here is what i got.

First thing i observed was that Vehicle Damage and Vehicle Health are independent.

bumper damaged

bumper removed

rear bumper (back side) damaged

rear bumper lost

left door (driver's) damaged

Left door opened. So when driving the car, this door will be flying, but still attached. To remove left door completely, use 48=32+16

Right door damaged.FRONT. Passenger 1

Right door is opened. To remove right door completely use 192

Left Back door damaged

512 left back door opened. Use 768 to remove this door completely.

1024 right back door damaged

2048 right back door opened. Use 3072 = 2048+1024 to remove this door completely

damage the part of the car above FRONT right tyre. i dont know what this part is called. here is an image

8192 the above mentioned part is removed completely

16384 now the same part above LEFT FRONT tyre. damaged.

32768 the same part removed completely.

65536 FRONT bonnet partially damaged

131072 bonnet will be flying while car moving( but still attached to vehicle )

To remove the bonnet use 65536+131072=196608

262144 trunk damaged.(also called dicky) BACKSIDE

524288 Flying trunk.

To remove trunk completely use 786432

1048576 Front glass(WINDSHIELD) broken

2097152 WINDSHIELD lost ( i don't know but 3145728 (which i found to be the sum of above two numbers) also is used to indicate that this part is removed completely.

4194304 LEFT front TYRE popped. (flat). sparks

8388608 LEFT front tyre not found/removed completely.

16777216 LEFT BACK tyre popped/flat

33554432 LEFT BACk tyre removed

67108864 RIGHT front TYRE popped and 134217728 for removing it

268435456 RIGHT BACK tyre popped. 536870912 (the largest value) for removing this tyre completely.

This last value is 2 raised to power 29. i tried higher powers, like 30 but no effect.

Now how this values can be combined?
VCMP server has some kind of technology.

eg. There are two doors in the front side. One on left side of driver and other on right side of passenger. To remove left door alone, use vehicle.Damage=48. To remove right door alone, use vehicle.Damage=192. Now to remove both the doors, use vehicle.Damage= 240. How i got 240? by adding 48 and 192.

Exercise. Remove all 4 doors+bonnet+trunk

This is the VCMP server technology i mentioned, ie. adding numbers.

That's all. I hope this will be useful to everyone.

Snippet Showroom / Snippet to face a player to another player
« on July 19th, 2020, 03:28 PM »
Suppose you want player A to face to player B, you can use
Code: [Select]
Today, i will show you how to compile your plugin for linux.

You must be having Visual Studio on your computer. Your computer is windows.

You must also have a linux vps.( mine is ubuntu )

What we do is install a thing on vps which will be used for compiling. Then give details of vps to Visual studio ( username: root, password:, and IP address )

Then just click on build on Visual studio. It will copy your project to vps. compile it there and bring back your  output. ( or show a couple of error :D

Detailed Instruction
Step one-> Install Linux Development Workload

2. Create a new Linux Console Application

3. Build. ( it will ask you for details of vps. ip address, username, password. give it )


4. You will get error. Go to your vps and install gdb server.
Code: [Select]
sudo apt install -y build-essential gdbserver

Now it will work. The first application will be a helloworld application by default ( has .out extension). You can copy the file to vps and run it by ./ConsoleApplication.out

Now we are building plugin. It has .so extension. So in visual studio, go to solution properties and change .out to .so

You are done.

Now delete ConsoleApplication.cpp and paste our vcmp plugin files, i.e. SQMain.cpp, SQMain.h, SQFuncns.cpp, SQFuncs.h, plugin.h, ConsoleUtils.cpp, ConsoleUtils.h.
copy the files to project directory

add->existing item

Your are successfully completed. Now click build and your will be ready.


Files( SQMain.cpp, SQFuncs.cpp, etc. )

tags: Remote build
General Discussion / killer and player in onPlayerKill
« on June 17th, 2020, 03:12 PM »
Actually, the function is onPlayerKill( killer, player, reason, bodypart )

but, in blank server i noticed that the script order is onPlayerKill( player, killer, reason, bodypart ).

It confuses people as well as new bies
( like me two months ago. I was  killing myown client2 minimized, but his kills were increasing)

so seby, take any actions? ;D
Scripting and Server Management / about Bytes Stream
« on June 14th, 2020, 06:03 AM »
We client script and use stream to pass data. So a quick question.
Especially in blank server, store/main.nut we make something like following,

I used to think how far we can go on numbering. All about the answer flashed to me yesterday, while working with some streams.

I will tell after poll is finished
Community Plugins / VCMP helloworld plugin
« on May 12th, 2020, 11:52 AM »

This is a simple module.

It has only one function hello(). When called, it outputs Hello World!

You can download it from here

Just open helloworld.vcxproj file. You will need Visual Studio.

Happy Editing :)
Community Plugins / create bots with this plugin
« on May 11th, 2020, 01:49 PM »
This is a squirrel plugin to create bots in the server.
Download plugins



Installation  ( very easy )

Copy the actor64.dll into plugins folder. Open server.cfg find the line plugins, add 'actor64' to the last. see pic below

Only two functions now,
create_actor(name, skinId, x, y, z, angle), set_actor_angle

Code: [Select]
function onScriptLoad()
create_actor( "medic", 5, -656, 756, 11.2, 1.5 );  //5 == ambulance man
create_actor( "emma", 65, -660, 758, 11.2, -1.5 ); 


create_actor("kevin",5); will spawn a medic with name 'kevin'

create_actor("Edward",1,-656,756,11.2,0); will spawn a cop at downtown facing north.

setport("8193"); ( in case your port is not 8192, but 8193 );

1. actorid and playerid are different.
2. create_actor returns an integer which is 0 for 1st bot, 1 for 2nd bot and so on. We can call it actor id. 
3. create_actor function will take a little time to create bots.
4. If your server has registration system, you must add the bots name to database. Otherwise the bots cannot spawn.

For detailed documentation, see click Source code below and view readme file.

Note: This project was built with Visual Studio 2019.           Source code

Linux Version

64 bit

32 bit

Source code

Functions are same except set_port. The parameter inside set_port must be integer. eg. set_port( 8193 ). Default is 8192.
Tutorials / create_actor
« on April 28th, 2020, 09:04 PM »
yeah. finally..

What is it?
creating random actors here and there in server.
here and there?
yes. at any place u want.
how many?
atmost some 40 without lag. i created a seventy five one of them with lag
75 what?

Tell me the cmd to create it.
it goes like create_actor x y z

Enough. To experienced scripters, i explain what this is. A python program will run  with your server -it is a socket server. you connect a socket to it
Code: [Select]
socket.Send("create_actor 116 lance -661.12 756.365 11.0966 0")
and actor is ready within seconds.

If you have knowledge about packets,
How many packets are send?
one packet per bot in every 2 seconds. it is a ping packet. otherwise it disconnects. Packets are send to the server from python program.

hi guys, i did not know python. for this purpose i learned it.

actor is a word used in vice city script file to the player, cop, pedestrians etc. you might know.
How much time the actor lives?
Until you "destroy_actor id"

So what are the commands you developed?
create_actor skinID name x y z angle
set_actor_pos id x y z
set_actor_health id 100
for the first actor you create, id will be 1, then 2, then 3, and so on.

Any other? Two more commands are there, which i developed by evening.
set_actor_weapon id 22
set_actor_angle id 3.14

codes here->
Also, i recommend you to use cmdinputrel by ysc, to have easy interaction with bots.
General Discussion / wiki down for two months
« on April 21st, 2020, 01:36 PM »
the vcmp wiki is down for a long time. I wish contribute to wiki, about vehicle.Angle and vehicle.Rotation, etc
Tutorials / half bots
« on April 16th, 2020, 02:59 PM »
Today i will show how to have a kind of bots in your server.

First you go to server and 'record' actions for say 5 minutes. I will tell how to 'record'.
Then you play it. the same things happen in server.

1. You need wireshark
2. You need python ( mine is not 3 , it is 2.x )
3. Scapy

You are going to connect to a server ( do not connect to but something else )
Now, open wireshark and select interface ( mine is Wi-Fi )
Then it will start recording packets. All you need is open VCMP Browser. Select your server play on it for some time.
Then come back to wireshark and stop. Then save the packets in *.pcap extension. eg. play.pcap

Now you can play it in two ways. 1. Colasoft Packet Player which is the software i started with. But you do not need it, since i made a python code to manually play the packets. So here 2. Using python and scapy to play it. Edit the python file below and change ip address, name, etc. Place your pcap file and python file in same folder and run the python file. You will see a new player appearing in your server.

Code: [Select]
#!/usr/bin/env python3
# importing the threading module
import threading
from scapy.all import *
from scapy.utils import rdpcap
import time
import sys

if __name__ == "__main__":
    name = "hh17"# 4 letter   
    old_name = "habi"
    for b in a:
        if hasattr(b, 'load'):
                if b.load.find(bytes(old_name.encode())) >=0:
        if(UDP in b):
            del b[UDP].chksum
            del b[UDP].len
        if(Ether in b and IP in b and UDP in b):
            send(IP(dst="")/b[UDP], verbose=True,iface='Npcap Loopback Adapter');
            m= float( a[i+1].time - a[i].time );