[Plugin] samp.js - JavaScript for SA-MP
#21

Quote:
Originally Posted by !damo!spiderman
View Post
Can you tell me what non-english symbols you're using and how you're using them in a script?
Cyrillic, in chat messages

Example:
PHP Code:
$server.on("PlayerConnect", function(player) {
    
SendClientMessage(player.id, -1"Welcome! Добро пожаловать!");
}); 
Reply
#22

Quote:
Originally Posted by BonhommeG
View Post
Cyrillic, in chat messages

Example:
PHP Code:
$server.on("PlayerConnect", function(player) {
    
SendClientMessage(player.id, -1"Welcome! Добро пожаловать!");
}); 
And are you using the windows version or the linux version?
Reply
#23

Still wondering.. Why didn't you used SAMPGDK in this plugin?
It would save a shitload of time.

As well, If I'm not mistaken, SAMPGDK hooks directly into the server memory, So the scripts execution would be faster too.
Reply
#24

Quote:
Originally Posted by !damo!spiderman
View Post
And are you using the windows version or the linux version?
Yes, Windows version, Win7 x64
Reply
#25

Quote:
Originally Posted by GWMPT
View Post
Still wondering.. Why didn't you used SAMPGDK in this plugin?
It would save a shitload of time.

As well, If I'm not mistaken, SAMPGDK hooks directly into the server memory, So the scripts execution would be faster too.
A few reasons... I didn't want to depend on memory hooks plus on the contrary I have actually saved myself more time doing it the way I have as I wrap all native sa-mp functions in javascript around one expose C++ function and all those wrapped functions are automatically generated, which also works for other plugins. If people end up having issues with speed and can narrow it down to a native function then I'd be happy to look into using the SAMPGDK in the future but for now I wanted to get something working as easily and effortlessly as possible and I doubt people will notice the difference of a few microseconds.
Reply
#26

Quote:
Originally Posted by Crayder
View Post
No, I think he may have no programming knowledge. My guess would be that he doesn't know the difference between a callback and a function.
Wow, I think you must apologize for your words. First read my questions and then talk about my knowledge - I never used this plugin and asked about it's future support. I didn't read it's sources and don't know how it's working.
I'm not so stupid to prove my knowledge of any language and I don't care about your view. Sadly I've met too many of you complexing guys.
Reply
#27

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
If you end up doing that, you can look at my code for an example. My callbacks and natives all load dynamically.
Thanks. Funny enough I had been looking at your code the past 2 days already and did see that you had called it dynamically with it. Plus was looking at what you did for your issue with cyrillic text
Reply
#28

Astonishing work, damo. Keep going m8
Reply
#29

First thing, good job!

Second one is that I really want to use this but I'm confused on how to set everything up and running.

Can someone help me out? Thank you.
Reply
#30

Quote:
Originally Posted by PeterJane
Посмотреть сообщение
First thing, good job!

Second one is that I really want to use this but I'm confused on how to set everything up and running.

Can someone help me out? Thank you.
Hey PeterJane,

Basically all you need to do is download one of the releases and copy all the files and folders into your server directory.

Next just set your gamemode to a blank script and set your filterscript to samp.js

Add samp.js.[so/dll] to your plugins line in the config file

Add a line to your config called jsfiles with a name of a javascript file you would like to load as your script/mode. For example

Код:
jsfiles main.js
Create your js file in the js folder.


You can use this script here https://github.com/damospiderman/sam...xamples/new.js to get you started, its the javascript equivalent of new.pwn

Example Config

Код:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 bare 1
filterscripts samp.js
query 1
chatlogging 0
weburl www.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 10
logtimeformat [%H:%M:%S]
language English
plugins samp.js.dll
jsfiles main.js
Reply
#31

Quote:
Originally Posted by !damo!spiderman
Посмотреть сообщение
Hey PeterJane,

Basically all you need to do is download one of the releases and copy all the files and folders into your server directory.
Thank you damo! It's working now.
Reply
#32

New Update - 0.1.9

After looking into GDK more I have decided to implement it for various reasons. Mainly because it allows us to not need the samp.js filterscript and can also hook any public function easily with the new JavaScript function RegisterPublic("OnPlayerConnect", "i", "PlayerConnect", ["playerid"]);. This isn't limited to just samp native publics either. The speed differences in benchmarks with using GDK and without are basically the same though.

