How to setup java server?

Started by PENE, Aug 13, 2018, 11:46 AM

Previous topic - Next topic

PENE

I would like to do the simple server, but on java (squirrel I know good now, so now its a time to try something new). I never to do a somethings on java, so I know it will be difficult at the beginning.

First step, where I have a problem is...


 Vice City Multiplayer Server
 -------------------------------
 v0.4, (c) 2007-2014 VC:MP Team

Loaded plugin: announce04rel64

Loaded plugin: geoip04rel64

Loaded plugin: hashing04rel64

Plugin error >> VcmpPluginInit in 'plugins/libjavapluginrel64.dll' returned 0.
Failed to load plugin: libjavapluginrel64

Loaded plugin: sqlite04rel64

[WEAPONS] No custom weapons to load.
[VEHICLEMODELS] No custom vehicle models to load.
** Started VC:MP 0.4 Server **
 Port: 1000
 Max players: 30

[MODULE]  Loading GeoIP for 0.4 by Crys.
[MODULE]  Loaded GeoIP.dat (GeoIP Country Edition)


[MODULE]  Loaded SQLite3 for VC:MP by Stormeus.

About my pc and server version:

* Windows 10 x64
* VC-MP 04rel006
* Server uses lasted relase, for x64 os.
* And lasted java plugin for x64 os.





Next question... It's possible to do a simple tutorial with how to compile java script for vcmp?

Btw. I know how to do a squirrel server, scripting but I want something new. Everyone starts somehow and I also want to try. It is possible that this topic will also help someone.

Thanks.

NewK

#1
I've set up a netbeans project with a sample vcmp script that you can use as a starting point. Here's how to get started:

  • Download and Install JDK8
  • Download netbeans
  • After installing netbeans, open it and go to the top bar where it says "Team-->Git-->Clone" and paste this link where it says "Repository URL": https://github.com/newk5/vcmp-sample-script.git
  • Press Next and then Finish and wait a bit and a window will probably pop up asking you to open the project
  • After the project is opened on netbeans go to the top bar where it says "Run-->Clean and Build project", this will compile the script
  • After that is done go to your Documents and there should be a folder there called "NetBeansProjects" and inside it there will a folder called VCMP-SampleScript, and inside it there will a folder called "server". Open that folder and edit javaplugin.properties file with the instructions specified there. After you edited that file make sure to delete the instructions

After all that is done just run the server64.exe (server32.exe in case you have a 32bit windows) or mpsvrrel64/32 if you're on linux.

PENE

Okey, big thanks, I compiled the basic script but... still i have error with plugin :/

x86:
Plugin error >> LoadLibrary() 'plugins/libjavapluginrel64.dll' failed: Code 193
Failed to load plugin: libjavapluginrel64

x64:
Plugin error >> VcmpPluginInit in 'plugins/libjavapluginrel64.dll' returned 0.
Failed to load plugin: libjavapluginrel64

Idk whats wrong here...

NewK

Use server64.exe only since you're on a 64bit OS. 

Something is most likely wrong on your javaplugin.properties file. Show me the contents of that file

rww

For me works ;)

[spoiler]

[/spoiler]
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X

PENE

Quote from: NewK on Aug 14, 2018, 04:05 PMUse server64.exe only since you're on a 64bit OS. 

Something is most likely wrong on your javaplugin.properties file. Show me the contents of that file

Yeah, I forgot about remove from one line comments. I have a next question. I can't use Vector(x,y,z) and Colour. I try

server.addPlayerClass(0, 0x00000000, 0, Vector(0.0f, 0.0f, 20.0f), 0.0f, 0, 0, 0, 0, 0, 0);

and "can't find symbol
symbol: method vector etc..."

also I have problem with gametext, i can't use in string \x10
squirrel:
Announce("\x10 \x10 \x10 \x10 \x10 ~b~Welcome", player, 7);

NewK

