-
Posts
866 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Mr_Moose
-
A client vehicle will only exist in the client who created it somehow, it's pretty much like creating a vehicle in GTA SA single player. A server sided vehicle on the other hand will exist in the server and stay synced between all players in the server. Basically, any element that you want to have synced between all players should be created server side, which is pretty much all elements. I can't find any possible situation where you need to create elements on the client.
-
And the errors would be the following: "Attempt to perform arithmetic on a string value" or something like that which can be seen by reading the code. The solution is simple however, on line 7, 8 and 9: Replace: tostring( ) with: tonumber( )
-
just wanted to ask something about addEventHandler
Mr_Moose replied to toxicsmoke11's topic in Scripting
You may view them in a line to see the difference better: addEventHandler("onPlayerJoin",root,function() end) addEventHandler("onPlayerJoin",root,functionName) So what we can see here is that the first one has the actual function inside the handler as a parameter, this is useful when you want to call a function inside another function and thereby access local variables from the first function inside the second function. setTimer() has some good samples of this. Anyway by using local variables you save memory so it's pretty good for the performance if you want to optimize your scripts. The second one adds a command handler for an already existing function within the same source file, just remember that the function need to be defined before this is executed so it should be added below the function it trigger or inside another function basically. This is more useful for large functions which contains a lot of code but both works no matter what actually. -
Change the order, all code is running from line to line, top to bottom basically: if ( g_xp >= 100 and g_xp <= 150 ) then setElementData(source, "Level", "2") elseif ( g_xp >= 50 and g_xp <= 100 ) then setElementData(source, "Level", "1") This will check if g_xp is bigger than 100 before it check if it's bigger than 50 which is pretty logic in a level up system.
-
Take a look at this one: https://community.multitheftauto.com/index.php?p=resources&s=details&id=9056. Specially made to work with this group system and open source as well. Just remember to verify that the exported functions to get turf color and team color are in the meta.xml file of the group system. <export function="getGroupChatColor" type="server"/> <export function="getGroupTurfColor" type="server"/> It's currently in an early beta state and has only been quickly scripted and tested so there are some configuration to do to make it work, like a few variable names and other exports, but except for that it seems to be pretty appreciated after all. For some reason the whole inspiration for the turf system came from this group system so a special thanks to Smart for the group system.
-
bool guiProgressBarSetProgress ( progressBar theProgressbar, float progress ) Might be an issue in the wiki description, instead of float it's probably int.
-
Well I don't know any way to view all the available commands but you should probably add some kind of restriction to it that for example verify that it is your account that is used while calling that command or similar, some people might be able to guess it, you never know. mabako services is a pretty old resource btw and it might contain bugs. Is there any way to earn money in it by for example rubbing a store, any bank system built in or similar who's values you can reset by reconnect.
-
The second argument in outputChatBox is optional with root as default value, passing any argument that isn't acceptable will either generate errors or output your text to root. There might be a solution to pass a team as argument if you can convert it to an element tree structure. Otherwise it will most likely fall back to root and the team messages keeps showing for all players online. I would recommend the loop based on the table of team members that's probably the easiest solution.
-
It's most likely a bug in any of the scripts that allow the players to send money or some kind of bank system, if you have any of those check so nobody enter a negative amount and gain money to himself for example, looks like you have a pretty good amount of players in your server so another option could be to google "money cheat in (name of your server here)" and see if anything appears. Usually when there are bugs in bank systems or money transfer scripts most people will basically set their money to maximum and think that they get away with it, if they just gain money really fast but in smaller amounts then you should check for people who reconnects very often, reconnecting will reset some values that isn't saved like for example cool down in a job, store robbery or something else where people gain a large amount of money in a short time. Any compiled scripts from untrusted as well as trusted source may contain a hidden command to get money and finally known bugs in community resources. What money related community resources do you have that might be able to trigger the above scenarios.
-
I'm sure you know what kind of text you want to block, otherwise just change line 2 to check for resources instead with these functions: resource getResourceFromName ( string resourceName ) string getResourceName ( resource res ) The important thing is that onClientChatMessage is added before the resources you want to disable chat outputs for.
-
function preventSpam(text) if string.match(text,"text") then cancelEvent() -- don't output it end end addEventHandler("onClientChatMessage", getRootElement(), preventSpam) The solution is onClientChatMessage, just make sure that you add this code in a resource that starts before the resources who's chat box you want to block, otherwise it has no effect. That can be reorganize the resources in server config since they will start in the order they are listed in. Also remember to set "text" to a part of the text output you want to block.
-
You may suggest it here then: https://forum.multitheftauto.com/viewforum.php?f=102, as in the wiki link posted by Ali_Digitali it's only possible for mta to call the radio stations from a client (or make a loop on the server which triggers an event on a lot of clients as described above). That might look like a botnet or some kind of small DDoS attack, anyway currently it seems hard to solve this in lua scripting only and by posting a suggestion this functionality may be added. MTA is based on open source and written in C++ (correct me if I'm wrong here), so the possibility's to improve this is pretty good actually. I'm not an expert when it comes to radio streaming in general but as a server owner and self host I know how annoying it is when the logs get's overflowed like this and the requests is pretty useless. No matter what happens it might take a while before anything is changed (if so) and until then I guess it's best if the server owners somehow get's noticed about this and disable the resources that making a lot of useless calls and instead start to use the individual resources which threads every client as a regular client and let them select a radio station from a list and then listen to it just like if they visited the streaming website. Edit: Btw since you're looking for those who might use this badly implemented radio resources you should probably check with the largest servers in MTA like CIT (http://cit2.net) and notice them about the problem, sadly I'm currently banned there otherwise I could have done it. It was a while ago since I played there but anyway it has the stuff I described above like attaching a sound to a car or an event where like 100 players running in and out all the time and similar so that could eventually be the source to your problem, I would look there if I where you.
-
Well as some people said, the play sound function in MTA may be client sided but the actual sound is an element which can be attached to a car for instance. If this is done on the MTA server it can be synced to the clients while the car is moving within a certain distance and with different volumes depending on distance. I guess that's one reason to why your logs looks like that, just imagine someone who streams the radio station while driving around in a server with a large amount of players where all of them starts to stream the station as soon this car get's nearby. I agree that the solution isn't the best but that's currently how it works, not many servers is using it currently however. Something that would be better where if the function PlaySound() also could be server sided or completely server sided. Basically the server calls the radio stream once and then sends it out to the clients. Another way is to do like in this resource: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8305 which is a client sided GUI with a phone containing a list of radio stations. Players who uses that will only download the radio stream for themselves and no one else which means that the log probably will look like a regular visitor on the webpage.
-
addEventHandler("onMarkerHit",root, function (player) -- source is the marker that you hit when root is the attached element, to get the distance, use this local max,may,maz = getElementPosition(source) local px,py,pz = getElementPosition(player) local distance = getDistanceBetweenPoints3D( max,may,maz, px,py,pz ) end) Don't use loops where it's not needed, this will give you both the marker element and the distance from this marker element to the player or element that just hit it, I'm not sure what you are trying to do but this should cover anything you need in a way more efficient way.
-
[Error] Attempting to compare a number with a boolean
Mr_Moose replied to BrastaSauce's topic in Scripting
Replace this: if (screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then With this: if (screenx and screeny and screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then And the if statement will verify that screenx and screeny has a value that isn't false (which will output the error you received). The root of this problem is as Plean said: "If the cursor isn't showing, returns false as the first value.", another option could be o check if the cursor is showing in this if statement as well. -
Ok then, follow my advice and hopefully you find what's wrong by yourself. Without the code we can't help you.
-
You may have mixed up the amount of end like you did with the variable names, try to use indentation in your code like this: function doSomething(player, cmd) if player then if cmd then -- Just to show how indentation works, way more easy to read now. end end end The errors you receive doesn't seems to be a part of your code either, only the first one at the bottom but it will be easier to find out with some indentation and better names on your variables.
-
Stolen: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8973 Stolen: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8972 Two stolen resources from the original below, same author, irrelevant images, contains outdated code and trademark infringement. Original: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8041 DONE
-
Version 1.4.7 is finally released: Changes in 1.4.7: - Improved the sync algorithm by including carriages rotation - Sync the element syncer to prevent bad sync within the train when the syncer has high ping - Fade out trains that doesn't move due to distance - Added trains on the SF docks railroad - Added train stations where the trains stop for a while - Added stop blocks to prevent "flying trains"* - Improved default values * The term "Flying trains" describe trains that reach the "end" of their track and just keep traveling to the next node but fact is that this nodes doesn't follow the train track which the players can see on the map, by adding stop blocks it's possible to stop the trains before they reach that node where they start to fly. For example between south LV in a straight line to SF train station.
-
Replace line 9 in the first block from this: stopSound ( cds ) to this: if isElement(cds) then stopSound ( cds ) end That will perform a check to see if the sound exist before trying to remove it. The reason is that you are trying to remove the sound before it's created due to the timer you are using, since I'm not sure what you are trying to do I guess this will be the best solution since it will verify that the sound exist before trying to remove it.
-
Line 14, 16, 17, 18, 19: getLocalPlayer is a function, use one of these instead: getLocalPlayer() -- Function to get local player localPlayer -- Predefined variable of local player The source element of onClientVehicleDamage is the vehicle that has been damaged so you don't need line 13 unless if you want to compare it with the source element. Use /debugscript 3 and check the server console for more information about these issues.
-
Try this: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8060, It spawns and handle trains server side just like in GTA SA, fully synced with carriages attached, customizable data file etc..
-
This one will also work: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8783 in case you want a more effective, simple and realistic turf system.
-
addCommandHandler("vender",function(player) if isTimer( timer ) then killTimer ( timer ) end end Always good to verify that something you are trying to delete actually exist
-
There are many RP/RPG servers that has some kind of law and police system, it's all about how much realism you need in it and in any case I would recommend you to use an external wanted level variable that can hold numbers that is larger than 6 (int) otherwise it get's kind of boring when a player committed enough crimes to reach 6 stars and then he can't get more wanted at all. Anyway to solve your problem you should use: if getPlayerWantedLevel( player ) < 6 then setPlayerWantedLevel( player, getPlayerWantedLevel( player ) + 1 ) end Make sure that "player" points at a player and this should also be used on the server to make sure it's synced. The hit counter with the nightstick may be created with the set and getElementData together with a timer pointer table that holds a timer for every player which is started as soon the cop hits the criminal once, this will reduce the hitcounter after a while and kill the timer when it's done and as soon you get 3 hits the arrest function is called. In the arrest function you could either send the suspect to the jail or force him to follow you until you hit the jail marker. Currently it doesn't seem to be any full police script available but I'm planning to release on soon, if you want to try it I recommend you to visit AC RP/CnR/Mw and look at that law and wanted system.