Will be putting up a linux build later. Let me know of any issues/bugs you have.

Changelog
Код:
- Added GDK to call native functions and hook publics
- samp.js filterscript is no longer needed
- Added RegisterPublic to register public function callbacks to the $server.on events
- Added CallNativeGDK for calling native functions via GDK
- Various bug fixes
samp.js v0.1.9
Reply
#33

Linux version for 0.1.9 now compiled

https://github.com/damospiderman/sam...ses/tag/v0.1.9
Reply
#34

This is a small bug major bugfix build

0.1.9.1

Fixes issue with publics/callbacks having incorrect arguments

https://github.com/damospiderman/sam...s/tag/v0.1.9.1
Reply
#35

Another bug fix thanks to Laronic for finding it

0.1.9.2 - BUGFIX:

Fixed issue with CallNativeGDK return undefined
Fixed issue with CallNativeGDK setting all supplied floats to the same value

https://github.com/damospiderman/sam...s/tag/v0.1.9.2
Reply
#36

More bugfixes! Thanks again to Laronic for hammering it so we can iron out all the bugs.

0.1.9.3

Bugfixes:

- Typos in Player.js for this._id
- CallNativeGDK multiple string issue
- CallNativeGDK format string being read incorrectly at times
- Issues with the .inc converter not detecting some reference strings correctly
- Added extra checks to stop server crash when using mysql close
- mysql.ping returning undefined

https://github.com/damospiderman/sam...s/tag/v0.1.9.3
Reply
#37

Quote:
Originally Posted by !damo!spiderman
Посмотреть сообщение
More bugfixes! Thanks again to Laronic for hammering it so we can iron out all the bugs.

0.1.9.3

Bugfixes:

- Typos in Player.js for this._id
- CallNativeGDK multiple string issue
- CallNativeGDK format string being read incorrectly at times
- Issues with the .inc converter not detecting some reference strings correctly
- Added extra checks to stop server crash when using mysql close
- mysql.ping returning undefined

https://github.com/damospiderman/sam...s/tag/v0.1.9.3
Nice, it helped me a lot!
Reply
#38

pretty fast updates. nice work damo
Reply
#39

v0.1.9.4
Download 0.1.9.4

A few bug fixes and a few additions, lots of thanks to Laronic and andievandy for submitting bug reports and adding features

Код:
Changes/Bug Fixes
- Player.js 
     - Various setters/getters had incorrectly named variables causing issues with player.armour,player.health etc to not work ( thanks andievandy )
    - player.world added ( andievandy )
    - player.message( color, message ) Added (SendClientMessage alias)
 - Multiple funcs/getter/setters added by Laronic
      - Added cameraPos getter/setter
      - Added cameraLookAt getter/setter
      - Added cameraAspectRatio getter
      - Added cameraZoom getter
      - Added cameraFrontVector getter
      - Added surfingVehicle getter
      - Added vehicleSeat getter
      - Added toggleSpectate setter
      - Added setCameraBehind() func
      - Added inVehicle(vehicleid) func
      - Added inAnyVehicle() func
      - Added spectateVehicle(vehicleid, mode) func
      - Added spectatePlayer(target, mode) func
      - Added isAdmin() func
      - Added isNPC() func
      - Added kick() func
      - Added ban(reason) func

- Server.js - Additions by Laronic
      - Added `rcon(cmd)` func
      - Added `gamemode` getter/setter

- RegisterPublic was being parsed incorrectly causing callbacks to be cancelled when returning 1 instead of 0
- Events.js caused callbacks to not be called in multiple scripts if not defined in the main script
- print was causing malformed characters on some(one) machine
- Fixed memory leak in print

- mysql query now parses date objects to mysql timestamp ( thanks Laronic )
Thanks to everyone who is using it and testing. Also feel free to make feature requests for anything and I will most probably add it (within reason).

I also have a working example of reading MapAndreas files natively in samp.js with both buffered and non-buffered versions if anyone is interested give me a shout and I will make it pretty and upload it
Reply
#40

Great work! I'm really enjoying it
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)