There's 2 method signatures you can use for addPlayerClass, you need to choose 1:

addPlayerClass(int teamId, Colour colour, int modelId, Vector position, float angle, WeaponAndAmmo[] weapons);
addPlayerClass(int teamId, int colourHex, int modelId, float x, float y, float z, float angle, int weaponOne, int weaponOneAmmo, int weaponTwo, int weaponTwoAmmo, int weaponThree, int weaponThreeAmmo);
Could be:
WeaponAndAmmo[] weapons = new WeaponAndAmmo[]{
        new WeaponAndAmmo(19, 999), //shotgun
        new WeaponAndAmmo(18, 999), //python
        new WeaponAndAmmo(26, 999) //m4
 };
server.addPlayerClass(5, new Colour(255, 0, 0), 73, new Vector(0, 0, 0), 338.7986f, weapons);

or

server.addPlayerClass(73, 0xFF, 73, 0, 0, 0, 0, 19, 999, 18, 999, 26, 999);

About Announce that is a squirrel function it wont work in java. To make an announcement you have to use:

sendGameMessage(Player recipient, int type, String message)For example:
server.sendGameMessage(player, 1, "hello");

PENE

Quote from: NewK on Aug 18, 2018, 07:49 PMThere's 2 method signatures you can use for addPlayerClass, you need to choose 1:

addPlayerClass(int teamId, Colour colour, int modelId, Vector position, float angle, WeaponAndAmmo[] weapons);
addPlayerClass(int teamId, int colourHex, int modelId, float x, float y, float z, float angle, int weaponOne, int weaponOneAmmo, int weaponTwo, int weaponTwoAmmo, int weaponThree, int weaponThreeAmmo);
Could be:
WeaponAndAmmo[] weapons = new WeaponAndAmmo[]{
        new WeaponAndAmmo(19, 999), //shotgun
        new WeaponAndAmmo(18, 999), //python
        new WeaponAndAmmo(26, 999) //m4
 };
server.addPlayerClass(5, new Colour(255, 0, 0), 73, new Vector(0, 0, 0), 338.7986f, weapons);

or

server.addPlayerClass(73, 0xFF, 73, 0, 0, 0, 0, 19, 999, 18, 999, 26, 999);

About Announce that is a squirrel function it wont work in java. To make an announcement you have to use:

sendGameMessage(Player recipient, int type, String message)For example:
server.sendGameMessage(player, 1, "hello");

Okey, player class works, but about Announce I know it's server.sendGameMessage ;) but I can't use something like this

server.sendGameMessage(player, 7, "\x10 \x10 \x10 \x10 \x10 \x10 \x10 " + player.getSkin());

with error by \x10 (moves the text to the next line)

NewK

You probably need to escape that backslash, try it like this:
server.sendGameMessage(player, 7, "\\x10 \\x10 \\x10 \\x10 \\x10 \\x10 \\x10 " + player.getSkin());

PENE

Quote from: NewK on Aug 19, 2018, 07:18 AMYou probably need to escape that backslash, try it like this:
server.sendGameMessage(player, 7, "\\x10 \\x10 \\x10 \\x10 \\x10 \\x10 \\x10 " + player.getSkin());



:/

NewK

k, this will work:
server.sendGameMessage(player, 7, "\n \n \n \n \n \n \n " + player.getSkin());

PENE

ehh.. next stupid question :|

I do a SkinNameList.java in com.github.newk5.vcmp.samplescript.entitles

[noae]package com.github.newk5.vcmp.samplescript.entities;

public class SkinNameList {

