02.07.2015, 05:38
(
Last edited by !damo!spiderman; 19/08/2015 at 05:01 AM.
)
samp.js is a plugin which allows you to create scripts in JavaScript for SA-MP.
It is currently in Alpha mainly due to the amount of changes I do every day which are not fully tested or complete. It is however being used on live servers without any issues.
Features:
Due to the high system requirements for compiling ( thanks to V8 ) and lack of complete instructions and makefiles/project files I highly recommend testing using the binaries supplied, until I make working instructions available.
All pawn functions have been automatically recreated in JavaScript, with the syntax basically the same except for when referenced variables are involved.
Most plugins can also be used within samp.js, a special nodejs converter script can be ran which will convert all the plugins functions into JavaScript functions.
Example Script:
MySQL Example
I will provide more examples as I go
You can find me in #samp.js on the irc.tl network
GitHub Page
API Documentation
Latest Release
Latest Release - Linux
Latest Release - Windows
Streamer Plugin Support with Callbacks
https://github.com/damospiderman/sam...ugins/streamer
Streamer Callback example
Special Thanks
ev0lution - Testing, Scripts, emotional support
Laronic - Bug finding and code additions
andievandy - Bug finding and code additions
It is currently in Alpha mainly due to the amount of changes I do every day which are not fully tested or complete. It is however being used on live servers without any issues.
Features:
- JavaScript - Easy to use dynamic language
- Runs on the fast V8 JavaScript Engine - The same engine powering Chrome/Chromium and Node.js
- Async/Threaded Sockets library ( example Irc bot class included )
- MySQL library *NEW*. Easy to use Async(threaded) MySQL implementation
- Player wrapper class ( Vehicle, Objects, Dialog, TextDraw etc classes to come )
- New ES6 JavaScript features including classes, block scope variables and template strings
- Modules
- Advanced Event loop
Due to the high system requirements for compiling ( thanks to V8 ) and lack of complete instructions and makefiles/project files I highly recommend testing using the binaries supplied, until I make working instructions available.
All pawn functions have been automatically recreated in JavaScript, with the syntax basically the same except for when referenced variables are involved.
Most plugins can also be used within samp.js, a special nodejs converter script can be ran which will convert all the plugins functions into JavaScript functions.
Example Script:
PHP Code:
$server.on("ScriptInit", function(){
// Create a timer which runs once a minute infinitely
SetTimer(function(){
// loop through all players
for(let player of $players){
player.health-=0.1;
}
}, 60000, -1 );
});
$server.on("GameModeInit", function(){
print("Game Mode Started");
});
$server.on("PlayerSpawn", function(player){
// Get players position - let is a local var
let pos = player.pos;
// Create a new vehicle at the players position
let vehid = CreateVehicle(522, pos.x+1, pos.y, pos.z, pos.a, -1,-1,0);
// Put the player in the vehicle we just created
player.vehicle = vehid;
});
$server.on("PlayerCommandText", function(player, text){
let args = text.split(' ');
let cmd = args.shift();
let msg = args.join(' ');
switch(cmd){
case '/pm':
{
if(isNaN(args[0])){
SendClientMessage( player, -1, "/pm [playerid] [message]");
return 1;
}
let id = args.shift();
msg = args.join(' ');
SendClientMessage(id,0x00FF00F, `PM from ${player.name}: ${msg}`);
return 1;
}
}
return 0;
});
I will provide more examples as I go
You can find me in #samp.js on the irc.tl network
GitHub Page
API Documentation
Latest Release
Latest Release - Linux
Latest Release - Windows
Streamer Plugin Support with Callbacks
https://github.com/damospiderman/sam...ugins/streamer
Streamer Callback example
PHP Code:
$server.on("DynamicObjectMoved", function(objectid){
});
$server.on("PlayerEditDynamicObject", function(player, objectid, response, x,y,z,rx,ry,rz){
});
ev0lution - Testing, Scripts, emotional support
Laronic - Bug finding and code additions
andievandy - Bug finding and code additions