SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/07/2015, 05:03 PM   #71
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 523
Reputation: 437
Default Re: samp.js - JavaScript for SA-MP

For some reason the print function is getting called two times in the latest version (v0.1.9.4). Maybe it could also be an issue in the event system?

With the follow code:
PHP Code:
$server.on('GameModeInit', function() {
    print(
'test');
    print(
'test2');
    return 
1;
});

$server.on('PlayerConnect', function(player) {
    print(
'Player ' player.id ' joined.');
    return 
1;
}); 
I get this in the console/server_log:
Code:
[18:51:07] Player 0 joined.
[18:51:07] test
[18:51:07] test2
[18:51:07] Player 0 joined.
[18:51:07] test
[18:51:07] test2
Somebody else have also this issue or is it just me?
BlackBank is offline   Reply With Quote
Old 26/07/2015, 06:24 PM   #72
!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 BlackBank3 View Post
For some reason the print function is getting called two times in the latest version (v0.1.9.4). Maybe it could also be an issue in the event system?

With the follow code:
PHP Code:
$server.on('GameModeInit', function() {
    print(
'test');
    print(
'test2');
    return 
1;
});

$server.on('PlayerConnect', function(player) {
    print(
'Player ' player.id ' joined.');
    return 
1;
}); 
I get this in the console/server_log:
Code:
[18:51:07] Player 0 joined.
[18:51:07] test
[18:51:07] test2
[18:51:07] Player 0 joined.
[18:51:07] test
[18:51:07] test2
Somebody else have also this issue or is it just me?
That's really weird, I haven't noticed anything like that in my tests.

Are you using the Windows version or Linux?
__________________
!damo!spiderman is offline   Reply With Quote
Old 26/07/2015, 06:26 PM   #73
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Actually I think I know what it is. Are you still using the old samp.js filterscript? If so you need to remove it as its not needed anymore and will cause issues ( like events being called twice )
__________________
!damo!spiderman is offline   Reply With Quote
Old 26/07/2015, 06:49 PM   #74
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 523
Reputation: 437
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by !damo!spiderman View Post
Actually I think I know what it is. Are you still using the old samp.js filterscript? If so you need to remove it as its not needed anymore and will cause issues ( like events being called twice )
I was indeed using the old samp.js filterscript, removed it and it works again! Thanks
BlackBank is offline   Reply With Quote
Old 30/07/2015, 11:00 PM   #75
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Big updates, mainly thanks to Laronic for doing lots of JavaScript helper classes and testing

samp.js 0.1.9.5
Code:
***General***
- Fixed issue with CallNativeGDK cutting reference strings for some users
- Fixed issue with CallNativeGDK crashing when calling new SHA256_PashHash
function
- Added support for arrays and referenced arrays in CallNativeGDK with a(int) v(float) A(int)
V(float) specifiers
- Fixed memory leaks in CallNativeGDK
include() now searches js folder then js/include folder if file can't be
found
- Fixed issue with callbacks/events from other plugins crashing server when
called
- Fixed issue with invalid player objects in callbacks/events being
undefined
- Added PlayerObject.js, GlobalObject.js, TextDraw.js, GlobalTextDraw.js, Vehicle.js ( thanks Laronic )

***MySQLConnection***
- query func now return class object

