SA-MP Forums Archive
[Plugin] Lua in SAMP (alpha) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] Lua in SAMP (alpha) (/showthread.php?tid=369919)

Pages: 1 2


Lua in SAMP (alpha) - Rancho - 18.08.2012


Lua in SAMP
Introduction

This plugin, as the name suggests, makes possible the use of Lua in SA:MP Servers, which is known by its easy syntax and the various possibilities to do incredible things on it.

So, how can i create plugin for lua? It's easy to do.Download "l_base" Plugin Development Kit.And write your own plugin:
Pre-coming plugins: ml_mysql 5.0 <transported from MTA-MYSQL> (Not pre-comes on Linux)


Kalcor and I do not recommend the use of this plugin for public servers, this is just an experiment.

Requirements
Speed

In strings 5x faster, In booleans 22x faster than pawn.

Changes from Pawn
Setting up
In README.txt (Open with Notepad++)

This project is now private for some reasons.I can put it when it come fully.(may be)


I will add LUA lessons to Tutorials category.


Re: Lua in SAMP (alpha) - xSiiLenTx - 18.08.2012

Yay When I was a little bit younger, i scripted for "roblox" :P Lua is my favorite, ty!


Re: Lua in SAMP (alpha) - ipsBruno - 18.08.2012

Good working man !!

Downloading ..


Re: Lua in SAMP (alpha) - RanSEE - 18.08.2012

Great Job, looking forward to this.


Re: Lua in SAMP (alpha) - davve95 - 18.08.2012

Good job!


Re: Lua in SAMP (alpha) - MegadreamsBE - 18.08.2012

Are you serious? I was nearly finishing my LUA plugin... damn Though mine is able to work perfectly together with pawn and could really be used as a second language so i still gonna finish it.


Re: Lua in SAMP (alpha) - [DOG]irinel1996 - 18.08.2012

Nice plugin, are there any advantages using this?

I guess it's a good way to script if you don't know PAWN, and you know LUA.


Re: Lua in SAMP (alpha) - MegadreamsBE - 18.08.2012

As far as im able to see is this one a bit slow so currently i won't use it to much. Though it's a good job and we'll we gonna be concurrents i guess since im one of these days releasing my version. :3


Re: Lua in SAMP (alpha) - Rancho - 18.08.2012

Quote:
Originally Posted by irinel1996
Посмотреть сообщение
Nice plugin, are there any advantages using this?

I guess it's a good way to script if you don't know PAWN, and you know LUA.
Yes, Pawn has static allocated arrays & strings.Lua has dynamic allocated arrays&strings

You can add commands with event handlers or addCommandHandler like;

Код:
function myCmd(playerid, cmdName, number1, number2, ...)
print('Number 1 ',number1);
print('Number 2:' .. number2);
print(...);
end
addCommandHandler('cmd',myCmd);
You can add multiple event handlers, you can make custom events, addEvent and call it with triggerEvent..

Has Thread's.
Has auto-include system. etc...

For example
Код:
local VehicleNames = {
    "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus",
    "Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr Whoopee","BF Injection",
    "Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie",
    "Stallion","Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder",
    "Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider",
    "Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina",
    "Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood",
    "Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa","RC Goblin","Hotring Racer A","Hotring Racer B",
    "Bloodring Banger","Rancher","Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain",
    "Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck",
    "Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent","Bullet","Clover",
    "Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A",
    "Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer",
    "Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
    "Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
    "Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
    "Stair Trailer","Boxville","Farm Plow","Utility Trailer"
};
function iFunc(pid, cmd)
	local named = ""
	for k,v in ipairs(VehicleNames) do
		if ( named=="" ) then
			named = v
		else
			named = named.."\n"..v
		end
	end
	showPlayerDialog(playerid, 9122, DIALOG_STYLE_LIST, "Select a Car",named,"Select","Cancel");
end
addCommandHandler('vehicles',iFunc);
This allows to all vehicles in one dialog only..Tested, it works..


