SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/07/2015, 08:18 PM   #21
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,413
Reputation: 403
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by GWMPT View Post
When you restart a script, you don't really need to call OnPlayerConnect, or OnPlayerDisconnect
Anyways, if it's needed, you can fake these calls.
After all, they are only callbacks.
I am not really specifically talking about those callbacks, but you can't directly restart a gamemode with the player staying spawned as you can start / stop etc resources while the player keeps the same onfoot data as you can in MTA.
Abagail is offline   Reply With Quote
Old 02/07/2015, 08:21 PM   #22
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,048
Reputation: 286
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by Abagail View Post
I am not really specifically talking about those callbacks, but you can't directly restart a gamemode with the player staying spawned as you can start / stop etc resources while the player keeps the same onfoot data as you can in MTA.
No.
In this case, He only needs to restart the javascript scripts, and fake the callbacks.
The "Gamemode" itself doesn't reloads or restarts.
GWMPT is offline   Reply With Quote
Old 02/07/2015, 11:09 PM   #23
KingHual
High-roller
 
KingHual's Avatar
 
Join Date: Jun 2010
Location: Bulgaria
Posts: 2,432
Reputation: 1303
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by Abagail View Post
The players have to reconnect to restart the gamemode to my knowledge(when the server gmx'es they still reconnect ).
You're forgetting the gamemode isn't a thing here. It's only used as a medium for the JS scripts.
__________________
KingHual is offline   Reply With Quote
Old 02/07/2015, 11:47 PM   #24
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 468
Reputation: 147
Default Re: samp.js - JavaScript for SA-MP

There's a few rcon commands you can use: loadjs, unloadjs and reloadjs or their JavaScript counterparts load() unload() and reload(). You can easily reload scripts without starting gamemodes.

I will be adding a watch function to the FileSystem class do you could easily have it automatically reload on change.

You could also use eval(its evil ) I've done it to teat things even added it in an irc bot and executed commands from irc.
__________________
!damo!spiderman is offline   Reply With Quote
Old 03/07/2015, 12:31 AM   #25
!damo!spiderman
Huge Clucker
 
!damo!spiderman's Avatar
 
Join Date: Oct 2006
Posts: 468
Reputation: 147
Default Re: samp.js - JavaScript for SA-MP

Example of the various ways you can use the async MySQL class

PHP Code:
var conn $mysql.createConnection("127.0.0.1""username""password""database");

conn.connect(function(err){
    if(
err) return print(err);

    print(
"Connected Successfully");

    
let name "damo";
    
let info "samp.js dev"
    
    
let fullinfo = { namenameinfoinfo };
    
    
conn.query("INSERT INTO `table` ( `name`, `info` ) VALUES('"+name+"', '"+info+"'", function( errresult ){
        
// Query = INSERT INTO `table` ( `name`, `info` ) VALUES ( 'damo', 'samp.js dev' )
        
if(err) return print(err);
        
        print(
"Row Inserted: "+result.insertId);
    });
    
    
conn.query("INSERT INTO `table` ( `name`, `info` ) VALUES( ?, ? )", [ nameinfo ], function(errresult){
        
// Query = INSERT INTO `table` ( `name`, `info` ) VALUES ( 'damo', 'samp.js dev' )
        
print("Affected: "+result.affectedRows );
    });
    
    
conn.query("INSERT INTO `table` SET ?"fullinfo, function(errresult){
        
// Query = INSERT INTO `table` SET  name = 'damo', info = 'samp.js dev' 
    
});
    
    
    
let userarr = [];
    
    
userarr.push([ 'ev0lution''Tester' ]);
    
userarr.push( [ 'damo''samp.js dev' ]);
                  
    
conn.query("INSERT INTO `table` ( `name`, `info` ) VALUES ?", [ userarr ], function(errresult ){
        
// Query = INSERT INTO `table` ( `name`, `info` ) VALUES ( 'ev0lution','Tester' ), ( 'damo', 'samp.js dev' )
    
});
    
    
    
conn.query("SELECT * FROM `table`", function(errrowsfields){
        if(
err) return print(err);
        
        print(
rows);
        
/*
            [
                { id:0, name: "ev0lution", info: "Tester" },
                { id:1, name: "damo", info: "samp.js dev" }
            ]
        */
        
        
for(var row of rows){
            print(`
Name: ${row.name}, Info: ${row.info}`);    
        }
        
        print(
fields);
        
        
/*
            [
                "id",
                "name",
                "info"
            ]
        */
    
});
    
}); 
__________________
!damo!spiderman is offline   Reply With Quote
Old 03/07/2015, 12:36 AM   #26
ikkentim
High-roller
 
ikkentim's Avatar
 
Join Date: Jan 2010
Location: Kampen, The Netherlands
Posts: 1,077
Reputation: 188
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by Abagail View Post
I am not really specifically talking about those callbacks, but you can't directly restart a gamemode with the player staying spawned as you can start / stop etc resources while the player keeps the same onfoot data as you can in MTA.
As long as you reload the game mode logic and keep the player states/any other data you have live scripting w/o having players reconnect.
__________________
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 Go0gle Maps! | Topic Github Sample
ikkentim is offline   Reply With Quote
Old 03/07/2015, 12:43 AM   #27
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 868
Reputation: 47
Default Re: samp.js - JavaScript for SA-MP

Thank you for this amazing plugin, best and most useful plugin so far
__________________
Quote:
Originally Posted by ThaiLuan View Post
Code:
C:\Users\Administrator\Downloads\Viet-RP\gamemodes\3mien.pwn(112016) : fatal error 101: cannot write to file: "disk full"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Help me! How to fix error
CoaPsyFactor is offline   Reply With Quote
Old 03/07/2015, 12:49 AM   #28
ev0lution
Gangsta
 
ev0lution's Avatar
 
Join Date: Jul 2009
Posts: 700
Reputation: 373
Default Re: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by Abagail View Post
The players have to reconnect to restart the gamemode to my knowledge(when the server gmx'es they still reconnect ).
This is even possible in pawn. Just write your gamemode as a filterscript instead.
__________________
ev0lution is offline   Reply With Quote
Old 03/07/2015, 05:10 AM   #29
FSAOskar
Big Clucker
 
Join Date: Feb 2015
Location: Germany
Posts: 94
Reputation: 22
Default AW: samp.js - JavaScript for SA-MP

Quote:
Originally Posted by !damo!spiderman View Post
There's a few rcon commands you can use: loadjs, unloadjs and reloadjs or their JavaScript counterparts load() unload() and reload(). You can easily reload scripts without starting gamemodes.

I will be adding a watch function to the FileSystem class do you could easily have it automatically reload on change.

You could also use eval(its evil ) I've done it to teat things even added it in an irc bot and executed commands from irc.
Great, thanks !
FSAOskar is offline   Reply With Quote
Old 03/07/2015, 05:36 AM   #30
Lynn
High-roller
 
Lynn's Avatar
 
Join Date: Jan 2010
Location: Detroit, Michigan USA
Posts: 1,121
Reputation: 108
Default Re: samp.js - JavaScript for SA-MP

Wow, impressive. Very nice work.
Lynn 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
[Pedido] JavaScript e C++ RiqueP Português/Portuguese 6 27/04/2014 09:50 AM
javascript samp:// [Ger]Little_Grandpa Help Archive 6 21/08/2010 06:24 PM


All times are GMT. The time now is 11:46 PM.


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