***Player.js***
- Added setVar(type, varName, value) func
- Added deleteVar(varName) func
- Added getVar(type, varName) func
- Added getVarType(varName) func
- Added getVarUpperIndex(varName) func
- Added getVarNameAtIndex(index) func
- Added textDrawCreate(text, pos) func
- Added textDrawDestroy(textDraw) func
- Added textDrawShow(textDraw) func
- Added textDrawHide(textDraw) func
- Added textDrawLetterSize(textDraw, size) func
- Added textDrawTextSize(textDraw, size) func
- Added textDrawAlignment(textDraw, align) func
- Added textDrawColor(textDraw, color) func
- Added textDrawUseBox(textDraw, toggle) func
- Added textDrawBoxColor(textDraw, color) func
- Added textDrawSetShadow(textDraw, shadow) func
- Added textDrawSetOutline(textDraw, outline) func
- Added textDrawBackgroundColor(textDraw, color) func
- Added textDrawSetFont(textDraw, font) func
- Added textDrawSetProportional(textDraw, toggle) func
- Added textDrawSetSelectable(textDraw, toggle) func
- Added textDrawSetString(textDraw, string) func
- Added textDrawSetPreviewModel(textDraw, previewModel) func
- Added textDrawSetPreviewRot(textDraw, previewRot) func
- Added textDrawSetPreviewVehCol(textDraw, color) func
- Added streamedInFor(target) func
- Added setMarkerFor(target, color) func
- Added showNameTagFor(target, show) func
- Added sendMessageTo(target, message) func
- Added sendDeathMessageToPlayer(killer, victim, weapon) func
- Added editObject(objectid) func
- Added selectObject() func
- Added cancelEdit() func
- Added objectCreate(objectid, pos, rot, drawDistance) func
- Added objectDestroy(objectid) func
- Added objectIsValid(objectid) func
- Added objectIsMoving(objectid) func
- Added objectEdit(objectid) func
- Added objectAttachToVehicle(objectid, vehicleid, offset, rot) func
- Added objectAttachCamera(playerid, objectid) func
- Added objectMove(objectid, speed, pos, rot) func
- Added objectStop(objectid) func
- Added objectSetPos(objectid, pos) func
- Added objectGetPos(objectid) func
- Added objectSetRot(objectid, rot) func
- Added objectGetRot(objectid) func
- Added objectModel(objectid) func
- Added objectSetNoCameraCol(objectid) func
- Added objectSetMaterial(objectid, materialIndex, modelid, txdName, textureName, materialColor) func
- Added objectSetMaterialText(objectid, text, materialIndex, materialSize, fontFace, fontSize, bold, fontColor, backColor, textAlignment) func
- Added spawnInfo(team, skin, pos, weaponData1, weaponData2, weaponData3) func
- Added spawn() func
- Added forceClassSelection() func
- Added posFindZ(pos) func
- Added playCrimeReport(target, crimeId) func
- Added playAudioStream(url, pos, distance, usePos) func
- Added stopAudioStream() func
- Added setSkillLevel(skill, level) func
- Added removeAttachedObject(index) func
- Added attachedObjectSlotUsed(index) func
- Added editAttachedObject(index) func
- Added setChatBubble(text, color, drawDistance, expireTime) func
- Added setCheckpoint(size, pos) func
- Added disableCheckpoint() func
- Added setRaceCheckpoint(type, pos, nextPos, size) func
- Added disableRaceCheckpoint() func
- Added setMapIcon(iconid, pos, markerType, color, style) func
- Added removeMapIcon(iconid) func
- Added attachCameraToObject(objectid) func
- Added interpolateCameraPos(from, to, time, cut) func
- Added interpolateCameraLookAt(from, to, time, cut) func
- Added startRecordingData(recordType, recordName) func
- Added stopRecordingData() func
- Added selectTextdraw(color) func
- Added cancelSelectTextdraw() func
- Added createExplosion(pos, type, radius) func
- Added getNetworkStats() func
- Added showMenu(menuId) func
- Added hideMenu(menuId) func
- Added gangZoneShow(zone, color) func
- Added gangZoneHide(zone, color) func
- Added gangZoneFlash(zone, color) func
- Added gangZoneStopFlash(zone) func
- Added attach3DTextLabel(label, pos) func
- Added delete3DTextLabel(label) func
- Added update3DTextLabel(label, color, text) func
- Added showDialog(dialogid, style, caption, info, button1, button2) func
- Added setVehicleParams(vehicleid, objective, doorsLocked) func
- Added shopName setter
- Added controllable setter
- Added disableRemoteVehicleCollisions setter
- Added enableCameraTarget setter
- Added stuntBonus setter
- Added cameraTargetObject getter
- Added cameraTargetVehicle getter
- Added cameraTargetPlayer getter
- Added cameraTargetActor getter
- Added cameraMode getter
- Added targetActor getter
- Added ping getter
- Added surfingObjectID getter
- Added isInCheckpoint getter
- Added isInRaceCheckpoint getter
- Added animationIndex getter
- Added version getter
- Added netStats_ConnectedTime getter
- Added netStats_MessagesReceived getter
- Added netStats_BytesReceived getter
- Added netStats_MessagesSent getter
- Added netStats_BytesSent getter
- Added netStats_MessagesRecvPerSecond getter
- Added netStats_ConnectionStatus getter
- Added netStats_GetIpPort getter
- Added drunkLevel setter/getter
- Added time setter/getter
- Added fightingStyle setter/getter
- Added worldBounds setter/getter

