Jump to content

How To Save Teams?


vXHazE

Recommended Posts

Alright. Go to server > mods > deathmatch > resources. In there, create a new folder called 'teams'. Go into that folder and create a file called script.lua. Paste this code into it, then save it:

createTeam("Team name", 200, 50, 0) --Those are the RGB colours. 

Create another file called meta.xml. Paste this into it, then save it (in the same folder):

<meta> 
<script src="script.lua" type="server"/> 
</meta> 

Now, when you start your server, you should have a resource called 'teams'. Write /start teams into the chatbox, and watch your resource start.

Link to comment

i made a folder called teams then I made the the notepad called script.lua and put in what you told me to i changed the color and the name of the team then i made a notepad called meta.xml and copied and pasted the stuff you told me to than I went to mtaserver and at the bottom I added it to the start up thing and it doesn't work for some reason also toffbrown i'am not sure how to make the script you sent me sorry for my noobizm :(

Link to comment

https://community.multitheftauto.com/index.php?p=resources&s=details&id=9064

Here i uploaded it and don't fret we are always learning,

now

function team () ----- this is the start of your function 
createTeam ( "vXHazE", 255, 0, 0 )--- this is the function that happends the " " is the team name in tab and 255, 0, 0 is the RGB color coding so RGB = Red,Green,Blue and you said red so the colour will be 255 
end------ this ends the function 
addEventHandler("onResourceStart", resourceRoot, team)---- this is what causes the function do execute the functions basically so onResourceStart runs the function when this resource starts 

EDIT idk why but my Lua isnt working on here

Link to comment
i made a folder called teams then I made the the notepad called script.lua and put in what you told me to i changed the color and the name of the team then i made a notepad called meta.xml and copied and pasted the stuff you told me to than I went to mtaserver and at the bottom I added it to the start up thing and it doesn't work for some reason also toffbrown i'am not sure how to make the script you sent me sorry for my noobizm :(

First, make a folder and name it whatever you want then do the following

1.)create a text file in the folder, open it, save as a .lua file in the folder you created.Name your lua file when saving, exmaple team.lua but i'd suggest server.lua

2.)create a text file, save it as meta.xml. Make sure it's meta.xml.

3.)Then open your .lua file and enter the following -

function aTeam () 
 Admin = createTeam ( "Admins", 255,255,255 ) 
end 
addEventHandler("onResourceStart", resourceRoot, aTeam) 
  

Change the "Admins" to any Team name that you want and change the 255,255,255 to change the team color.

4.)enter your .xml and type in the following

  
<meta> 
     <info author="YourName" type="script" description="Your description" /> 
     <script src="server.lua" /> 
</meta> 

5.)Make sure you saved' both files

6.)Copy the folder you created for the script and paste it here -->mods/deathmatch/resources/gameplay

and paste it there.

7.)Turn on your server and enable the script.

I'm a new scripter as well, just trying to help, it's how i do scripts, steps might be long but it should work hopefully, good luck!.

Link to comment

With your script you don't need Admin = createTeam and also 255, 255, 255 is white he wanted red

Please follow or use what i posted because what i wrote was correct, also add open up your mtaserver.conf

and go all the way down to the bottom and paste

or change it to what folder you used for the script

Link to comment

If you are going to have multiple teams, easiest way would probably be:

local teams = { 
    -- "team", r, g, b 
    {"Red Team",255,0,0}, 
    {"Blue Team",0,0,255}, 
} 
  
function team () 
    for i,v in ipairs(teams) do 
        createTeam (v[1], v[2], v[3], v[4] ) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, team) 

Link to comment

Add this to the original Script

function savTeam() 
local account = getPlayerAccount(source) 
local team = getAccountData (account, "team")  
if (team) and getTeamFromName(team) then 
      setPlayerTeam(source, getTeamFromName( team )) 
     end 
end 
addEventHandler("onPlayerLogin",root,savTeam) 
  
function update() 
 local team = getPlayerTeam(source) 
local account = getPlayerAccount(source) 
if (team) and not isGuestAccount(account) then 
setAccountData(account, "team", getTeamName( team )) 
 end 
    end 
addEventHandler("onPlayerQuit", getRootElement(), update)  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...