zzx Posted March 18, 2014 Share Posted March 18, 2014 Yo guys, In this tutorial i'm gonna teach you guys how to create a simple script for beginners, so let's start. 1) You have to open a file in C:\Program Files\MTA San Andreas 1.3\server\mods\deathmatch\resources, and then create in it a meta.xml and then create server.lua (optional) where we will build our script. 2) Open meta.xml and copy these lines: "YourName" type="gamemode" name="My Server" description="My first MTA server" version="1.0.0" /> and paste them in the meta file you have created. (these lines will define your script). 3) Open the server.lua (Lua) file. 4) function playerCount ( ) Add this line to the 1st line in Lua file, by the way, this function gives you the players count in the server. 5) function playerCount ( ) outputChatBox("#ff8800[server]: #ffffffPlayers: #ffffff(" .. getPlayerCount() .. "#ffffff)" , root, 255, 0, 0, true) These lines show you players count in the server's chat with a colored words. for example: [server]: Players: (12). 6) addEventHandler ( "onPlayerJoin", getRootElement(), playerCount ) addEventHandler ( "onPlayerQuit", getRootElement(), playerCount ) When a player joins the server he will be counted in the server counter and the counter gives you the entire players number. and the same happen when the player leaves the server. Example: [server]: Players: (12 [When he joins]). [server]: Players: (11 [When he leaves]). 7) Here is the entire code: function playerCount ( ) outputChatBox("#ff8800[server]: #ffffffPlayers: #ffffff(" .. getPlayerCount() .. "#ffffff)" , root, 255, 0, 0, true) end addEventHandler ( "onPlayerJoin", getRootElement(), playerCount ) addEventHandler ( "onPlayerQuit", getRootElement(), playerCount ) If you want any help, you can send me a PM. Peace, Zeldak. Link to comment
abu5lf Posted March 18, 2014 Share Posted March 18, 2014 2) Open meta.xml and copy these lines: "YourName" type="gamemode" name="My Server" description="My first MTA server" version="1.0.0" /> type="gamemode" ._. Read more: Meta.xml Link to comment
cheez3d Posted March 18, 2014 Share Posted March 18, 2014 You are telling them to create a script called server.lua but the meta.xml has script.lua. Modify that . Link to comment
JR10 Posted March 18, 2014 Share Posted March 18, 2014 I appreciate the fact that you've tried and posted this tutorial, but, the wiki teaches you the exact same thing. This section needs tutorials that doesn't already exist. But of course, this is only my opinion. Link to comment
Noki Posted March 19, 2014 Share Posted March 19, 2014 You have the chatbox item outputting to root (all element's everywhere). You should replace it with 'source', so the responsible element (the player that joined) will see it. Chat box spam never look nice. Link to comment
Arnold-1 Posted March 23, 2014 Share Posted March 23, 2014 You have the chatbox item outputting to root (all element's everywhere). You should replace it with 'source', so the responsible element (the player that joined) will see it. Chat box spam never look nice. well he used onPlayerQuit that means he wanted it to show it to everyone, didn't he? Link to comment
Om. Posted November 28, 2015 Share Posted November 28, 2015 eh, that'll just output [server] isn't it? and it's server sided so ehm, #getElementsByType('player') (Client-Sided) will also work Link to comment
Recommended Posts