***Server***
- Added gameText func
- Added disableInteriorEnterExits func
- Added enableVehicleFriendlyFire func
- Added usePlayerPedAnims func

***FileSystem***
Fixed issue with $fs.read reading data incorrectly

***streamer.inc.js***
- Added array support
- Fixed various issues

***Examples***
- Converted grandlarc gamemode to JavaScript https://github.com/damospiderman/samp.js/tree/master/examples/grandlarc
__________________
!damo!spiderman is offline   Reply With Quote
Old 01/08/2015, 11:08 AM   #76
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Ok after that last release we discovered so fairly major bugs so update to avoid drama. We've also added a new global event feature allow you to emit global events to other scripts

Usage:
PHP Code:
$server.emit('myevent'var1,var2,var3);

// Another script
$server.on('myevent', function(var1,var2,var3){

}); 
Update v0.1.9.6
Code:
Major Bug Fixes
- Strings were not being cast properly in CallNativeGDK causing some strings to duplicate randomly at times and functions not to work correctly
- Invalid player objects were being undefined rather than being a player object
- Returns from callbacks/events weren't being registered properly
- sampdb functions weren't converted properly and returned null values

Additions
- Global events. These events allow you to fire an event which gets fired in all scripts. Usage example: 
````
$server.emit('myevent', var1, var2, var3 );

// Another script
$server.on('myevent', function(var1, var2, var3 ){

});
````
__________________
!damo!spiderman is offline   Reply With Quote
Old 02/08/2015, 08:15 AM   #77
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Ok there were a few minor issues reported from that last release so I've just pushed a new dll haven't done a full release.

Issue 1: ScriptInit wasn't being called on loadjs/reloadjs
Issue 2: Script load order was alphabetical

If either of those things affect you then download the new dll here https://github.com/damospiderman/sam...in/samp.js.dll
__________________
!damo!spiderman is offline   Reply With Quote
Old 02/08/2015, 08:30 PM   #78
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
Ok there were a few minor issues reported from that last release so I've just pushed a new dll haven't done a full release.

Issue 1: ScriptInit wasn't being called on loadjs/reloadjs
Issue 2: Script load order was alphabetical

If either of those things affect you then download the new dll here https://github.com/damospiderman/sam...in/samp.js.dll
Just gonna put it out there for a better workflow:

It's bad practice to put compiled binaries in your repository. The binaries change completely with every build meaning the size of the repository will grow massively with each recompile. Git is generally meant for version management of source code. It's a best to remove the binaries from the repository and add it to your .gitignore file. Instead, you should provide these binaries in all your (pre-)releases instead. Aside from keeping the size of your repository smaller (as it doesn't have to store every single version in history of the binaries) it will also keep your commits cleaner as you will only be commiting the actual change (in code) and not the recompiled binaries.

If you are worried that people should be able to get the binaries of the latest commit without having to compile them theirselves, you can setup a build script with appveyor. If you configure it properly it will save an artifact (a build result/DLL) of every commit (sampgdk does this too: https://ci.appveyor.com/project/Zeex/sampgdk/ )
__________________
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 04/08/2015, 08:22 AM   #79
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 244
Reputation: 160
Default Re: samp.js - JavaScript for SA-MP

Thanks for the suggestion
__________________
!damo!spiderman is offline   Reply With Quote
Old 04/08/2015, 09:48 AM   #80
Laronic
Huge Clucker
 
Laronic's Avatar
 
Join Date: Mar 2011
Posts: 412
Reputation: 57
Default Re: samp.js - JavaScript for SA-MP

Command handler and example usages has been added and can be viewed here for whoever is interested
Laronic 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 08:16 AM.


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