-
Posts
1,193 -
Joined
-
Last visited
Everything posted by tosfera
-
I've never actually used OOP in MTA since Lua doesn't support it by default, the MTA team has created OOP theirselfs with meta tables since that was recommended by Lua itself. yet I don't feel the OOP vibe in lua and therefore I'm not using it. An example can be found on the wiki; -- Exposed to global environment Element = { create = createElement, setPosition = setElementPosition, ... } Vehicle = { create = createVehicle, setColor = setVehicleColor, ... } -- Hidden in lua registry, applied to userdata ElementMT = { __index = CLuaClassDefs::Index, __newindex = CLuaClassDefs::NewIndex, __class = Element, __call = __class.create, __set = { type = CLuaClassDefs::ReadOnly, health = setElementHealth, ... }, __get = { type = getElementType, health = getElementHealth, ... }, } VehicleMT = { __index = CLuaClassDefs::Index, __newindex = CLuaClassDefs::NewIndex, __class = Vehicle, __parent = ElementMT, __call = __class.create, __set = { damageProof = setVehicleDamageProof ... }, __get = { damageProof = isVehicleDamageProof ... }, } source; https://wiki.multitheftauto.com/wiki/OOP
-
Why would you need our help if you are "THE LUA PRINCE !!!%"? Anyway, the error clearly states that there is something wrong in your script on the server. I can't even visit the page so why the hell would your script ever be able to post something there?
-
The error "invalid key to 'next'" has given me such a hard time, but I found out that nothing goes wrong even though the error is there. About the coroutine, are you sure that the coroutine is actually a correctly corrected thing? They are getting spammed since you got an infinite amount of times on your timer.
-
I don't think that's going to work. The wiki states: "Note: This event is only for custom weapons that were created with createWeapon, for player held weapons use onClientPlayerWeaponFire." Therefore the entire eventHandler is wrong, second of all. If a player fires a gun and it's streamed in, no one else will be able to shoot again since ostimer is set to true. I would go for an approach like this; local lawTeam = { [ "Police" ] = true, [ "SWAT" ] = true }; local timers = {} addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), function ( weapon, ammo, _, posX, posY, posZ, target ) if ( getPlayerTeam ( source ) ) then if ( lawTeam [ getTeamName ( getPlayerTeam ( source ) ) ] ) then if ( weapon == 23 ) then if ( isTimer ( timers [ source ] ) ) then outputChatBox ( "Your tazer is still on cooldown.", source ); cancelEvent(); return; end timers [ source ] = setTimer ( function ( thePlayer ) timers [ thePlayer ] = nil; end, 2000, 1, source ); -- your code to "taze" the person end end end end ); Another thing you can do is disable the aim control for the time that the tazer has been disabled.
-
Cancelling a custom event isn't going to do any good. The only thing that has been cancelled with your script @Army@1 is the button's function. But if you bound the button yourself, it'll most likely still bug out and work. @ALw7sH's script is the way to go, sorry that I've been so slow in sending you a reply but his script is going to work. Since you've used custom events, you can't just cancel them without going into the custom made things. You said you're pro at 3 programming languages, I don't believe that. The way you're writing your code lacks all the hints towards a real programmer. For example; Coding styles, lack of common sense, getting stuck at simple things, messing up some copy paste things. Every language is the same as in logic, you just need to learn the syntax.
-
An index is assigned with it's value after the = sign. You first index would've thrown an error since Lua is smart enough to find mistakes like that. If this wasn't the case, a model that equals to "490, 597, etc." would've triggered the function. Each model needs their own single index and value. (:
-
Set some data on the player using setElementData. As long as the player is in jail ( by checking the data ), add a "return" to your executing command. Let's say we set some data on the player his butt; setElementData ( thePlayer, "isJailed", true ); Now, we'll take a look at the f1 and f2 functions. Let's say that we take f1 and f1 is bound to function Support, all you have to do is add a return statement at the first line of the function; if ( getElementData ( thePlayer, "isJailed" ) ) then return end This'll turn off the functions for him even when the player is using commands to avoid the bound button.
-
If you would create a table and make the index equally to the vehicle model and always assign the value 'true' to it, you can use it to see if it's allowed. like so; local allowedVehicles = { [ 599 ] = true }; if ( allowedVehicles [ getElementModel ( vehicle ) ] ) then -- your code here end
-
You need to change the inertia property too. Just editing the maxVelocity won't make it go the actual max speed. The calculations behind the max speed are taken with the mass, intertia and maxVelocity.
-
setWeaponProperty requires more than just editing the damage. You can better cancel the event and create a table in lua with all the weapons and their damages. Just know that if you want to make it more realistic, you should count in body parts too.
-
set the __parent towards your other class in the metatable.
-
Check the distance between the 2, force the client which is following the cop to either run or sprint and press some buttons to make him walk after the cop. Make sure to do this in a fairly short timer to make it as realistic as possible. Functions used, I guess; getElementPosition getDistanceBetweenPoints3D setControlState setTimer
-
getElementModel also works client sided. Once the player presses the key, you should see if the ped is in a vehicle. I'm just not a fan of isPedInVehicle and therefore I'm always using getPedOccupiedVehicle. Once you got an element in there, you're a 100% sure that the ped is in a vehicle. As a simple setup to get you started; local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ); if ( vehicle ) then if ( getElementModel ( vehicle ) == allowed_model ) then -- your code here end end
-
getElementData getPedArmor setPedArmor getElementHealth setElementHealth That's most likely everything you should use.
-
The problem is with your "host" => "89.53.89.145/resources", your host is still "89.53.89.145", take out that "/resources". The location of your resources is indeed at that location, but that doesn't mean that every player is going to connect to the server "89.53.89.145/resources". It's connecting to the server "89.53.89.145". (: Also, change the port to the port which your server is still using, most likely 22003 or 22005. Not sure which port the script most likely uses. Guess it's 22005 since that's the http port.
-
Try to simply remove line by line in the php script until you get something as a return. You're simply getting an empty json_encode in your lua script so it has to be in your php script. Maybe the thing you send towards the script or something that has been messed up in there.
-
I have no idea what you're doing with that, that should be something on your server's side.
-
I've done what you've asked as far as I could understand your question and the script. It might not work because your "admin.number" hasn't been set correctly or what so ever. Whether the player is online or offline, the account data will be set to either true or false ( depending on the command used ) while providing a player's name or his accountname. Since you can't get the account name of a player that has left the server, you need his account username.
-
If you want to set the accountData when they are offline, you're going to need more than just a simple table holding the usernames. You're going to have to ban the users depending on username since the username is the key towards the account. Try something like this; addCommandHandler ( "banaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end ); addCommandHandler ( "unbanaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end );
-
MTA has a really good reason to ban some people. Their system is designed to provide a protection against some serious damage towards servers. A few months ago someone has been banned because he found several ways to get into the server's RAM with such a high amount of requests that the entire server could just crash which results into some pretty high costs for the owners of those servers. If you want to get rid of the system that protects you for these kind of things, go ahead and take it out of your server files, create your own build and enjoy being targeted by people like this.
-
The massive amount of sub domains in webservers and the restricted access in some hosts ( especially free ones ) do have trouble with keeping up. If the browser expects something which isn't returned in the time given, it'll break and most likely crash. This isn't just the case with CEF, some linux based browsers also have this problem. It's some messed up configuration at the side of the host.
-
The 'player' variable ins't being set correctly. You've been adding the command with "addcommand", if I'm not mistaken. Are you sure that it gets the right variable filled in? Try to debug the value which is in "player" and see what's wrong.
-
Visit the PHP script in your browser and see if it's throwing any errors, try to add some debug lines and see what's wrong. I think that when the PHP returns an error, MTA will receive an empty object. Or the script is just sending an empty object since error_reporting is most likely turned off in IPB.
-
The warning only gets thrown when you're trying to add an event handler which has already been added. You can simply ignore it since there won't be any performance issues. Your compiler is just telling you that there has been another eventHandler already linked to the same function and therefore isn't doing it anymore. If you want to clean the warning/errors being dropped in your face, you can always add a simple check to see if the eventHandler has already been added. Create a new boolean variable which gets set to true at this line; addEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) and false at this one ( 2x ); removeEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) If the variable is true, don't add the handler again. Or if you really want to do it even more simple. First remove the eventHandler and then add it back again, like so; function onClientGUIDoubleClick ( ) if ( source == GUIEditor.gridlist[1] ) then selectedItem = nil local r, c = guiGridListGetSelectedItem ( source ) if ( r ~= -1 ) then local name = tostring ( guiGridListGetItemData ( source, r, 1 ) ) local c = getElementData(localPlayer,"SAEGUser:Items")[name] guiSetText ( GUIEditor.edit[1], items[name].desc ) selectedItem = name if ( items[name].requiresInVehicle ) then guiSetText ( GUIEditor.edit[1], guiGetText ( GUIEditor.edit[1] ) .."\n\nThis requires you to be in a vehicle." ) if ( not isPedInVehicle ( localPlayer ) ) then removeEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) end end if ( isPedInVehicle ( localPlayer ) and not items [ name ].useableInVehicle ) then removeEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) elseif ( not isPedInVehicle ( localPlayer ) and not items[name].requiresInVehicle ) then removeEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) addEventHandler ( "onClientGUIDoubleClick", GUIEditor.gridlist[1], onClientGUIDoubleClick ) end end useItem ( selectedItem ) end end