Jump to content

laserlaser

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by laserlaser

  1. Delete first version at least. There is no change in resource but I deleted my copyright. DONE It would be nice if you re-added the description text
  2. "please delete" in description https://community.mtasa.com/index.php?p=resources&s=details&id=7770 ANSWER: this is your resource.. what exactly is it meant for (as you deleted the description)? Per the community regulations, we tend not to/can refuse to delete useful, popular or old resources. You usually release useful and popular resources.
  3. I thinked on it very long time ago.But I decided to not go to do. Because It can't include client scripts. But It is great for someone who want to make only server-side scripts.So great job bro.
  4. Hi everyone, I just make a ModLoader for ModLoading in game and make a sample for SDT_GUI(a.k.a dxGUI). Here is the video: Google Drive Download You should edit 'mods_server.xml' to add new mods.
  5. Project name changed to SDT_GUI. v1.4.4 comes with too much new things.
  6. I think you should just read the my first message. It says: 'I have edit Aibo's DrawColorText 1.5 years ago.'
  7. It's old project And 'colorCoded: Set to true to enable embedded #FFFFFF color codes. Note: clip and wordBreak are forced false if this is set.' I want to use colored text with 'clip' property.
  8. V.1.4.3 COMES ! 11 new beautiful theme added...
  9. Hi, I have edit Aibo's DrawColorText 1.5 years ago. function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY,clip,wordBreak,postGUI) --local maxWidth = bx-ax local strAdded = 0 if str:sub(1,1) ~= " " then str = " "..str strAdded = 1 end if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 -- maxWidth = bx-ax elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w -- maxWidth = bx-ax end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local f = 1 local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) --if (w > maxWidth) then -- w = maxWidth --end --maxWidth = maxWidth-w if (f == 1) and strAdded == 1 then cap = cap:sub(2) f = f+1 end if not clip then clip = false end if not wordBreak then wordBreak = false end if not postGUI then postGUI = false end dxDrawText(cap, ax, ay, ax+w, by, color, scale, font,"left","top",clip,wordBreak,postGUI) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) --if (w > maxWidth) then -- w = maxWidth --end --maxWidth = maxWidth-w if not clip then clip = false end if not wordBreak then wordBreak = false end if not postGUI then postGUI = false end if ( f == 1) and strAdded==1 then cap = cap:sub(2) end f = f+1 dxDrawText(cap, ax, ay, ax+w, by, color, scale, font,"left","top",clip,wordBreak,postGUI) end end I noticed now, It doesn't work OMFG! Where is the problem?
  10. I think you are using v1.4.1, and you cant call the theme like "Subaru" you should use 'dxGetTheme' function.Like 'dxGetTheme("Subaru")' I wrote it in the first message, Edit is not a component now.It's just a template, not a drawable component for now.You can create normal gui edit and attach it to the dxGUI window. x_wnd=dxCreateWindow(...) y_edt=guiCreateEdit(...) guiAttachToDirectX(x_wnd, y_edt, y_edt_x_position_on_the_dx_window, y_edt_y_position_on_the_dx_window) You can use it like that in 1.4.3 I will develop 'Attaching' function and It will be better than 1.4.2
  11. I have to left from MTA last summer. But I will back this summer. I will develop this resource again and improve the wiki page.
  12. http://community.mtasa.com/index.php?p= ... ls&id=4871 I think you can do it with that.
  13. Because you're using socket plugin on the wiki.But I didn't use it.I used viewtopic.php?f=108&t=46338 this one.
  14. Oh I looked a if block only, not element == true
  15. change with function seatbelton( player ) local check = getPedOccupiedVehicle ( player ) if ( check == true ) then setElementData( player, "seatbelt",true) exports.global:sendLocalMeAction(player, "puts their seatbelt on") elseif ( check == false ) then outputChatBox("You are not in a car!", player, 255,0,0 ) else setElementData( player, "seatbelt",false) exports.global:sendLocalMeAction(player, "takes their seatbelt off") end end addCommandHandler("seatbelt",seatbelton)
  16. I will add callJava tutorial...
  17. [Tutorial] JAVA SDK Hi everybody! Today, i will make a tutorial for this community... It's my gift This tutorial is to teach to you how use the JAVA SDK and what we can do with it. Summary What is Java What is the Java SDK What we can do with it How to install How to use How to use with callJava Download a demo What is the Java Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. I think that, those informations is enough... What is the Java SDK SDK mean Software Development Kit, it's a library allow to developpers to make his applications. Multiple platforms propose his SDK. Just search on Google Examples: Facebook SDK Have so much... Search on Google (Google have too his SDK) Download What we can do with it The JAVA SDK from MTA offer much possibility. You can do everything with it if you have a great imagination Examples ? Remote management (all controls, kick, ban, mute, chat, pm) Background timers (For no lag) Facebook abilities with Facebook SDK Twitter abilities with Twitter SDK More, more, more, more How to install Let's start ! First, you must: A MTA-Server A knowledge of java The resource JSDK ( They are all in JavaSDK.zip ) The library JAVA SDK Now we can start Unzip the file.And enter into folder.You will see 3 folders. Copy all files in "modules/" folder into "your/server/mods/deathmatch/modules". If this folder doesn't exist, create and copy... Copy all files in "resources/" folder into "your/server/mods/deathmatch/resources".And give admin rights to "jsdk" resource. Result: In "modules/" folder there are "ml_sockets.dll or ml_sockets.so". In "resources/" folder there are "jsdk" resource Now download and run the ide. I will use eclipse, there are too many alternatives.Netbeans, eclipse, JCreator .... Create a new java project. Select the project name on Package explorer.Click right, and select the properties. Go to "Java Build Path", Select "Libraries" tab. Click "Add external jars", Select "SDK/JavaSDK.jar" in your unzipped folder. Now we're ready to develop something.. Create a new java class.If public static void main(String[] args) { // TODO Auto-generated method stub } this line doesn't exists, add this lines. Write import com.mtasa.*; import com.mtasa.elements.*; import com.mtasa.functions.*; top of the class. The library is successfully imported to our class, now our library are installed How to use Go into main function..And create a new object type is MTA MTA object's constructor public MTA(String host="127.0.0.1", int port=22005, String username="",String password=""){ .... } Explain: The server ip you want to connect(Default 127.0.0.1) The server port you want to connect(Default 22005) The username you want to connect with(Default empty) The password you want to connect with(Default empty) IMPORTANT: The account must have a acl rights. <right name="general.ModifyOtherObjects" access="true"></right> <right name="general.http" access="true"></right> In admin rights they are both is true... I created the object try { MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); } catch (MTAException e) { e.printStackTrace(); } The object's constructor can throw the MTAException, so we must put it into try-catch block. Create a LuaArgs object... LuaArgs object's constructor public LuaArgs(MTA server){ .... } Explain: The server object you want to make call I created..And add the one parameter. Now my try block look like; MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); LuaArgs largs = new LuaArgs(mta); largs.add("Hello Mr.Green"); Now I can call the functions... LuaArgs MTA.callFunction(String funcName, LuaArgs args) Explain: The default MTA function you want to call (ex: outputChatBox, outputDebugString) The arguments to send function Returns: LuaArgs object, what function returned to we. LuaArgs MTA.call(String resourcename, String funcName, LuaArgs args) Explain: The resource name where are the function The function name, it must be exported and http is true...Like The arguments to send function Returns: LuaArgs object, what function returned to we. NOTICE: If you send the one argument, you can create it with MTA.luaArg(Object o) method. So, MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); LuaArgs largs = new LuaArgs(mta); largs.add("Hello Mr.Green"); is equals to MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); LuaArgs largs = mta.luaArg("Hello Mr.Green"); But I don't send one argument, I must create A LuaArgs object...I added many arguments to Largs. And I will make call to outputDebugString Now my try blog is: MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); LuaArgs largs = new LuaArgs(mta); largs.add("Hello Mr.Green"); largs.add(0); // Custom message largs.add(255); // R largs.add(0); // G largs.add(0); // B mta.callFunction("outputDebugString", largs); When program runs, in server-console outputs "Hello Mr.Green" We did it! But It's the hardest way You can do it easily.How? boolean MTA.out.outputDebugString(message, dlevel=3, r=0, g=0, b=0); Explain: The message you want to output Debug level, 0: Custom, 1:Error, 2:Warning, 3:Information, There are a constants.Ex: Output.LEVEL_WARNING, Output.LEVEL_ERROR The color codes (r,g,b) Returns: boolean Just one line ! Now my try block MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); mta.out.outputDebugString("Hello Mr.Green",Output.LEVEL_CUSTOM, 255,0,0); Just 2 lines ! How to use with callJava Now, we will use callJava function.First of all i will explain jsdk exported functions function callJava(int remote_clientid[,arg1,arg2,...]) Explain: remote_clientid It's the socket's id.It give information about SDK Connectors. Arguments function getSDKPort() Explain: Returns: Opened SDK port.JavaSDK will connect our server with this port function getConnections() Explain: Returns: Table, All SDK's remote_clientid function getSocket() Explain: Returns: Socket ID (Server) Events: onJavaClientConnect (int socket_id, string remote_clientip, int remote_clientid); -- Call when SDK connected to server onJavaClientDisconnect (int socket_id, int remote_clientid); -- Call when SDK disconnected from server Now we can start Ahhh lua part.So most boring part Create a new resource, if you don't know creating new resource, you can press 'X' button on your browser There are 2 files: server.lua, meta.xml.You know how to design meta.xml, so i don't write it here. Let's open the Notepad++ and begin writing.. function onplayerjoin() -- TODO: Auto generated method sub end addEventHandler("onPlayerJoin",getRootElement(), onplayerjoin) function onsdkjoin(remote_clientid) end addEventHandler("onJavaClientConnect",getRootElement(), onsdkjoin) This is a very simple lua file.2 event only.Now we send somethings with callJava.. IMPORTANT: If you use callJava, you should open TCP Port (If you don't changed, default is 2205) Let's write into onsdkjoin function onsdkjoin(remote_clientid) -- callJava( remote_clientid , args ) -- I teach that function's usingÉ callJava(remote_clientid,"pop","Welcome to our server"); -- Send "pop" and "Welcome to our server" messages.Why I send "pop"? Cuz, InputEvents receives all strings.So We should know the event or message to do it.. end Write into onplayerjoin function onplayerjoin() for _,remote_clientid in ipairs(exports.jsdk:getConnections()) do -- Put into for loop the connection table callJava(remote_clientid,"join",getPlayerName(source)); end end It's the simple code, when players connect it calls all sdk with 2 argument, first "join", second player name.. Let's complete My class's last state is: import com.mtasa.*; import com.mtasa.elements.*; import com.mtasa.functions.*; public class SDKTut { /** * @param args */ public static void main(String[] args) { try { MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); mta.out.outputDebugString("Hello Mr.Green",Output.LEVEL_CUSTOM, 255,0,0); } catch (MTAException e) { e.printStackTrace(); } } } Now i will add input events with mta.addInputEvent function.. mta.addInputEvent(new InputEvent() { @Override public void onAction(LuaArgs arguments, String input) throws MTAException { } }); Explain: arguments: argument list in callJava input: arguments json string. The first argument, I was send events.So I will check it with parseString Write into onAction: if (arguments.parseString(0).equals("pop")){ }else if(arguments.parseString(0).equals("join")){ } Now I'm knowing the input's event...If it's pop, I will show it with JOptionPane...If "join" event I will print the player name... if (arguments.parseString(0).equals("pop")){ JOptionPane.showMessageDialog(null, arguments.parseString(1)); }else if(arguments.parseString(0).equals("join")){ System.out.println("Player joined: "+arguments.parseString(1)); } We did it! But not finished.Last step! Connecting the socket.. try { mta.sockOpen(); } catch (UnknownHostException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } This function can throw UnkownHostExpcetion and IOException.Now I'm changing the my codes.. My codes(last state): try { MTA mta = new MTA("127.0.0.1", 22005, "admin", "12345"); mta.out.outputDebugString("Hello Mr.Green",Output.LEVEL_CUSTOM, 255,0,0); mta.addInputEvent(new InputEvent() { @Override public void onAction(LuaArgs arguments, String input) throws MTAException { if (arguments.parseString(0).equals("pop")){ JOptionPane.showMessageDialog(null, arguments.parseString(1)); }else if(arguments.parseString(0).equals("join")){ System.out.println("Player joined: "+arguments.parseString(1)); } } }); mta.sockOpen(); } catch (MTAException e) { e.printStackTrace(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } TO BE CONTINUED...
  18. 0.2 comes, callJava and socket module changed.Now programs is client, server is server But you should open port : 2205 TCP or if you changed PORT, open it. If you don't use callJava in your programs, don't need to open port. p.s: in vps, it will automatically opened.
  19. Module:Sockets I proudly present you ml_sockets a c++ extension for mta 1.0, it was made by BlueG for SAMP and translated to MTA by me. The module adds socket functions & events to mta, sockets are used for communication between computers. See wikipedia for more info: http://en.wikipedia.org/wiki/Internet_socket Installation: - download ml_sockets (https://rapidshare.com/files/2826542902/ml_sockets.zip) - unzip - place ml_sockets in (..server\mods\deathmatch\modules) - add the module to your mtaserver.conf ( or for linux) - restart the server or write to console "loadmodule ml_sockets(.dll,.so)" Functions: int socket_create(int protocolType); -- udp & tcp , 1:TCP, 2:UDP -> Returns socket_id bool socket_bind(int socket_id, string ip); -- udp & tcp bool socket_connect(int socket_id, string host, int port); -- udp & tcp bool socket_listen(int socket_id, int port); -- udp & tcp bool socket_stop_listen(int socket_id); -- udp & tcp bool socket_destroy(int socket_id); -- udp & tcp bool socket_send(int socket_id, string data, int len); -- udp & tcp bool is_socket_valid(int socket_id); -- udp & tcp bool socket_set_max_connections(int socket_id, int max_remote_clients); -- tcp only bool socket_close_remote_client(int socket_id, int remote_clientid); -- tcp only bool socket_sendto_remote_client(int socket_id, int remote_clientid, string data); -- tcp only bool socket_remote_client_connected(int socket_id, int remote_clientid); -- tcp only string get_remote_client_ip(int socket_id, int remote_clientid); -- tcp only Events: -- client & server (udp) onUDPReceiveData(int socket_id, string data, data_len, string remote_client_ip, int remote_client_port); -- client only (tcp) onSocketAnswer(int socket_id, string data, int data_len); -- called when socket_connect() has been used and the server sends data onSocketClose(int socket_id); -- server only (tcp) onSocketReceiveData(int socket_id, int remote_clientid, string data, int data_len); -- called when a remote client sends data onSocketRemoteConnect(int socket_id, string remote_client, int remote_clientid); -- called when a remote client connects to our socket server onSocketRemoteDisconnect(int socket_id, int remote_clientid); -- called when a remote client disconnects from our socket server Both of all events source always N/A Tutorials will be added soon. I will be include this to my javaSDK for callJava
  20. Files(Lua Encryptor, File Downloader, Example): http://www.solidfiles.com/d/fe1d922802/
×
×
  • Create New...