    public String SkinNameList(int i) {
      switch (i) {
        case 0:   return "Tommy Vercetti";
case 1:   return "Cop";
case 2:   return "SWAT";
case 3:   return "FBI";
case 4:   return "Army";
        case 5:   return "Paramedic";
case 6:   return "Firefighter";
case 7:   return "Golf Guy #1";
case 9:   return "Bum Lady #1";
case 10:  return "Bum Lady #2";
case 11:  return "Punk #1";
case 12:  return "Lawyer";
case 13:  return "Spanish Lady #1";
case 14:  return "Spanish Lady #2";
case 15:  return "Cool Guy #1";
case 16:  return "Arabic Guy";
case 17:  return "Beach Lady #1";
case 18:  return "Beach Lady #2";
case 19:  return "Beach Guy #1";
case 20:  return "Beach Guy #2";
case 21:  return "Office Lady #1";
case 22:  return "Waitress #1";
case 23:  return "Food Lady";
case 24:  return "Prostitute #1";
case 25:  return "Bum Lady #3";
case 26:  return "Bum Guy #1";
case 27:  return "Garbageman #1";
case 28:  return "Taxi Driver #1";
case 29:  return "Haitian #1";
case 30:  return "Criminal #1";
case 31:  return "Hood Lady #1";
case 32:  return "Granny #1";
case 33:  return "Businessman #1";
case 34:  return "Church Guy";
case 35:  return "Club Lady #1";
case 36:  return "Church Lady";
case 37:  return "Pimp";
case 38:  return "Beach Lady #3";
case 39:  return "Beach Guy #3";
case 40:  return "Beach Lady #4";
case 41:  return "Beach Guy #4";
case 42:  return "Businessman #2";
case 43:  return "Prostitute #2";
case 44:  return "Bum Lady #4";
case 45:  return "Bum Guy #2";
case 46:  return "Haitian #2";
case 47:  return "Construction Worker #1";
case 48:  return "Punk #2";
case 49:  return "Prostitute #3";
case 50:  return "Granny #2";
case 51:  return "Punk #3";
case 52:  return "Businessman #3";
case 53:  return "Spanish Lady #3";
case 54:  return "Spanish Lady #4";
case 55:  return "Cool Guy #2";
case 56:  return "Businessman #4";
case 57:  return "Beach Lady #5";
case 58:  return "Beach Guy #5";
case 59:  return "Beach Lady #6";
case 60:  return "Beach Guy #6";
case 61:  return "Construction Worker #2";
case 62:  return "Golf Guy #2";
case 63:  return "Golf Lady";
case 64:  return "Golf Guy #3";
case 65:  return "Beach Lady #7";
case 66:  return "Beach Guy #7";
case 67:  return "Office Lady #2";
case 68:  return "Businessman #5";
case 69:  return "Businessman #6";
case 70:  return "Prostitute #4";
case 71:  return "Bum Lady #4";
case 72:  return "Bum Guy #3";
case 73:  return "Spanish Guy";
case 74:  return "Taxi Driver #2";
case 75:  return "Gym Lady";
case 76:  return "Gym Guy";
case 77:  return "Skate Lady";
case 78:  return "Skate Guy";
case 79:  return "Shopper #1";
case 80:  return "Shopper #2";
case 81:  return "Tourist #1";
case 82:  return "Tourist #2";
case 83:  return "Cuban #1";
case 84:  return "Cuban #2";
case 85:  return "Haitian #3";
case 86:  return "Haitian #4";
case 87:  return "Shark #1";
case 88:  return "Shark #2";
case 89:  return "Diaz Guy #1";
case 90:  return "Diaz Guy #2";
case 91:  return "DBP Security #1";
case 92:  return "DBP Security #2";
case 93:  return "Biker #1";
case 94:  return "Biker #2";
case 95:  return "Vercetti Guy #1";
case 96:  return "Vercetti Guy #2";
case 97:  return "Undercover Cop #1";
case 98:  return "Undercover Cop #2";
case 99:  return "Undercover Cop #3";
case 100: return "Undercover Cop #4";
case 101: return "Undercover Cop #5";
case 102: return "Undercover Cop #6";
case 103: return "Rich Guy";
case 104: return "Cool Guy #3";
case 105: return "Prostitute #5";
case 106: return "Prostitute #6";
case 107: return "Ricardo Diaz";
case 108: return "Love Fist #1";
case 109: return "Ken Rosenburg";
case 110: return "Candy Suxx";
case 111: return "Hilary";
case 112: return "Love Fist #2";
case 113: return "Phil";
case 114: return "Rockstar Guy";
case 115: return "Sonny";
case 116: return "Lance";
case 117: return "Mercedes";
case 118: return "Love Fist #3";
case 119: return "Alex Shrub";
case 120: return "Lance (Cop)";
case 121: return "Lance";
case 122: return "Cortez";
case 123: return "GIGN Agent";
case 124: return "Gonzalez";
case 125: return "Hilary (Robber)";
case 126: return "Mercedes";
case 127: return "Cam";
case 128: return "Cam (Robber)";
case 129: return "Phil (One Arm)";
case 130: return "Phil (Robber)";
case 131: return "Cool Guy #4";
case 132: return "Pizza Man";
case 133: return "Taxi Driver #1";
case 134: return "Taxi Driver #2";
case 135: return "Sailor #1";
case 136: return "Sailor #2";
case 137: return "Sailor #3";
case 138: return "Chef";
case 139: return "Criminal #2";
case 140: return "French Guy";
case 141: return "Garbageman #2";
case 142: return "Haitian #5";
case 143: return "Waitress #2";
case 144: return "Sonny Guy #1";
case 145: return "Sonny Guy #2";
case 146: return "Sonny Guy #3";
case 147: return "Columbian Guy #2";
case 148: return "Haitian #6";
case 149: return "Beach Guy #8";
case 150: return "Garbageman #3";
case 151: return "Garbageman #4";
case 152: return "Garbageman #5";
case 153: return "Tranny";
case 154: return "Thug #5";
case 155: return "SpandEx Guy #1";
case 156: return "SpandEx Guy #2";
case 157: return "Stripper #1";
case 158: return "Stripper #2";
case 159: return "Stripper #3";
case 160: return "Store Clerk";
case 161: return "Tommy Vercetti";
case 162: return "Soiree Outfit";
case 163: return "Coveralls Outfit";
case 164: return "Country Club Outfit";
case 165: return "Havana Outfit";
case 166: return "Cop Outfit";
case 167: return "Bank Job Outfit";
case 168: return "Casual Outfit";
case 169: return "Mr. Vercetti Outfit";
case 170: return "Tracksuit #1";
case 171: return "Tracksuit #2";
case 172: return "Cool Guy #5";
case 173: return "Cool Guy #6";
case 174: return "Prostitute #7";
case 175: return "Sonny Guy #4";
case 176: return "Prostitute #8";
case 177: return "Club Lady #2";
case 178: return "Prostitute #9";
case 179: return "Haitian #7";
case 180: return "Frankie Outfit";
case 181: return "Sonny Guy #5";
case 182: return "Columbian Guy #3";
case 183: return "Hood Lady #2";
case 184: return "Punk #4";
case 185: return "Waitress #3";
case 186: return "Kent Paul";
        default: return "Unknown";
      }
    }
}
[/noae]

and I try to use SkinNameList in MainController.java but I only can, when I put this function to MainController.java. I can't use from SkinNameList.java :/



Sorry for ask about everything, I know Im annoying now for you ;x But maybe it's help someone who also use java first time ;)

NewK

If you want to use public methods inside a class from another class (MainController) you need to instantiate your class. So at the top of MainController just add:
private SkinNameList skins = new SkinNameList();
And then you can call your method with:

skins.SkinNameList(intValue);
However if you're creating a class with utility methods like the one on your screenshot, you can turn the methods into static methods and that way you won't need to instantiate your class. Change your method from
public String SkinNameList(int i)to
public static String SkinNameList(int i)and that way you can use it like this:
SkinNameList.SkinNameList (intValue);