SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 05/07/2015, 11:14 AM   #51
KingHual
Banned
 
Join Date: Jun 2010
Location: Bulgaria
Posts: 2,290
Reputation: 1389
Default Re: samp.js - JavaScript for SA-MP

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.
Saying someone has no programming knowledge because they aren't familiar with a concept found in one programming language is just stupid. There is no difference between a callback and a function outside of Pawn. Both are called methods/subroutines.
KingHual is offline   Reply With Quote
Old 05/07/2015, 11:29 AM   #52
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by BonhommeG View Post
Yes, Windows version, Win7 x64
Please use this version: https://github.com/damospiderman/sam...in/samp.js.dll

And put this in "ScriptInit" event or at the top of your script somewhere

Code:
setlocale("Russian");
Will do a linux version soon.
__________________
!damo!spiderman is offline   Reply With Quote
Old 05/07/2015, 01:49 PM   #53
ikkentim
High-roller
 
ikkentim's Avatar
 
Join Date: Jan 2010
Location: Kampen, The Netherlands
Posts: 1,052
Reputation: 205
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by !damo!spiderman View Post
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.
If you end up doing that, you can look at my code for an example. My callbacks and natives all load dynamically.
__________________
Greetings,
Tim Potze

Projects
GAMEDEV | Part-time developer working on Parkitect. | Steampage
LSRES | A SA:MP server from the past, and hopefully, back in the future.
SampSharp | Plugin for writing SA:MP gamemodes in C#. | Topic Website Github
SanMap | San Andreas in G00GLE MAPS! | Topic Github Sample
ikkentim is offline   Reply With Quote
Old 05/07/2015, 02:13 PM   #54
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by ikkentim View Post
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
__________________
!damo!spiderman is offline   Reply With Quote
Old 05/07/2015, 03:02 PM   #55
Kapersky™
Gangsta
 
Kapersky™'s Avatar
 
Join Date: Jul 2014
Location: !ncredible India.
Posts: 698
Reputation: 344
Default Re: samp.js - JavaScript for SA-MP

Astonishing work, damo. Keep going m8
__________________
around.
Kapersky™ is offline   Reply With Quote
Old 05/07/2015, 07:47 PM   #56
PeterJane
Big Clucker
 
PeterJane's Avatar
 
Join Date: Dec 2014
Posts: 118
Reputation: 13
Default Re: samp.js - JavaScript for SA-MP

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.
PeterJane is offline   Reply With Quote
Old 05/07/2015, 11:37 PM   #57
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by PeterJane View Post
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

Code:
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

Code:
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
__________________
!damo!spiderman is offline   Reply With Quote
Old 06/07/2015, 01:15 PM   #58
PeterJane
Big Clucker
 
PeterJane's Avatar
 
Join Date: Dec 2014
Posts: 118
Reputation: 13
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by !damo!spiderman View Post
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.
PeterJane is offline   Reply With Quote
Old 11/07/2015, 04:37 AM   #59
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

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
Code:
- 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
__________________
!damo!spiderman is offline   Reply With Quote
Old 12/07/2015, 03:08 PM   #60
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Linux version for 0.1.9 now compiled

https://github.com/damospiderman/sam...ses/tag/v0.1.9
__________________
!damo!spiderman is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript. Banditukas Everything and Nothing 18 04/04/2015 05:00 PM
[Pedido] botăo: script/ HTML/ JAVASCRIPT | SAMP FOLDER/FILE MestreSmart Portuguęs/Portuguese 6 28/02/2015 05:16 PM
Use PHP in javascript Banditukas Everything and Nothing 5 08/11/2014 05:44 AM
javascript samp:// [Ger]Little_Grandpa Help Archive 6 21/08/2010 06:24 PM


All times are GMT. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.