Jump to content

ShayF

Members
  • Posts

    43
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by ShayF

  1. 1 minute ago, Bean666 said:

    thank you i couldnt ask for more, but yes im using this for my project, whats the difference if i'll use mySQL tho?

    The only reason id personally use mysql is to get the data to a different server/website, so unless you're gonna do that then json should work just fine for ya.

  2. @Bean666I've laid out a framework for you to expand on, this code has not been tested, but it should have everything you need to get started, i just kinda got lazy and didn't wanna do client side. This way you don't have to use element data, the data is always there for you to access, and it saves to a json file on the server side, so you'll never have trouble accessing, modifying that data and also players who play on your server wont be able to access that json db file..
    I love using json for saving and loading large chunks of data into code.  If you plan to use this in an official project I suggest actually using MySQL/MariaDB which would be a totally different setup in the code but I'd be willing to switch that over for you if you wanted. Anyways, here you are. Just don't forget to add <oop>true</oop> to your meta file, because otherwise the oop formats in this file wont run.

    local Turf = {}
    Turf.__index = Turf
    
    local claims = {}
    
    local turfChatKey = 'G'
    
    function Turf.getPlayerRank(serial)
    	for i=1, #claims do
    		for k=1, claims[i].members do
    			if claims[i].members[k][1] == serial then
    				return claims[i].members[k][3]
    			end
    		end
    	end
    	return false
    end
    
    function getPlayerTurf(serial)
    	for i=1, #claims do
    		for k=1, claims[i].members do
    			if claims[i].members[k][1] == serial then
    				return claims[i]
    			end
    		end
    	end
    	return false
    end
    
    function Turf.new(name)
    	local self = setmetatable({}, Turf)
    	self.name = name or 'default'
    	
    	self.bank = 0
    	
    	self.members = {}
    	
    	self.land = {}
    	
    	claims[#claims+1] = self
    	return self
    end
    
    function Turf:addLand(x, y, radius)
    	local position = Vector2(x, y) or nil
    	if position then
    		self.land[#self.land+1] = {}
    		self.land[#self.land+1].position = position
    		self.land[#self.land+1].radius = radius or 1
    	end
    end
    
    function Turf:removeLand(x, y)
    	if tonumber(x) and tonumber(y) then
    		for i=1, #self.land do
    			if self.land[i].x == x and self.land[i].y = y then
    				self.land[i] = nil
    			end
    		end
    	end
    end
    
    function Turf:addMember(player) -- player needs to be online
    	if isElement(player) and getElementType(player) == 'player' then
    		self.members[#self.members+1] = {getPlayerSerial(player), getPlayerName(player), 'member'}
    	end
    end
    
    function Turf:removeMember(serial)
    	for i=1, #self.members do
    		if self.members[i][1] == serial then
    			self.members[i] = nil
    		end
    	end
    end
    
    function Turf:playerAddMoney(player, amount) -- player needs to be online
    	if isElement(player) and getElementType(player) == 'player' and tonumber(amount) then
    		if getPlayerMoney(player) >= amount then
    			setPlayerMoney(player, getPlayerMoney(player)-amount)
    			self.bank = self.bank+amount
    		end
    	end
    end
    
    function Turf:playerRemoveMoney(player, amount) -- player needs to be online
    	if isElement(player) and getElementType(player) == 'player' and tonumber(amount) then
    		if self.bank >= amount then
    			setPlayerMoney(player, getPlayerMoney(player)+amount)
    			self.bank = self.bank-amount
    		end
    	end
    end
    
    addCommandHandler('turf', function(player, cmd, ...)
    	local turf = getPlayerTurf(getPlayerSerial(player))
    	if turf then
    		for i=1, #turf.members do
    			local outputUser = getPlayerFromSerial(turf.members[i][1])
    			if outputUser then
    				outputChatBox('['..turf.name..'] '..getPlayerName(player)..': '..table.concat(arg, ' '), outputUser, 255, 255, 255, true)
    			end
    		end
    	end
    end)
    
    function Turf.save()
    	local file = File('turfs.json')
    	file:write(toJSON(claims))
    	file:close()
    end
    addCommandHandler('turfsave', Turf.save)
    
    function Turf.load()
    	local file = fileOpen('turfs.json')
    	if file then
    		local buffer = file:read(file.size)
    		claims = fromJSON(buffer)
    	end
    	file:close()
    end
    
    addEventHandler('onResourceStart', resourceRoot, function()
    	Turf.load()
    	for i, plr in pairs(getElementsByType('player')) do
    		bindKey(plr, turfChatKey, 'down', 'chatbox', 'turf')
    	end
    end)
    
    addEventHandler('onPlayerJoin', root, function()
    	bindKey(source, turfChatKey, 'down', 'chatbox', 'turf')
    end)
    -- example
    local myTurf = Turf.new('my turf name') -- name
    myTurf:addLand(0, 1, 5) -- x, y, radius
    myTurf:addMember(getRandomPlayer()) -- add player, player needs to be online
    myTurf:removeMember('players serial') -- since i used serials you can do this with the player offline.

     

    and when you add/modify any turfs just make sure you do /turfsave in console or in game to save the changes to the file. that way if you restart the resource or the server your last save is loaded. the command will not give an output, just save it and then check the file to see if theres any content, should work just fine.

  3. 22 hours ago, Miyuru said:

    I Found a Method "setVehicleComponentVisible" but it's only show local player? :(

    This is because setVehicleComponentVisible is a client-side only function.
    It's actually possible to combine 2 models into the same file and run them without ID's, or make a custom system for ID's.
    I've successfully added different vehicles to MTA without replacing anything.
    Note it's not advised because the file size just gets insane, textures get jumbled up, and other things.

    • Like 1
  4. 13 hours ago, Pedro001 said:

    Would someone please help me with this thing.

     

    11 hours ago, IIYAMA said:

    Scripting/resource requests should be posted in resources

    @IIYAMAI believe you misunderstood the thread and moved it to the incorrect location, this man was asking for help, someone could make small changes to the code and he'd be set. He isn't asking for a whole resource, nor displaying one.

    • Like 1
  5. Hello everyone, my name is Shay. I'm a 19 year old scripter from USA who started a good community called CoreMTA. This community is dedicated towards teaching people how to script. We also occasionally post public scripts for download on our website, which are free to download and edit. It's our goal to help the MTA community as much as possible. If you have any questions feel free to message me, email me, hit me up on discord, whatever you need.
    ~ ShayF

    Website: CoreMTA
    Forums: CoreMTA Forums
    Discord: CoreMTA Discord

    spacer.png

    spacer.png

    spacer.png

    spacer.pngspacer.png

    • Like 1
  6. Hello, my name is ShayF. I'm sure by now all the staff members if not most of them know about me by now. I was banned a long time ago, I'm not entirely sure when I just know that its been 2 years or more since I was banned on the discord server.

    I was banned due to continuous, persistent, and unreasonable arguments with MTA staff.

    I want to appeal this ban because I really don't even want to bother talking with MTA staff anymore. Ever since I joined MTA I have been trying to help people within the community. I have joined countless servers offering my assistance in making scripts or fixing them, I became really good at scripting. I have made tons of threads on here trying to help people with scripts here on the forums as well. I want to continue helping people and designing great things. I would like another chance on discord to help people there and make friends.

    I apologize for all the trouble that I have caused and I surely won't attempt it again, I don't wanna be on anyone's bad side, there's been too much drama as it stands.

    Thanks, - ShayF
    Discord: ShayF#0259

  7. After talking to countless members of this community I've heard the same thing over and over again. "MTA is a dead game" or "MTA is a dying game".

    As far as I know there are endless possibilities and opportunities to create amazing things within this platform. I see common themes going around for gameplay experiences or 'gamemodes' such as roleplay, cops and robbers, freeroam, race, deathmatch, derby, dayz, and many others. 90% of which I would join and find it to be so much similar to another. I believe that each of these servers needs more diversity.
    This to me became a real problem when I found so many servers ripping scripts from other servers. In fact there have been many times where I met someone who wanted to start a server up within a few days, he wasn't willing to put in the effort to develop his own scripts, instead he was heart set on using scripts that come from another server.

    I've been scripting for a long time now and I've made some amazing things. I can say with certainty that 99% of scripts made in MTA could be so much better. I believe the game could be better as a whole if servers would have more diversity. It should be a goal to be completely different from everything else, and to advance on bigger levels each day..

    Sometimes I believe people when they the game is dying. Server owners and scripters are getting lazy, making script that either just make the cut or stealing them from another server. It's making a general overall gameplay experience on the platform that become boring after so long. If each server had a lot of different things that go in different directions I'm sure the gameplay experience would be more in depth. Especially if the scripts are actually good.

    Too many simple user interfaces, too many user interfaces in general. It's nice when you can have all the stuff you need in one place, but what if it wasn't just stuff you needed? What if it wasn't just in one place? What if the gameplay experience actually had some depth to it, where you can really customize how you play the game. Instead of a server depicting a specific route for you, a route that is the same as everyone else's?

    Here's what I believe. I believe that MTA could be one of the best gaming platforms ever made but in order to achieve that level of success scripters and server owners need to put more time and effort into making their servers with more in depth and modern/old style gameplay with as much diversity as possible.

    ~ Shay

    • Like 2
  8. The reason this no longer works is not an issue with the script, it is an update that google has made to youtube, where they limited the type of devices able to use the TV version of youtube.
    They give a full list of supported devices on this page here: https://support.google.com/youtube/answer/7582560
    Unfortunately without something to act as like an emulator, this problem cannot be fixed.
    MTA can be run on linux, mac, and windows, but in order to emulate a supported device MTA needs to be able to run on something like android, or a smart tv os.
    Even then mta uses a web browser addition called CEF, which many programs use. It's a version of chromium that can be implemented into really any application. CEF is what gives you your youtube videos in game. Unfortunately that is another breaking point.

    This is out of MTA's control, and it is out of Tails or Loki's control, so unfortunately this issue cannot be resolved @Varus01

    ~ Shay

    • Like 1
  9. You can use a youtube api converter to convert youtube videos into mp3 files, however generally these api's only convert music videos. To do this you'd need to do whats called string parsing. Where you take the youtube url and change the string a bit to match what the api needs in order to work, these api's are called web api's and can be used using fetchRemote however it is not ideal because it requires each player to verify access to the url. Alternatively you can use/make your own api with something like nodejs that I don't know much about, but it is a faster, more flexible alternative.
    There is one other way that doesn't require api's or verifying urls, you can run a browser to a youtube link to play the sound however you'd have to find some way to sync it up with other players and also check the distance between the player or where you created the sound and the elements around it for that 3d effect. I hope this helped, good luck to you mate.

    • Like 1
  10. I've been away from MTA for quite some time, probably close to 6 months. I decided to pick up where I left off on one of my projects called Vehicle Manipulation.
    This project is in efforts to allow any modification at all to the car. So far, all I've done is the wheels and greatly greatly improved the whole concept of attaching objects.
    In these images, the wheels are cambered, resized, width changed, and they are spaced away from the vehicle. All of which is fully customizable, let me know your thoughts. If I should continue or not.

    Plans: Animate windows, animate wiper blades, animate steering wheel, animate pedals, animate shifters, animate radios, design an actually realistic shifting system, improve textures, and use processLine to pick up items from the ground and put them on the vehicle or inside the vehicle.

    Spoiler

    unknown.png
    unknown.png

     

  11. local sx,sy = guiGetScreenSize()
    local sw,sh = 1366,768
    
    function toRelative(x,y,w,h)
    	return x/sw*sx,y/sh*sy,w/sw*sx,h/sh*sy
    end
    
    local x,y,w,h = toRelative(400,500,200,300)-- use absolute values here.

     

×
×
  • Create New...