Coder Social home page Coder Social logo

peterszombati / samp-node-lib Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 5.0 235 KB

NodeJS library for Scripting San Andreas Multiplayer:SAMP depends on samp-node plugin

License: MIT License

TypeScript 97.39% JavaScript 2.61%
samp san-andreas-multiplayer pawn nodejs gta gta-samp gta-san-andreas gta-sa library sa-mp

samp-node-lib's Introduction

samp-node-lib

NodeJS library for Scripting San Andreas Multiplayer : SAMP depends on samp-node plugin

some part of source code was auto generated with NodeJS

Getting started

Step 0 install samp-node

Step 1 install samp-node-lib via npm

npm i samp-node-lib

Example usage

import {
    ManualVehicleEngineAndLights,
    OnGameModeInit,
    OnPlayerCommandText
} from "samp-node-lib";

OnGameModeInit(() => {
    ManualVehicleEngineAndLights();
});

//

OnPlayerCommandText((player, cmdtext) => {
    player.SendClientMessage('rgba(255,0,0,1)', cmdtext)
});

Example using for gates

import {
    DynamicObject,
    OnGameModeInit,
    OnPlayerCommandText
} from "samp-node-lib";


let o1: DynamicObject;
let o2: DynamicObject;

OnGameModeInit(() => {
    o1 = new DynamicObject(3049, 808.012, 842.4, 10.9, 0.0, 0.0, 293.198)
        .setOpen(806.29, 846.4, 10.9, 0.0, 0.0, 293.2);
    o2 = new DynamicObject(3050, 808, 842.4, 10.9, 0.0, 0.0, 114.988)
        .setOpen(809.5, 839.2, 10.9, 0.0, 0.0, 114.99);
});

OnPlayerCommandText((player, cmdtext) => {
    if (cmdtext === '/open') {
        o1.open();
        o2.open();
        return 1;
    }
    if (cmdtext === '/close') {
        o1.close();
        o2.close();
        return 1;
    }
});

samp-node-lib's People

Contributors

cactysman avatar danjdewhurst avatar peterszombati avatar peterszombati-bvtech-io avatar rsetiawan7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

samp-node-lib's Issues

Doesn't work if imported with ES6 style

My script not loaded properly if I use ES6 import style instead of CommonJS.

index.js

import { OnGameModeInit } from 'samp-node-lib';

OnGameModeInit(() => console.log('Gamemode loaded from root index.js'));

But if you do:

const { OnGameModeInit } = require('samp-node-lib');

OnGameModeInit(() => console.log('Gamemode loaded from root index.js'));

It would loaded correctly.

player.GetPlayerName() returns undefined

Hello, i tested OnPlayerConnect function

sampNodeLib.OnPlayerConnect((player) => {
    console.log(`[Node] Player ${player.playerid} connected`);

    console.log(player.GetPlayerName())
})

In result i got:
[Node] Player 0 connected
undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.