Quote:
Originally Posted by MegadreamsBE
Посмотреть сообщение
As far as im able to see is this one a bit slow so currently i won't use it to much. Though it's a good job and we'll we gonna be concurrents i guess since im one of these days releasing my version. :3
Yes, I said on the topic :W I'm trying to optimize it.But I don't know where is the problem.May be in AmxUtils.cpp, I should use Invoke? I'm solving speed problems with threads now.

@I saw your project in ******-code.But there was a just main.cpp :W


Re: Lua in SAMP (alpha) - MegadreamsBE - 18.08.2012

True, i only created the project yet. Though im using the samp GDK which is slightly faster but doesn't allow logprintf.
P.S: The source will get uploaded after the release, didn't do it yet so people couldn't steal my code.


Re: Lua in SAMP (alpha) - Baboon - 18.08.2012

If I am right, Lua is also used for MTA scripting right?

Well seems cool that many people try to convert pawn to a different scripting language and the same way around.
really interesting.


Re: Lua in SAMP (alpha) - MegadreamsBE - 18.08.2012

Yes it's also used by MTA. Btw interesting that you allow users to create plugins just for this plugin. Im experimenting with an method to call plugin natives through an include in pawn so people are able to use every sa-mp plugin in LUA. If that works out you can use it to if you want Rancho.


Re: Lua in SAMP (alpha) - Rancho - 18.08.2012

Quote:
Originally Posted by MegadreamsBE
Посмотреть сообщение
Yes it's also used by MTA. Btw interesting that you allow users to create plugins just for this plugin. Im experimenting with an method to call plugin natives through an include in pawn so people are able to use every sa-mp plugin in LUA. If that works out you can use it to if you want Rancho.
I allow creating plugins.Because I can't make every functions.
I have few english :P I can't understand you but this plugin contains all 0.3e nativIIes.


Re: Lua in SAMP (alpha) - Rancho - 18.08.2012

I solved some speed problems.Now I'm fixing its...


Re: Lua in SAMP (alpha) - Arca - 18.08.2012

Is there a way to call custom native function from PAWN file?


Re: Lua in SAMP (alpha) - TheArcher - 18.08.2012

I read almost all the replies about LUA used by MTA. I'm pretty sure that it's also used mostly for new mods and source engine (CSS, GarrysMod etc...).

@Arca What do you mean? A native function can be called from .myfile file format. I think the natives must be implemented in the plugin and compiled to be executed.


Re: Lua in SAMP (alpha) - Arca - 18.08.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
I read almost all the replies about LUA used by MTA. I'm pretty sure that it's also used mostly for new mods and source engine (CSS, GarrysMod etc...).

@Arca What do you mean? A native function can be called from .myfile file format. I think the natives must be implemented in the plugin and compiled to be executed.
This

Quote:
Originally Posted by Arca
Посмотреть сообщение
A suggestion:

Can you add Native Function Requester?

For Example:
pawn Код:
NativeFunctionRequestor.RequestFunction("SendClientMessage", playerid, -1, @"I love {00FF00} Lua!"); // Requesting the function which is SendClientMessage with it's specific parameters



Re: Lua in SAMP (alpha) - Rancho - 18.08.2012

Quote:
Originally Posted by Arca
Посмотреть сообщение
This
Why you need this? I added all natives..

Just write
sendClientMessage(playerid, -1, "I love Lua");


Re: Lua in SAMP (alpha) - Arca - 18.08.2012

Quote:
Originally Posted by Rancho
Посмотреть сообщение
Why you need this? I added all natives..

Just write
sendClientMessage(playerid, -1, "I love Lua");
I need that for my custom native functions.


Re: Lua in SAMP (alpha) - Rancho - 18.08.2012

Quote:
Originally Posted by Arca
Посмотреть сообщение
I need that for my custom native functions.
in ******-Code page, Download AmxUtils/*.cpp,*.h Add your native's information to PawnNative.h

and call it with;

AmxUtils * utils;
utils->callNative( MyNative, "blah string");